Skip to content

Commit

Permalink
Allow customising controls
Browse files Browse the repository at this point in the history
More finegraned customisation of exisiting controls to be added later.
  • Loading branch information
cbenhagen committed Jan 17, 2019
1 parent f3fa335 commit aeac812
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions lib/chewie.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
library chewie;

export 'src/chewie_player.dart';
export 'src/chewie_controller.dart';
export 'src/chewie_progress_colors.dart';
5 changes: 5 additions & 0 deletions lib/src/chewie_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ class ChewieController extends ChangeNotifier {
this.materialProgressColors,
this.placeholder,
this.showControls = true,
this.customControls,
this.allowedScreenSleep = true,
this.isLive = false,
}) : assert(videoPlayerController != null,
Expand All @@ -40,6 +41,10 @@ class ChewieController extends ChangeNotifier {
/// Whether or not to show the controls
final bool showControls;

/// Defines customised controls. Check [MaterialControls] or
/// [CupertinoControls] for reference.
final Widget customControls;

/// The Aspect Ratio of the Video. Important to get the correct size of the
/// video!
///
Expand Down
17 changes: 9 additions & 8 deletions lib/src/player_with_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@ class PlayerWithControls extends StatelessWidget {
child: AspectRatio(
aspectRatio: chewieController.aspectRatio ??
_calculateAspectRatio(context),
child:
VideoPlayer(chewieController.videoPlayerController),
child: VideoPlayer(chewieController.videoPlayerController),
),
),
),
Expand All @@ -55,12 +54,14 @@ class PlayerWithControls extends StatelessWidget {
ChewieController chewieController,
) {
return chewieController.showControls
? Theme.of(context).platform == TargetPlatform.android
? MaterialControls()
: CupertinoControls(
backgroundColor: Color.fromRGBO(41, 41, 41, 0.7),
iconColor: Color.fromARGB(255, 200, 200, 200),
)
? chewieController.customControls != null
? chewieController.customControls
: Theme.of(context).platform == TargetPlatform.android
? MaterialControls()
: CupertinoControls(
backgroundColor: Color.fromRGBO(41, 41, 41, 0.7),
iconColor: Color.fromARGB(255, 200, 200, 200),
)
: Container();
}

Expand Down

0 comments on commit aeac812

Please sign in to comment.