Skip to content

Commit

Permalink
Add settings and fullscreenDialog params to the constructors of m…
Browse files Browse the repository at this point in the history
…odal sheet routes and pages (#28)

Fixes #24.
  • Loading branch information
fujidaiti authored Feb 15, 2024
1 parent 24b5ba4 commit 499625b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
16 changes: 14 additions & 2 deletions package/lib/src/modal/cupertino.dart
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,10 @@ class _CupertinoStackedTransitionState extends State<CupertinoStackedTransition>

abstract class _BaseCupertinoModalSheetRoute<T> extends PageRoute<T>
with ModalSheetRouteMixin<T> {
_BaseCupertinoModalSheetRoute({super.settings});
_BaseCupertinoModalSheetRoute({
super.settings,
super.fullscreenDialog,
});

PageRoute<dynamic>? _previousRoute;

Expand Down Expand Up @@ -407,6 +410,7 @@ class CupertinoModalSheetPage<T> extends Page<T> {
this.maintainState = true,
this.enablePullToDismiss = true,
this.barrierDismissible = true,
this.fullscreenDialog = false,
this.barrierLabel,
this.barrierColor = _cupertinoBarrierColor,
this.transitionDuration = _cupertinoTransitionDuration,
Expand All @@ -420,6 +424,8 @@ class CupertinoModalSheetPage<T> extends Page<T> {
/// {@macro flutter.widgets.ModalRoute.maintainState}
final bool maintainState;

final bool fullscreenDialog;

final Color? barrierColor;

final bool barrierDismissible;
Expand All @@ -434,14 +440,18 @@ class CupertinoModalSheetPage<T> extends Page<T> {

@override
Route<T> createRoute(BuildContext context) {
return _PageBasedCupertinoModalSheetRoute(page: this);
return _PageBasedCupertinoModalSheetRoute(
page: this,
fullscreenDialog: fullscreenDialog,
);
}
}

class _PageBasedCupertinoModalSheetRoute<T>
extends _BaseCupertinoModalSheetRoute<T> {
_PageBasedCupertinoModalSheetRoute({
required CupertinoModalSheetPage<T> page,
super.fullscreenDialog,
}) : super(settings: page);

CupertinoModalSheetPage<T> get _page =>
Expand Down Expand Up @@ -477,6 +487,8 @@ class _PageBasedCupertinoModalSheetRoute<T>

class CupertinoModalSheetRoute<T> extends _BaseCupertinoModalSheetRoute<T> {
CupertinoModalSheetRoute({
super.settings,
super.fullscreenDialog,
required this.builder,
this.enablePullToDismiss = true,
this.maintainState = true,
Expand Down
11 changes: 10 additions & 1 deletion package/lib/src/modal/modal_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ModalSheetPage<T> extends Page<T> {
this.maintainState = true,
this.enablePullToDismiss = true,
this.barrierDismissible = true,
this.fullscreenDialog = false,
this.barrierLabel,
this.barrierColor = Colors.black54,
this.transitionDuration = const Duration(milliseconds: 300),
Expand All @@ -35,6 +36,8 @@ class ModalSheetPage<T> extends Page<T> {
/// {@macro flutter.widgets.ModalRoute.maintainState}
final bool maintainState;

final bool fullscreenDialog;

final Color? barrierColor;

final bool barrierDismissible;
Expand All @@ -49,14 +52,18 @@ class ModalSheetPage<T> extends Page<T> {

@override
Route<T> createRoute(BuildContext context) {
return _PageBasedModalSheetRoute(page: this);
return _PageBasedModalSheetRoute(
page: this,
fullscreenDialog: fullscreenDialog,
);
}
}

class _PageBasedModalSheetRoute<T> extends PageRoute<T>
with ModalSheetRouteMixin<T> {
_PageBasedModalSheetRoute({
required ModalSheetPage<T> page,
super.fullscreenDialog,
}) : super(settings: page);

ModalSheetPage<T> get _page => settings as ModalSheetPage<T>;
Expand Down Expand Up @@ -91,6 +98,8 @@ class _PageBasedModalSheetRoute<T> extends PageRoute<T>

class ModalSheetRoute<T> extends PageRoute<T> with ModalSheetRouteMixin<T> {
ModalSheetRoute({
super.settings,
super.fullscreenDialog,
required this.builder,
this.enablePullToDismiss = true,
this.maintainState = true,
Expand Down

0 comments on commit 499625b

Please sign in to comment.