Skip to content

Commit 9651e41

Browse files
chrisbobbegnprice
authored andcommitted
action_sheet [nfc]: Give action-sheet scrolling code more breathing room
1 parent 7d985ea commit 9651e41

File tree

1 file changed

+43
-35
lines changed

1 file changed

+43
-35
lines changed

lib/widgets/action_sheet.dart

Lines changed: 43 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,46 @@ void _showActionSheet(
6161
isScrollControlled: true,
6262
builder: (BuildContext _) {
6363
final designVariables = DesignVariables.of(pageContext);
64+
65+
Widget? effectiveHeader;
66+
if (header != null) {
67+
effectiveHeader = Flexible(
68+
// TODO(upstream) Enforce a flex ratio (e.g. 1:3)
69+
// only when the header height plus the buttons' height
70+
// exceeds available space. Otherwise let one or the other
71+
// grow to fill available space even if it breaks the ratio.
72+
// Needs support for separate properties like `flex-grow`
73+
// and `flex-shrink`.
74+
flex: 1,
75+
child: InsetShadowBox(
76+
top: 8, bottom: 8,
77+
color: designVariables.bgContextMenu,
78+
child: SingleChildScrollView(
79+
padding: EdgeInsets.symmetric(vertical: 8),
80+
child: header)));
81+
}
82+
83+
final body = Flexible(
84+
flex: 3,
85+
child: Padding(
86+
padding: const EdgeInsets.fromLTRB(16, 0, 16, 0),
87+
child: Column(
88+
crossAxisAlignment: CrossAxisAlignment.stretch,
89+
mainAxisSize: MainAxisSize.min,
90+
children: [
91+
Flexible(child: InsetShadowBox(
92+
top: 8, bottom: 8,
93+
color: designVariables.bgContextMenu,
94+
child: SingleChildScrollView(
95+
padding: const EdgeInsets.symmetric(vertical: 8),
96+
child: Column(
97+
mainAxisSize: MainAxisSize.min,
98+
spacing: 8,
99+
children: buttonSections.map((buttons) =>
100+
MenuButtonsShape(buttons: buttons)).toList())))),
101+
const BottomSheetDismissButton(style: BottomSheetDismissButtonStyle.cancel),
102+
])));
103+
64104
return PerAccountStoreWidget(
65105
accountId: accountId,
66106
child: Semantics(
@@ -70,43 +110,11 @@ void _showActionSheet(
70110
child: Column(
71111
mainAxisSize: MainAxisSize.min,
72112
children: [
73-
if (header != null)
74-
Flexible(
75-
// TODO(upstream) Enforce a flex ratio (e.g. 1:3)
76-
// only when the header height plus the buttons' height
77-
// exceeds available space. Otherwise let one or the other
78-
// grow to fill available space even if it breaks the ratio.
79-
// Needs support for separate properties like `flex-grow`
80-
// and `flex-shrink`.
81-
flex: 1,
82-
child: InsetShadowBox(
83-
top: 8, bottom: 8,
84-
color: designVariables.bgContextMenu,
85-
child: SingleChildScrollView(
86-
padding: EdgeInsets.symmetric(vertical: 8),
87-
child: header)))
113+
if (effectiveHeader != null)
114+
effectiveHeader
88115
else
89116
SizedBox(height: 8),
90-
Flexible(
91-
flex: 3,
92-
child: Padding(
93-
padding: const EdgeInsets.fromLTRB(16, 0, 16, 0),
94-
child: Column(
95-
crossAxisAlignment: CrossAxisAlignment.stretch,
96-
mainAxisSize: MainAxisSize.min,
97-
children: [
98-
Flexible(child: InsetShadowBox(
99-
top: 8, bottom: 8,
100-
color: designVariables.bgContextMenu,
101-
child: SingleChildScrollView(
102-
padding: const EdgeInsets.symmetric(vertical: 8),
103-
child: Column(
104-
mainAxisSize: MainAxisSize.min,
105-
spacing: 8,
106-
children: buttonSections.map((buttons) =>
107-
MenuButtonsShape(buttons: buttons)).toList())))),
108-
const BottomSheetDismissButton(style: BottomSheetDismissButtonStyle.cancel),
109-
]))),
117+
body,
110118
]))));
111119
});
112120
}

0 commit comments

Comments
 (0)