Skip to content

Commit 7d985ea

Browse files
chrisbobbegnprice
authored andcommitted
action_sheet: Add ActionSheetHeader.outerVerticalPadding
1 parent 3f8f832 commit 7d985ea

File tree

3 files changed

+18
-9
lines changed

3 files changed

+18
-9
lines changed

lib/widgets/action_sheet.dart

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,7 @@ void _showActionSheet(
4646
Widget? header,
4747
required List<List<Widget>> buttonSections,
4848
}) {
49-
// This assert does look absurd, but see dartdoc -- [BottomSheetHeader] adds
50-
// vertical padding to position itself on the sheet, so isn't suitable here.
51-
// When it grows a param to omit that padding, soon, it'll be usable here.
52-
// (Currently the only caller that passes `header` is the message action sheet,
53-
// and that header widget only adds internal padding, on a distinct-colored
54-
// surface, not padding for positioning.)
55-
assert(header is! BottomSheetHeader);
49+
assert(header is! BottomSheetHeader || !header.outerVerticalPadding);
5650

5751
// Could omit this if we need _showActionSheet outside a per-account context.
5852
final accountId = PerAccountStoreWidget.accountIdOf(pageContext);
@@ -128,6 +122,9 @@ typedef WidgetBuilderFromTextStyle = Widget Function(TextStyle);
128122
/// The "build" params support richer content, such as [TextWithLink],
129123
/// and the callback is passed a [TextStyle] which is the base style.
130124
///
125+
/// To add outer vertical padding to position the header on the sheet,
126+
/// pass true for [outerVerticalPadding].
127+
///
131128
/// Figma; just message no title:
132129
/// https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3481-26993&m=dev
133130
///
@@ -145,6 +142,7 @@ class BottomSheetHeader extends StatelessWidget {
145142
this.buildTitle,
146143
this.message,
147144
this.buildMessage,
145+
this.outerVerticalPadding = false,
148146
}) : assert(message == null || buildMessage == null),
149147
assert(title == null || buildTitle == null),
150148
assert((message != null || buildMessage != null)
@@ -154,6 +152,7 @@ class BottomSheetHeader extends StatelessWidget {
154152
final Widget Function(TextStyle)? buildTitle;
155153
final String? message;
156154
final Widget Function(TextStyle)? buildMessage;
155+
final bool outerVerticalPadding;
157156

158157
@override
159158
Widget build(BuildContext context) {
@@ -182,12 +181,20 @@ class BottomSheetHeader extends StatelessWidget {
182181
_ => null,
183182
};
184183

185-
return Padding(
186-
padding: EdgeInsets.fromLTRB(16, 16, 16, 4),
184+
Widget result = Padding(
185+
padding: EdgeInsets.symmetric(horizontal: 16),
187186
child: Column(
188187
crossAxisAlignment: CrossAxisAlignment.stretch,
189188
spacing: 8,
190189
children: [?effectiveTitle, ?effectiveMessage]));
190+
191+
if (outerVerticalPadding) {
192+
result = Padding(
193+
padding: EdgeInsets.only(top: 16, bottom: 4),
194+
child: result);
195+
}
196+
197+
return result;
191198
}
192199
}
193200

lib/widgets/emoji_reaction.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -805,6 +805,7 @@ class ViewReactionsHeader extends StatelessWidget {
805805

806806
if (reactions == null || reactions.aggregated.isEmpty) {
807807
return BottomSheetHeader(
808+
outerVerticalPadding: true,
808809
message: zulipLocalizations.seeWhoReactedSheetNoReactions);
809810
}
810811

lib/widgets/read_receipts.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ class _ReadReceiptsHeader extends StatelessWidget {
129129
}
130130

131131
return BottomSheetHeader(
132+
outerVerticalPadding: true,
132133
title: zulipLocalizations.actionSheetReadReceipts,
133134
buildMessage: headerMessageBuilder);
134135
}

0 commit comments

Comments
 (0)