diff --git a/example/lib/app/app.dart b/example/lib/app/app.dart index 2f6d165cf..99f7e3f5f 100644 --- a/example/lib/app/app.dart +++ b/example/lib/app/app.dart @@ -189,9 +189,9 @@ class _ChewieDemoState extends State { ? Chewie( controller: _chewieController!, ) - : const Column( + : Column( mainAxisAlignment: MainAxisAlignment.center, - children: [ + children: const [ CircularProgressIndicator(), SizedBox(height: 20), Text('Loading'), diff --git a/lib/src/cupertino/cupertino_controls.dart b/lib/src/cupertino/cupertino_controls.dart index 7e16b38a1..0a1cd6d63 100644 --- a/lib/src/cupertino/cupertino_controls.dart +++ b/lib/src/cupertino/cupertino_controls.dart @@ -22,12 +22,20 @@ class CupertinoControls extends StatefulWidget { required this.backgroundColor, required this.iconColor, this.showPlayButton = true, + this.iconSelectedColor, + this.textStyle, + this.mainAxisAlignment, + this.paddingItem = const EdgeInsets.all(0.0), Key? key, }) : super(key: key); final Color backgroundColor; final Color iconColor; + final Color? iconSelectedColor; + final TextStyle? textStyle; + final MainAxisAlignment? mainAxisAlignment; final bool showPlayButton; + final EdgeInsets paddingItem; @override State createState() { @@ -35,8 +43,7 @@ class CupertinoControls extends StatefulWidget { } } -class _CupertinoControlsState extends State - with SingleTickerProviderStateMixin { +class _CupertinoControlsState extends State with SingleTickerProviderStateMixin { late PlayerNotifier notifier; late VideoPlayerValue _latestValue; double? _latestVolume; @@ -84,6 +91,10 @@ class _CupertinoControlsState extends State final orientation = MediaQuery.of(context).orientation; final barHeight = orientation == Orientation.portrait ? 30.0 : 47.0; final buttonPadding = orientation == Orientation.portrait ? 16.0 : 24.0; + final style = TextStyle( + color: iconColor, + fontSize: orientation == Orientation.portrait ? 12.0 : 16.0, + ); return MouseRegion( onHover: (_) => _cancelAndRestartTimer(), @@ -117,7 +128,7 @@ class _CupertinoControlsState extends State ), child: _buildSubtitles(chewieController.subtitle!), ), - _buildBottomBar(backgroundColor, iconColor, barHeight), + _buildBottomBar(backgroundColor, iconColor, barHeight, style), ], ), ], @@ -178,8 +189,7 @@ class _CupertinoControlsState extends State useRootNavigator: chewieController.useRootNavigator, builder: (context) => CupertinoOptionsDialog( options: options, - cancelButtonText: - chewieController.optionsTranslation?.cancelButtonText, + cancelButtonText: chewieController.optionsTranslation?.cancelButtonText, ), ); if (_latestValue.isPlaying) { @@ -243,6 +253,7 @@ class _CupertinoControlsState extends State Color backgroundColor, Color iconColor, double barHeight, + TextStyle? textStyle, ) { return SafeArea( bottom: chewieController.isFullScreen, @@ -284,8 +295,7 @@ class _CupertinoControlsState extends State if (chewieController.allowPlaybackSpeedChanging) _buildSpeedButton(controller, iconColor, barHeight), if (chewieController.additionalOptions != null && - chewieController - .additionalOptions!(context).isNotEmpty) + chewieController.additionalOptions!(context).isNotEmpty) _buildOptionsButton(iconColor, barHeight), ], ), @@ -347,8 +357,7 @@ class _CupertinoControlsState extends State Widget _buildHitArea() { final bool isFinished = _latestValue.position >= _latestValue.duration; - final bool showPlayButton = - widget.showPlayButton && !_latestValue.isPlaying && !_dragging; + final bool showPlayButton = widget.showPlayButton && !_latestValue.isPlaying && !_dragging; return GestureDetector( onTap: _latestValue.isPlaying @@ -554,6 +563,12 @@ class _CupertinoControlsState extends State builder: (context) => _PlaybackSpeedDialog( speeds: chewieController.playbackSpeeds, selected: _latestValue.playbackSpeed, + iconColor: widget.iconSelectedColor ?? Colors.white, + textStyle: widget.textStyle ?? + const TextStyle(color: Colors.black, fontSize: 16.0), + mainAxisAlignment: widget.mainAxisAlignment ?? + MainAxisAlignment.center, + paddingItem: widget.paddingItem, ), ); @@ -751,16 +766,14 @@ class _CupertinoControlsState extends State void _skipBack() { _cancelAndRestartTimer(); final beginning = Duration.zero.inMilliseconds; - final skip = - (_latestValue.position - const Duration(seconds: 15)).inMilliseconds; + final skip = (_latestValue.position - const Duration(seconds: 15)).inMilliseconds; controller.seekTo(Duration(milliseconds: math.max(skip, beginning))); } void _skipForward() { _cancelAndRestartTimer(); final end = _latestValue.duration.inMilliseconds; - final skip = - (_latestValue.position + const Duration(seconds: 15)).inMilliseconds; + final skip = (_latestValue.position + const Duration(seconds: 15)).inMilliseconds; controller.seekTo(Duration(milliseconds: math.min(skip, end))); } @@ -813,17 +826,23 @@ class _PlaybackSpeedDialog extends StatelessWidget { Key? key, required List speeds, required double selected, + required this.iconColor, + required this.textStyle, + required this.mainAxisAlignment, + required this.paddingItem, }) : _speeds = speeds, _selected = selected, super(key: key); final List _speeds; final double _selected; + final Color iconColor; + final TextStyle textStyle; + final MainAxisAlignment mainAxisAlignment; + final EdgeInsets paddingItem; @override Widget build(BuildContext context) { - final selectedColor = CupertinoTheme.of(context).primaryColor; - return CupertinoActionSheet( actions: _speeds .map( @@ -832,11 +851,16 @@ class _PlaybackSpeedDialog extends StatelessWidget { Navigator.of(context).pop(e); }, child: Row( - mainAxisAlignment: MainAxisAlignment.center, + mainAxisAlignment: mainAxisAlignment, children: [ if (e == _selected) - Icon(Icons.check, size: 20.0, color: selectedColor), - Text(e.toString()), + Icon(Icons.check, size: 20.0, color: iconColor) + else if (MainAxisAlignment.start == mainAxisAlignment) + SizedBox(width: 20.0), + Padding( + padding: paddingItem, + child: Text(e.toString(), style: textStyle), + ), ], ), ), diff --git a/pubspec.yaml b/pubspec.yaml index b6bdabe63..9e0d762f2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,6 +2,7 @@ name: chewie description: A video player for Flutter with Cupertino and Material play controls version: 1.5.0 homepage: https://github.com/fluttercommunity/chewie +publish_to: none environment: sdk: '>=2.13.0 <4.0.0'