From 38d02096bf6ed6f3544a008a4375b42d925b3931 Mon Sep 17 00:00:00 2001 From: Gyanendro Kh <16163526+GyanendroKh@users.noreply.github.com> Date: Thu, 16 Feb 2023 07:57:59 +0530 Subject: [PATCH] Adding Material Seek Control button size and fade duration config --- lib/src/center_seek_button.dart | 8 ++++++-- lib/src/chewie_player.dart | 14 ++++++++++++++ lib/src/material/material_controls.dart | 4 ++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/lib/src/center_seek_button.dart b/lib/src/center_seek_button.dart index a8313b7d4..ce890a41e 100644 --- a/lib/src/center_seek_button.dart +++ b/lib/src/center_seek_button.dart @@ -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); @@ -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) { @@ -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, @@ -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, diff --git a/lib/src/chewie_player.dart b/lib/src/chewie_player.dart index 923996c7a..c62f73158 100644 --- a/lib/src/chewie_player.dart +++ b/lib/src/chewie_player.dart @@ -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, @@ -302,6 +304,8 @@ class ChewieController extends ChangeNotifier { bool? fullScreenByDefault, ChewieProgressColors? cupertinoProgressColors, ChewieProgressColors? materialProgressColors, + Duration? materialSeekButtonFadeDuration, + double? materialSeekButtonSize, Widget? placeholder, Widget? overlay, bool? showControlsOnInitialize, @@ -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: @@ -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; diff --git a/lib/src/material/material_controls.dart b/lib/src/material/material_controls.dart index e4f1197e8..667fd1a5d 100644 --- a/lib/src/material/material_controls.dart +++ b/lib/src/material/material_controls.dart @@ -399,6 +399,8 @@ class _MaterialControlsState extends State backgroundColor: Colors.black54, iconColor: Colors.white, show: showPlayButton, + fadeDuration: chewieController.materialSeekButtonFadeDuration, + iconSize: chewieController.materialSeekButtonSize, onPressed: _seekBackward, ), Container( @@ -420,6 +422,8 @@ class _MaterialControlsState extends State backgroundColor: Colors.black54, iconColor: Colors.white, show: showPlayButton, + fadeDuration: chewieController.materialSeekButtonFadeDuration, + iconSize: chewieController.materialSeekButtonSize, onPressed: _seekForward, ), ],