Skip to content

Commit 8d43acf

Browse files
chrisbobbegnprice
authored andcommitted
action_sheet: Add headerScrollable param to _showActionSheet
1 parent 9651e41 commit 8d43acf

File tree

1 file changed

+24
-17
lines changed

1 file changed

+24
-17
lines changed

lib/widgets/action_sheet.dart

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,12 @@ import 'topic_list.dart';
3939
/// and an optional scrollable header.
4040
///
4141
/// [header] should not use vertical padding to position itself on the sheet.
42-
/// It will be wrapped in vertical padding,
43-
/// a scroll view, and an [InsetShadowBox] to support scrolling.
42+
/// It will be wrapped in vertical padding
43+
/// and, if [headerScrollable], a scroll view and an [InsetShadowBox].
4444
void _showActionSheet(
4545
BuildContext pageContext, {
4646
Widget? header,
47+
bool headerScrollable = true,
4748
required List<List<Widget>> buttonSections,
4849
}) {
4950
assert(header is! BottomSheetHeader || !header.outerVerticalPadding);
@@ -64,24 +65,30 @@ void _showActionSheet(
6465

6566
Widget? effectiveHeader;
6667
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)));
68+
effectiveHeader = headerScrollable
69+
? Flexible(
70+
// TODO(upstream) Enforce a flex ratio (e.g. 1:3)
71+
// only when the header height plus the buttons' height
72+
// exceeds available space. Otherwise let one or the other
73+
// grow to fill available space even if it breaks the ratio.
74+
// Needs support for separate properties like `flex-grow`
75+
// and `flex-shrink`.
76+
flex: 1,
77+
child: InsetShadowBox(
78+
top: 8, bottom: 8,
79+
color: designVariables.bgContextMenu,
80+
child: SingleChildScrollView(
81+
padding: EdgeInsets.symmetric(vertical: 8),
82+
child: header)))
83+
: Padding(
84+
padding: EdgeInsets.only(top: 16, bottom: 4),
85+
child: header);
8186
}
8287

8388
final body = Flexible(
84-
flex: 3,
89+
flex: (effectiveHeader != null && headerScrollable)
90+
? 3
91+
: 1,
8592
child: Padding(
8693
padding: const EdgeInsets.fromLTRB(16, 0, 16, 0),
8794
child: Column(

0 commit comments

Comments
 (0)