Skip to content

Commit 38d0209

Browse files
committed
Adding Material Seek Control button size and fade duration config
1 parent 9caca81 commit 38d0209

File tree

3 files changed

+24
-2
lines changed

3 files changed

+24
-2
lines changed

lib/src/center_seek_button.dart

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ class CenterSeekButton extends StatelessWidget {
77
required this.backgroundColor,
88
this.iconColor,
99
required this.show,
10+
this.fadeDuration = const Duration(milliseconds: 300),
11+
this.iconSize = 26,
1012
this.onPressed,
1113
}) : super(key: key);
1214

@@ -15,6 +17,8 @@ class CenterSeekButton extends StatelessWidget {
1517
final Color? iconColor;
1618
final bool show;
1719
final VoidCallback? onPressed;
20+
final Duration fadeDuration;
21+
final double iconSize;
1822

1923
@override
2024
Widget build(BuildContext context) {
@@ -24,7 +28,7 @@ class CenterSeekButton extends StatelessWidget {
2428
child: UnconstrainedBox(
2529
child: AnimatedOpacity(
2630
opacity: show ? 1.0 : 0.0,
27-
duration: const Duration(milliseconds: 300),
31+
duration: fadeDuration,
2832
child: DecoratedBox(
2933
decoration: BoxDecoration(
3034
color: backgroundColor,
@@ -33,7 +37,7 @@ class CenterSeekButton extends StatelessWidget {
3337
// Always set the iconSize on the IconButton, not on the Icon itself:
3438
// https://github.com/flutter/flutter/issues/52980
3539
child: IconButton(
36-
iconSize: 26,
40+
iconSize: iconSize,
3741
padding: const EdgeInsets.all(8.0),
3842
icon: Icon(iconData, color: iconColor),
3943
onPressed: onPressed,

lib/src/chewie_player.dart

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,8 @@ class ChewieController extends ChangeNotifier {
255255
this.fullScreenByDefault = false,
256256
this.cupertinoProgressColors,
257257
this.materialProgressColors,
258+
this.materialSeekButtonFadeDuration = const Duration(milliseconds: 300),
259+
this.materialSeekButtonSize = 26,
258260
this.placeholder,
259261
this.overlay,
260262
this.showControlsOnInitialize = true,
@@ -302,6 +304,8 @@ class ChewieController extends ChangeNotifier {
302304
bool? fullScreenByDefault,
303305
ChewieProgressColors? cupertinoProgressColors,
304306
ChewieProgressColors? materialProgressColors,
307+
Duration? materialSeekButtonFadeDuration,
308+
double? materialSeekButtonSize,
305309
Widget? placeholder,
306310
Widget? overlay,
307311
bool? showControlsOnInitialize,
@@ -352,6 +356,10 @@ class ChewieController extends ChangeNotifier {
352356
cupertinoProgressColors ?? this.cupertinoProgressColors,
353357
materialProgressColors:
354358
materialProgressColors ?? this.materialProgressColors,
359+
materialSeekButtonFadeDuration:
360+
materialSeekButtonFadeDuration ?? this.materialSeekButtonFadeDuration,
361+
materialSeekButtonSize:
362+
materialSeekButtonSize ?? this.materialSeekButtonSize,
355363
placeholder: placeholder ?? this.placeholder,
356364
overlay: overlay ?? this.overlay,
357365
showControlsOnInitialize:
@@ -475,6 +483,12 @@ class ChewieController extends ChangeNotifier {
475483
/// player uses the colors from your Theme.
476484
final ChewieProgressColors? materialProgressColors;
477485

486+
// The duration of the fade animation for the seek button (Material Player only)
487+
final Duration materialSeekButtonFadeDuration;
488+
489+
// The size of the seek button for the Material Player only
490+
final double materialSeekButtonSize;
491+
478492
/// The placeholder is displayed underneath the Video before it is initialized
479493
/// or played.
480494
final Widget? placeholder;

lib/src/material/material_controls.dart

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,6 +399,8 @@ class _MaterialControlsState extends State<MaterialControls>
399399
backgroundColor: Colors.black54,
400400
iconColor: Colors.white,
401401
show: showPlayButton,
402+
fadeDuration: chewieController.materialSeekButtonFadeDuration,
403+
iconSize: chewieController.materialSeekButtonSize,
402404
onPressed: _seekBackward,
403405
),
404406
Container(
@@ -420,6 +422,8 @@ class _MaterialControlsState extends State<MaterialControls>
420422
backgroundColor: Colors.black54,
421423
iconColor: Colors.white,
422424
show: showPlayButton,
425+
fadeDuration: chewieController.materialSeekButtonFadeDuration,
426+
iconSize: chewieController.materialSeekButtonSize,
423427
onPressed: _seekForward,
424428
),
425429
],

0 commit comments

Comments
 (0)