Skip to content

Commit

Permalink
Bugfix/hot reload fix (#729)
Browse files Browse the repository at this point in the history
* Fixed hot reload issue

* Revert normal player page

* Added useRootNavigator option to BetterPlayerConfiguration

* Updated changelog
  • Loading branch information
jhomlala authored Sep 25, 2021
1 parent ccd88ae commit 64178b0
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 37 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
8 changes: 8 additions & 0 deletions docs/generalconfiguration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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;
```
86 changes: 50 additions & 36 deletions lib/src/configuration/better_player_configuration.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -179,6 +185,10 @@ class BetterPlayerConfiguration {
Function(double visibilityFraction)? playerVisibilityChangedBehavior,
List<BetterPlayerTranslations>? translations,
bool? autoDetectFullscreenDeviceOrientation,
bool? handleLifecycle,
bool? autoDispose,
bool? expandToFill,
bool? useRootNavigator,
}) {
return BetterPlayerConfiguration(
aspectRatio: aspectRatio ?? this.aspectRatio,
Expand Down Expand Up @@ -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,
);
}
}
7 changes: 6 additions & 1 deletion lib/src/controls/better_player_controls_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,9 @@ abstract class BetterPlayerControlsState<T extends StatefulWidget>
showCupertinoModalPopup<void>(
barrierColor: Colors.transparent,
context: context,
useRootNavigator:
betterPlayerController?.betterPlayerConfiguration.useRootNavigator ??
false,
builder: (context) {
return SafeArea(
top: false,
Expand Down Expand Up @@ -488,6 +491,9 @@ abstract class BetterPlayerControlsState<T extends StatefulWidget>
showModalBottomSheet<void>(
backgroundColor: Colors.transparent,
context: context,
useRootNavigator:
betterPlayerController?.betterPlayerConfiguration.useRootNavigator ??
false,
builder: (context) {
return SafeArea(
top: false,
Expand All @@ -497,7 +503,6 @@ abstract class BetterPlayerControlsState<T extends StatefulWidget>
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)),
Expand Down

0 comments on commit 64178b0

Please sign in to comment.