@@ -11,8 +11,8 @@ import 'package:ensemble_ts_interpreter/invokables/invokable.dart';
11
11
import 'package:flutter/material.dart' ;
12
12
13
13
/// open a Modal Bottom Sheet
14
- class ShowBottomModalAction extends EnsembleAction {
15
- ShowBottomModalAction ({
14
+ class ShowBottomSheetAction extends EnsembleAction {
15
+ ShowBottomSheetAction ({
16
16
super .initiator,
17
17
super .inputs,
18
18
required this .body,
@@ -26,13 +26,13 @@ class ShowBottomModalAction extends EnsembleAction {
26
26
final dynamic body;
27
27
final EnsembleAction ? onDismiss;
28
28
29
- factory ShowBottomModalAction .from ({Invokable ? initiator, Map ? payload}) {
29
+ factory ShowBottomSheetAction .from ({Invokable ? initiator, Map ? payload}) {
30
30
dynamic body = payload? ['body' ] ?? payload? ['widget' ];
31
31
if (payload == null || body == null ) {
32
32
throw LanguageError (
33
- "${ActionType .showBottomModal .name } requires a body widget." );
33
+ "${ActionType .showBottomSheet .name } requires a body widget." );
34
34
}
35
- return ShowBottomModalAction (
35
+ return ShowBottomSheetAction (
36
36
initiator: initiator,
37
37
inputs: Utils .getMap (payload['inputs' ]),
38
38
body: body,
@@ -104,7 +104,7 @@ class ShowBottomModalAction extends EnsembleAction {
104
104
bottom: MediaQuery .of (modalContext).viewInsets.bottom,
105
105
),
106
106
// have a bottom modal scope widget so we can close the modal
107
- child: BottomModalScopeWidget (
107
+ child: BottomSheetScopeWidget (
108
108
rootContext: modalContext,
109
109
// create a new Data Scope since the bottom modal is placed in a different context tree (directly under MaterialApp)
110
110
child: DataScopeWidget (
@@ -139,6 +139,9 @@ class ShowBottomModalAction extends EnsembleAction {
139
139
initialViewport = (minViewport + maxViewport) / 2.0 ;
140
140
}
141
141
142
+ // On platforms with a mouse (Web/desktop), there is no min/maxViewport due to platform consistency,
143
+ // so the height will be fixed to initialViewport, and content will just scroll within it.
144
+ // https://docs.flutter.dev/release/breaking-changes/default-scroll-behavior-drag
142
145
return DraggableScrollableSheet (
143
146
expand: false ,
144
147
minChildSize: minViewport,
@@ -168,8 +171,8 @@ class ShowBottomModalAction extends EnsembleAction {
168
171
topLeft: defaultTopBorderRadius,
169
172
topRight: defaultTopBorderRadius)),
170
173
clipBehavior: Clip .antiAlias,
174
+ // stretch width 100%. Note that Flutter's bottom sheet has a width constraint on Web/Desktop so it may not take 100% on wide screen
171
175
width: double .infinity,
172
- // stretch width 100%
173
176
child: useSafeArea (scopeManager) ? SafeArea (child: child) : child);
174
177
if (showDragHandle (scopeManager)) {
175
178
rootWidget = Stack (
@@ -194,43 +197,43 @@ class ShowBottomModalAction extends EnsembleAction {
194
197
}
195
198
196
199
/// Dismiss the Bottom Modal (if the context is a descendant, no-op otherwise)
197
- class DismissBottomModalAction extends EnsembleAction {
198
- DismissBottomModalAction ({this .payload});
200
+ class DismissBottomSheetAction extends EnsembleAction {
201
+ DismissBottomSheetAction ({this .payload});
199
202
200
203
Map ? payload;
201
204
202
- factory DismissBottomModalAction .from ({Map ? payload}) =>
203
- DismissBottomModalAction (payload: payload? ['payload' ]);
205
+ factory DismissBottomSheetAction .from ({Map ? payload}) =>
206
+ DismissBottomSheetAction (payload: payload? ['payload' ]);
204
207
205
208
@override
206
209
Future <dynamic > execute (BuildContext context, ScopeManager scopeManager,
207
210
{DataContext ? dataContext}) {
208
- BuildContext ? bottomModalContext =
209
- BottomModalScopeWidget .getRootContext (context);
210
- if (bottomModalContext != null ) {
211
+ BuildContext ? bottomSheetContext =
212
+ BottomSheetScopeWidget .getRootContext (context);
213
+ if (bottomSheetContext != null ) {
211
214
return Navigator .maybePop (
212
- bottomModalContext , scopeManager.dataContext.eval (payload));
215
+ bottomSheetContext , scopeManager.dataContext.eval (payload));
213
216
}
214
217
return Navigator .maybePop (context, scopeManager.dataContext.eval (payload));
215
218
}
216
219
}
217
220
218
- /// a wrapper InheritedWidget for its descendant to look up the root modal context to close it
219
- class BottomModalScopeWidget extends InheritedWidget {
220
- const BottomModalScopeWidget (
221
+ /// a wrapper InheritedWidget for its descendant to look up the Sheet's root context to close it
222
+ class BottomSheetScopeWidget extends InheritedWidget {
223
+ const BottomSheetScopeWidget (
221
224
{super .key, required super .child, required this .rootContext});
222
225
223
226
// this is the context root of the modal
224
227
final BuildContext rootContext;
225
228
226
229
@override
227
- bool updateShouldNotify (covariant BottomModalScopeWidget oldWidget) {
230
+ bool updateShouldNotify (covariant BottomSheetScopeWidget oldWidget) {
228
231
return oldWidget.rootContext != rootContext;
229
232
}
230
233
231
234
static BuildContext ? getRootContext (BuildContext context) {
232
- BottomModalScopeWidget ? wrapperWidget =
233
- context.dependOnInheritedWidgetOfExactType <BottomModalScopeWidget >();
235
+ BottomSheetScopeWidget ? wrapperWidget =
236
+ context.dependOnInheritedWidgetOfExactType <BottomSheetScopeWidget >();
234
237
return wrapperWidget? .rootContext;
235
238
}
236
239
}
0 commit comments