From 89dd5be4a84400dc00f00b46152ab7a6d8bf9817 Mon Sep 17 00:00:00 2001 From: savy91 Date: Thu, 26 Sep 2019 16:27:31 +0200 Subject: [PATCH 1/3] Added possibility to show a modal bottom sheet with rounded borders --- lib/stopper.dart | 58 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/lib/stopper.dart b/lib/stopper.dart index 57a24e5..cfffb26 100644 --- a/lib/stopper.dart +++ b/lib/stopper.dart @@ -28,6 +28,8 @@ class Stopper extends StatefulWidget { final int initialStop; /// The minimum offset (in logical pixels) necessary to trigger a stop change when dragging. final double dragThreshold; + /// THe desidered shape + final ShapeBorder shape; /// The constructor. Stopper({ @@ -36,7 +38,8 @@ class Stopper extends StatefulWidget { @required this.stops, this.initialStop = 0, this.onClose, - this.dragThreshold = 25 + this.dragThreshold = 25, + this.shape = null }) : assert(initialStop < stops.length), super(key: key); @@ -219,13 +222,18 @@ PersistentBottomSheetController showStopper( /// If [true] then the user can close the bottom sheet dragging it down from the lowest stop. bool userCanClose = true, /// The minimum offset (in logical pixels) to trigger a stop change when dragging. - double dragThreshold = 25 + double dragThreshold = 25, + /// The desidered shape + ShapeBorder shape = null, + /// Required for modal bottomSheet + bool isScrollController = true }) { PersistentBottomSheetController cont; cont = showBottomSheet( context: context, builder: (context) { return Stopper( + shape: shape, key: key, builder: builder, stops: stops, @@ -239,3 +247,49 @@ PersistentBottomSheetController showStopper( ); return cont; } + +/// Shows the Stopper bottom sheet. +/// Returns a [PersistentBottomSheetController] that can be used +Future showModalStopper( + { + /// The key of the [Stopper] widget + Key key, + /// The build context + @required BuildContext context, + /// The builder of the bottom sheet + @required StopperBuilder builder, + /// The list of stop heights as logical pixel values. Use [MediaQuery] to compute the heights relative to screen height. + /// The order of the stop heights must be from the lowest to the highest. + @required List stops, + /// The initial stop number. + int initialStop = 0, + /// If [true] then the user can close the bottom sheet dragging it down from the lowest stop. + bool userCanClose = true, + /// The minimum offset (in logical pixels) to trigger a stop change when dragging. + double dragThreshold = 25, + /// The desidered shape + ShapeBorder shape = null, + /// Required for modal bottomSheet + bool isScrollController = true + }) { + Future cont; + cont = showModalBottomSheet( + shape: shape, + isScrollControlled: true, + context: context, + builder: (context) { + return Stopper( + shape: shape, + key: key, + builder: builder, + stops: stops, + initialStop: initialStop, + dragThreshold: dragThreshold, +// onClose: userCanClose ? () { +// cont.close(); +// }: null, + ); + }, + ); + return cont; +} \ No newline at end of file From 880931296aa94b797aa7d1f4c1a1a2489719a5d5 Mon Sep 17 00:00:00 2001 From: savy91 Date: Thu, 26 Sep 2019 16:32:44 +0200 Subject: [PATCH 2/3] Added possibility to show a modal bottom sheet with rounded borders --- lib/stopper.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/stopper.dart b/lib/stopper.dart index cfffb26..d54006b 100644 --- a/lib/stopper.dart +++ b/lib/stopper.dart @@ -248,8 +248,8 @@ PersistentBottomSheetController showStopper( return cont; } -/// Shows the Stopper bottom sheet. -/// Returns a [PersistentBottomSheetController] that can be used +/// Shows the Stopper modal bottom sheet. +/// Returns a [Future] that can be used Future showModalStopper( { /// The key of the [Stopper] widget From 735c42c9c45103acb6a66bf0266dd4c018c7e741 Mon Sep 17 00:00:00 2001 From: savy91 Date: Thu, 26 Sep 2019 16:39:13 +0200 Subject: [PATCH 3/3] Set background color to theme background color --- lib/stopper.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/stopper.dart b/lib/stopper.dart index d54006b..f90d68c 100644 --- a/lib/stopper.dart +++ b/lib/stopper.dart @@ -270,10 +270,12 @@ Future showModalStopper( /// The desidered shape ShapeBorder shape = null, /// Required for modal bottomSheet - bool isScrollController = true + bool isScrollController = true, }) { Future cont; + cont = showModalBottomSheet( + backgroundColor: Theme.of(context).backgroundColor, shape: shape, isScrollControlled: true, context: context,