Skip to content

Commit 40f6fe9

Browse files
committed
action_sheet: Constrain height of group-DM pills to 4-ish lines, not 6-ish
1 parent c994317 commit 40f6fe9

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

lib/widgets/action_sheet.dart

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import 'package:collection/collection.dart';
55
import 'package:flutter/foundation.dart';
66
import 'package:flutter/material.dart';
77
import 'package:flutter/services.dart';
8+
import 'package:http/http.dart';
89
import 'package:share_plus/share_plus.dart';
910

1011
import '../api/exception.dart';
@@ -47,9 +48,11 @@ void _showActionSheet(
4748
BuildContext pageContext, {
4849
Widget? header,
4950
bool headerScrollable = true,
51+
bool shorterScrollableMaxHeight = false,
5052
required List<List<Widget>> buttonSections,
5153
}) {
5254
assert(header is! BottomSheetHeader || !header.outerVerticalPadding);
55+
assert(headerScrollable || !shorterScrollableMaxHeight);
5356

5457
// Could omit this if we need _showActionSheet outside a per-account context.
5558
final accountId = PerAccountStoreWidget.accountIdOf(pageContext);
@@ -76,12 +79,20 @@ void _showActionSheet(
7679
// Needs support for separate properties like `flex-grow`
7780
// and `flex-shrink`.
7881
flex: 1,
79-
child: InsetShadowBox(
80-
top: 8, bottom: 8,
81-
color: designVariables.bgContextMenu,
82-
child: SingleChildScrollView(
83-
padding: EdgeInsets.symmetric(vertical: 8),
84-
child: header)))
82+
child: ConstrainedBox(
83+
constraints: BoxConstraints(
84+
maxHeight: shorterScrollableMaxHeight
85+
// Chosen so we show "4-ish lines rather than 6-ish" in the
86+
// DM action sheet header with group participant pills:
87+
// https://chat.zulip.org/#narrow/channel/48-mobile/topic/abbreviated.20headings/near/2371840
88+
? 160
89+
: double.infinity),
90+
child: InsetShadowBox(
91+
top: 8, bottom: 8,
92+
color: designVariables.bgContextMenu,
93+
child: SingleChildScrollView(
94+
padding: EdgeInsets.symmetric(vertical: 8),
95+
child: header))))
8596
: Padding(
8697
padding: EdgeInsets.only(top: 16, bottom: 4),
8798
child: header);
@@ -1095,9 +1106,11 @@ void showDmActionSheet(BuildContext context, {required DmNarrow narrow}) {
10951106
ProfilePage.buildRoute(context: context, userId: userId)))).toList())
10961107
: null);
10971108

1109+
final headerScrollable = narrow.otherRecipientIds.length > 1;
10981110
_showActionSheet(pageContext,
10991111
header: header,
1100-
headerScrollable: narrow.otherRecipientIds.length > 1,
1112+
headerScrollable: headerScrollable,
1113+
shorterScrollableMaxHeight: headerScrollable,
11011114
buttonSections: buttonSections);
11021115
}
11031116

0 commit comments

Comments
 (0)