Skip to content

Commit cf19d68

Browse files
PIG208gnprice
authored andcommitted
action_sheet [nfc]: Extract _showActionSheet
Signed-off-by: Zixuan James Li <[email protected]>
1 parent f580b68 commit cf19d68

File tree

1 file changed

+37
-30
lines changed

1 file changed

+37
-30
lines changed

lib/widgets/action_sheet.dart

+37-30
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,42 @@ import 'store.dart';
2323
import 'text.dart';
2424
import 'theme.dart';
2525

26+
void _showActionSheet(
27+
BuildContext context, {
28+
required List<ActionSheetMenuItemButton> optionButtons,
29+
}) {
30+
showModalBottomSheet<void>(
31+
context: context,
32+
// Clip.hardEdge looks bad; Clip.antiAliasWithSaveLayer looks pixel-perfect
33+
// on my iPhone 13 Pro but is marked as "much slower":
34+
// https://api.flutter.dev/flutter/dart-ui/Clip.html
35+
clipBehavior: Clip.antiAlias,
36+
useSafeArea: true,
37+
isScrollControlled: true,
38+
builder: (BuildContext _) {
39+
return SafeArea(
40+
minimum: const EdgeInsets.only(bottom: 16),
41+
child: Padding(
42+
padding: const EdgeInsets.fromLTRB(16, 0, 16, 0),
43+
child: Column(
44+
crossAxisAlignment: CrossAxisAlignment.stretch,
45+
mainAxisSize: MainAxisSize.min,
46+
children: [
47+
// TODO(#217): show message text
48+
Flexible(child: InsetShadowBox(
49+
top: 8, bottom: 8,
50+
color: DesignVariables.of(context).bgContextMenu,
51+
child: SingleChildScrollView(
52+
padding: const EdgeInsets.only(top: 16, bottom: 8),
53+
child: ClipRRect(
54+
borderRadius: BorderRadius.circular(7),
55+
child: Column(spacing: 1,
56+
children: optionButtons))))),
57+
const ActionSheetCancelButton(),
58+
])));
59+
});
60+
}
61+
2662
abstract class ActionSheetMenuItemButton extends StatelessWidget {
2763
const ActionSheetMenuItemButton({super.key, required this.pageContext});
2864

@@ -145,36 +181,7 @@ void showMessageActionSheet({required BuildContext context, required Message mes
145181
ShareButton(message: message, pageContext: context),
146182
];
147183

148-
showModalBottomSheet<void>(
149-
context: context,
150-
// Clip.hardEdge looks bad; Clip.antiAliasWithSaveLayer looks pixel-perfect
151-
// on my iPhone 13 Pro but is marked as "much slower":
152-
// https://api.flutter.dev/flutter/dart-ui/Clip.html
153-
clipBehavior: Clip.antiAlias,
154-
useSafeArea: true,
155-
isScrollControlled: true,
156-
builder: (BuildContext _) {
157-
return SafeArea(
158-
minimum: const EdgeInsets.only(bottom: 16),
159-
child: Padding(
160-
padding: const EdgeInsets.fromLTRB(16, 0, 16, 0),
161-
child: Column(
162-
crossAxisAlignment: CrossAxisAlignment.stretch,
163-
mainAxisSize: MainAxisSize.min,
164-
children: [
165-
// TODO(#217): show message text
166-
Flexible(child: InsetShadowBox(
167-
top: 8, bottom: 8,
168-
color: DesignVariables.of(context).bgContextMenu,
169-
child: SingleChildScrollView(
170-
padding: const EdgeInsets.only(top: 16, bottom: 8),
171-
child: ClipRRect(
172-
borderRadius: BorderRadius.circular(7),
173-
child: Column(spacing: 1,
174-
children: optionButtons))))),
175-
const ActionSheetCancelButton(),
176-
])));
177-
});
184+
_showActionSheet(context, optionButtons: optionButtons);
178185
}
179186

180187
abstract class MessageActionSheetMenuItemButton extends ActionSheetMenuItemButton {

0 commit comments

Comments
 (0)