Skip to content

Commit

Permalink
Adding Material Seek Control button size and fade duration config
Browse files Browse the repository at this point in the history
  • Loading branch information
GyanendroKh committed Feb 16, 2023
1 parent 9caca81 commit 38d0209
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/src/center_seek_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ class CenterSeekButton extends StatelessWidget {
required this.backgroundColor,
this.iconColor,
required this.show,
this.fadeDuration = const Duration(milliseconds: 300),
this.iconSize = 26,
this.onPressed,
}) : super(key: key);

Expand All @@ -15,6 +17,8 @@ class CenterSeekButton extends StatelessWidget {
final Color? iconColor;
final bool show;
final VoidCallback? onPressed;
final Duration fadeDuration;
final double iconSize;

@override
Widget build(BuildContext context) {
Expand All @@ -24,7 +28,7 @@ class CenterSeekButton extends StatelessWidget {
child: UnconstrainedBox(
child: AnimatedOpacity(
opacity: show ? 1.0 : 0.0,
duration: const Duration(milliseconds: 300),
duration: fadeDuration,
child: DecoratedBox(
decoration: BoxDecoration(
color: backgroundColor,
Expand All @@ -33,7 +37,7 @@ class CenterSeekButton extends StatelessWidget {
// Always set the iconSize on the IconButton, not on the Icon itself:
// https://github.com/flutter/flutter/issues/52980
child: IconButton(
iconSize: 26,
iconSize: iconSize,
padding: const EdgeInsets.all(8.0),
icon: Icon(iconData, color: iconColor),
onPressed: onPressed,
Expand Down
14 changes: 14 additions & 0 deletions lib/src/chewie_player.dart
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ class ChewieController extends ChangeNotifier {
this.fullScreenByDefault = false,
this.cupertinoProgressColors,
this.materialProgressColors,
this.materialSeekButtonFadeDuration = const Duration(milliseconds: 300),
this.materialSeekButtonSize = 26,
this.placeholder,
this.overlay,
this.showControlsOnInitialize = true,
Expand Down Expand Up @@ -302,6 +304,8 @@ class ChewieController extends ChangeNotifier {
bool? fullScreenByDefault,
ChewieProgressColors? cupertinoProgressColors,
ChewieProgressColors? materialProgressColors,
Duration? materialSeekButtonFadeDuration,
double? materialSeekButtonSize,
Widget? placeholder,
Widget? overlay,
bool? showControlsOnInitialize,
Expand Down Expand Up @@ -352,6 +356,10 @@ class ChewieController extends ChangeNotifier {
cupertinoProgressColors ?? this.cupertinoProgressColors,
materialProgressColors:
materialProgressColors ?? this.materialProgressColors,
materialSeekButtonFadeDuration:
materialSeekButtonFadeDuration ?? this.materialSeekButtonFadeDuration,
materialSeekButtonSize:
materialSeekButtonSize ?? this.materialSeekButtonSize,
placeholder: placeholder ?? this.placeholder,
overlay: overlay ?? this.overlay,
showControlsOnInitialize:
Expand Down Expand Up @@ -475,6 +483,12 @@ class ChewieController extends ChangeNotifier {
/// player uses the colors from your Theme.
final ChewieProgressColors? materialProgressColors;

// The duration of the fade animation for the seek button (Material Player only)
final Duration materialSeekButtonFadeDuration;

// The size of the seek button for the Material Player only
final double materialSeekButtonSize;

/// The placeholder is displayed underneath the Video before it is initialized
/// or played.
final Widget? placeholder;
Expand Down
4 changes: 4 additions & 0 deletions lib/src/material/material_controls.dart
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,8 @@ class _MaterialControlsState extends State<MaterialControls>
backgroundColor: Colors.black54,
iconColor: Colors.white,
show: showPlayButton,
fadeDuration: chewieController.materialSeekButtonFadeDuration,
iconSize: chewieController.materialSeekButtonSize,
onPressed: _seekBackward,
),
Container(
Expand All @@ -420,6 +422,8 @@ class _MaterialControlsState extends State<MaterialControls>
backgroundColor: Colors.black54,
iconColor: Colors.white,
show: showPlayButton,
fadeDuration: chewieController.materialSeekButtonFadeDuration,
iconSize: chewieController.materialSeekButtonSize,
onPressed: _seekForward,
),
],
Expand Down

0 comments on commit 38d0209

Please sign in to comment.