@@ -59,9 +59,32 @@ class ShowBottomModalAction extends EnsembleAction {
5959 Color ? getBackgroundColor (scopeManager) =>
6060 Utils .getColor (eval (payload["styles" ]? ['backgroundColor' ], scopeManager));
6161
62+ bool showDragHandle (scopeManager) =>
63+ Utils .getBool (eval (payload["styles" ]? ["showDragHandle" ], scopeManager),
64+ fallback: true );
65+
66+ Color ? dragHandleColor (scopeManager) =>
67+ Utils .getColor (eval (payload["styles" ]? ["dragHandleColor" ], scopeManager));
68+
6269 bool ? isScrollable (scopeManager) =>
6370 Utils .optionalBool (eval (payload["scrollable" ], scopeManager));
6471
72+ // scroll options
73+ double ? _initialViewport (scopeManager) => Utils .optionalDouble (
74+ eval (payload["scrollOptions" ]? ["initialViewport" ], scopeManager),
75+ min: 0 ,
76+ max: 1 );
77+
78+ double ? _minViewport (scopeManager) => Utils .optionalDouble (
79+ eval (payload["scrollOptions" ]? ["minViewport" ], scopeManager),
80+ min: 0 ,
81+ max: 1 );
82+
83+ double ? _maxViewport (scopeManager) => Utils .optionalDouble (
84+ eval (payload["scrollOptions" ]? ["maxViewport" ], scopeManager),
85+ min: 0 ,
86+ max: 1 );
87+
6588 @override
6689 Future <dynamic > execute (BuildContext context, ScopeManager scopeManager) {
6790 if (body != null ) {
@@ -70,10 +93,10 @@ class ShowBottomModalAction extends EnsembleAction {
7093 // disable the default bottom sheet styling since we use our own
7194 backgroundColor: Colors .transparent,
7295 elevation: 0 ,
96+ showDragHandle: false ,
7397
7498 barrierColor: getBarrierColor (scopeManager),
7599 isScrollControlled: true ,
76- showDragHandle: true ,
77100 enableDrag: true ,
78101 // padding to account for the keyboard when we have input widgets inside the modal
79102 builder: (modalContext) => Padding (
@@ -102,8 +125,25 @@ class ShowBottomModalAction extends EnsembleAction {
102125 Widget getBodyWidget (ScopeManager scopeManager, BuildContext context) {
103126 var widget = scopeManager.buildWidgetFromDefinition (body);
104127 if (isScrollable (scopeManager) == true ) {
128+ // fix the viewport numbers if used incorrectly
129+ double minViewport = _minViewport (scopeManager) ?? 0.25 ;
130+ double maxViewport = _maxViewport (scopeManager) ?? 1 ;
131+ if (minViewport > maxViewport) {
132+ // reset
133+ minViewport = 0.25 ;
134+ maxViewport = 1 ;
135+ }
136+ double initialViewport = _initialViewport (scopeManager) ?? 0.5 ;
137+ if (initialViewport < minViewport || initialViewport > maxViewport) {
138+ // to middle
139+ initialViewport = (minViewport + maxViewport) / 2.0 ;
140+ }
141+
105142 return DraggableScrollableSheet (
106143 expand: false ,
144+ minChildSize: minViewport,
145+ maxChildSize: maxViewport,
146+ initialChildSize: initialViewport,
107147 builder: (context, scrollController) =>
108148 buildRootContainer (scopeManager, context,
109149 child: SingleChildScrollView (
@@ -117,7 +157,7 @@ class ShowBottomModalAction extends EnsembleAction {
117157 // This is the root container where all the root styling happen
118158 Widget buildRootContainer (ScopeManager scopeManager, BuildContext context,
119159 {required Widget child}) {
120- return Container (
160+ Widget rootWidget = Container (
121161 margin: margin (scopeManager),
122162 padding: padding (scopeManager),
123163 decoration: BoxDecoration (
@@ -128,8 +168,28 @@ class ShowBottomModalAction extends EnsembleAction {
128168 topLeft: defaultTopBorderRadius,
129169 topRight: defaultTopBorderRadius)),
130170 clipBehavior: Clip .antiAlias,
131- width: double .infinity, // stretch width 100%
171+ width: double .infinity,
172+ // stretch width 100%
132173 child: useSafeArea (scopeManager) ? SafeArea (child: child) : child);
174+ if (showDragHandle (scopeManager)) {
175+ rootWidget = Stack (
176+ alignment: Alignment .topCenter,
177+ children: [rootWidget, _buildDragHandle (scopeManager)],
178+ );
179+ }
180+ return rootWidget;
181+ }
182+
183+ Widget _buildDragHandle (ScopeManager scopeManager) {
184+ return Container (
185+ margin: const EdgeInsets .only (top: 10 ),
186+ width: 32 ,
187+ height: 3 ,
188+ decoration: BoxDecoration (
189+ color: dragHandleColor (scopeManager) ?? Colors .grey[500 ],
190+ borderRadius: BorderRadius .circular (12 ),
191+ ),
192+ );
133193 }
134194}
135195
0 commit comments