diff --git a/CHANGELOG.md b/CHANGELOG.md index 099d85689..f71888d53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,8 @@ ## 0.0.76 * Fixed iOS build issue. * [BREAKING_CHANGE] Changed min required iOS version to 11. +* Updated `BetterPlayerConfiguration` `copyWith` method. +* Added `useRootNavigator` option to `BetterPlayerConfiguration`. ## 0.0.75 * Fixed iOS build issue. diff --git a/docs/generalconfiguration.md b/docs/generalconfiguration.md index edddcc83f..8abf05ed0 100644 --- a/docs/generalconfiguration.md +++ b/docs/generalconfiguration.md @@ -108,4 +108,12 @@ final bool handleLifecycle; ///Defines flag which enabled/disabled auto dispose on BetterPlayer dispose. ///Default value is true. final bool autoDispose; + +///Flag which causes to player expand to fill all remaining space. Set to false +///to use minimum constraints +final bool expandToFill; + +///Flag which causes to player use the root navigator to open new pages. +///Default value is false. +final bool useRootNavigator; ``` \ No newline at end of file diff --git a/lib/src/configuration/better_player_configuration.dart b/lib/src/configuration/better_player_configuration.dart index fc958210f..a493f9a78 100644 --- a/lib/src/configuration/better_player_configuration.dart +++ b/lib/src/configuration/better_player_configuration.dart @@ -116,42 +116,48 @@ class BetterPlayerConfiguration { ///to use minimum constraints final bool expandToFill; - const BetterPlayerConfiguration( - {this.aspectRatio, - this.autoPlay = false, - this.startAt, - this.looping = false, - this.fullScreenByDefault = false, - this.placeholder, - this.showPlaceholderUntilPlay = false, - this.placeholderOnTop = true, - this.overlay, - this.errorBuilder, - this.allowedScreenSleep = true, - this.fullScreenAspectRatio, - this.deviceOrientationsOnFullScreen = const [ - DeviceOrientation.landscapeLeft, - DeviceOrientation.landscapeRight, - ], - this.systemOverlaysAfterFullScreen = SystemUiOverlay.values, - this.deviceOrientationsAfterFullScreen = const [ - DeviceOrientation.portraitUp, - DeviceOrientation.portraitDown, - DeviceOrientation.landscapeLeft, - DeviceOrientation.landscapeRight, - ], - this.routePageBuilder, - this.eventListener, - this.subtitlesConfiguration = const BetterPlayerSubtitlesConfiguration(), - this.controlsConfiguration = const BetterPlayerControlsConfiguration(), - this.fit = BoxFit.fill, - this.rotation = 0, - this.playerVisibilityChangedBehavior, - this.translations, - this.autoDetectFullscreenDeviceOrientation = false, - this.handleLifecycle = true, - this.autoDispose = true, - this.expandToFill = true}); + ///Flag which causes to player use the root navigator to open new pages. + ///Default value is false. + final bool useRootNavigator; + + const BetterPlayerConfiguration({ + this.aspectRatio, + this.autoPlay = false, + this.startAt, + this.looping = false, + this.fullScreenByDefault = false, + this.placeholder, + this.showPlaceholderUntilPlay = false, + this.placeholderOnTop = true, + this.overlay, + this.errorBuilder, + this.allowedScreenSleep = true, + this.fullScreenAspectRatio, + this.deviceOrientationsOnFullScreen = const [ + DeviceOrientation.landscapeLeft, + DeviceOrientation.landscapeRight, + ], + this.systemOverlaysAfterFullScreen = SystemUiOverlay.values, + this.deviceOrientationsAfterFullScreen = const [ + DeviceOrientation.portraitUp, + DeviceOrientation.portraitDown, + DeviceOrientation.landscapeLeft, + DeviceOrientation.landscapeRight, + ], + this.routePageBuilder, + this.eventListener, + this.subtitlesConfiguration = const BetterPlayerSubtitlesConfiguration(), + this.controlsConfiguration = const BetterPlayerControlsConfiguration(), + this.fit = BoxFit.fill, + this.rotation = 0, + this.playerVisibilityChangedBehavior, + this.translations, + this.autoDetectFullscreenDeviceOrientation = false, + this.handleLifecycle = true, + this.autoDispose = true, + this.expandToFill = true, + this.useRootNavigator = false, + }); BetterPlayerConfiguration copyWith({ double? aspectRatio, @@ -179,6 +185,10 @@ class BetterPlayerConfiguration { Function(double visibilityFraction)? playerVisibilityChangedBehavior, List? translations, bool? autoDetectFullscreenDeviceOrientation, + bool? handleLifecycle, + bool? autoDispose, + bool? expandToFill, + bool? useRootNavigator, }) { return BetterPlayerConfiguration( aspectRatio: aspectRatio ?? this.aspectRatio, @@ -215,6 +225,10 @@ class BetterPlayerConfiguration { autoDetectFullscreenDeviceOrientation: autoDetectFullscreenDeviceOrientation ?? this.autoDetectFullscreenDeviceOrientation, + handleLifecycle: handleLifecycle ?? this.handleLifecycle, + autoDispose: autoDispose ?? this.autoDispose, + expandToFill: expandToFill ?? this.expandToFill, + useRootNavigator: useRootNavigator ?? this.useRootNavigator, ); } } diff --git a/lib/src/controls/better_player_controls_state.dart b/lib/src/controls/better_player_controls_state.dart index 55434d57f..3e1f92549 100644 --- a/lib/src/controls/better_player_controls_state.dart +++ b/lib/src/controls/better_player_controls_state.dart @@ -460,6 +460,9 @@ abstract class BetterPlayerControlsState showCupertinoModalPopup( barrierColor: Colors.transparent, context: context, + useRootNavigator: + betterPlayerController?.betterPlayerConfiguration.useRootNavigator ?? + false, builder: (context) { return SafeArea( top: false, @@ -488,6 +491,9 @@ abstract class BetterPlayerControlsState showModalBottomSheet( backgroundColor: Colors.transparent, context: context, + useRootNavigator: + betterPlayerController?.betterPlayerConfiguration.useRootNavigator ?? + false, builder: (context) { return SafeArea( top: false, @@ -497,7 +503,6 @@ abstract class BetterPlayerControlsState padding: const EdgeInsets.symmetric(horizontal: 4, vertical: 8), decoration: BoxDecoration( color: betterPlayerControlsConfiguration.overflowModalColor, - /*shape: RoundedRectangleBorder(side: Bor,borderRadius: 24,)*/ borderRadius: const BorderRadius.only( topLeft: Radius.circular(24.0), topRight: Radius.circular(24.0)),