Skip to content

Commit effada0

Browse files
chrisbobbegnprice
authored andcommitted
compose [nfc]: Move a TODO from _Banner to its subclass _ErrorBanner
And add some features to _Banner to support that TODO, and a Figma link.
1 parent 6dcd440 commit effada0

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

lib/widgets/compose_box.dart

+27-3
Original file line numberDiff line numberDiff line change
@@ -1384,6 +1384,18 @@ abstract class _Banner extends StatelessWidget {
13841384
Color getLabelColor(DesignVariables designVariables);
13851385
Color getBackgroundColor(DesignVariables designVariables);
13861386

1387+
/// A trailing element, with no outer padding for spacing/positioning.
1388+
///
1389+
/// To control the element's distance from the end edge, override [padEnd].
1390+
Widget? buildTrailing(BuildContext context);
1391+
1392+
/// Whether to add 8px trailing padding.
1393+
///
1394+
/// Subclasses can use `false` when the [buildTrailing] element
1395+
/// is meant to abut the edge of the screen
1396+
/// in the common case that there are no horizontal device insets.
1397+
bool get padEnd => true;
1398+
13871399
@override
13881400
Widget build(BuildContext context) {
13891401
final designVariables = DesignVariables.of(context);
@@ -1393,6 +1405,7 @@ abstract class _Banner extends StatelessWidget {
13931405
color: getLabelColor(designVariables),
13941406
).merge(weightVariableTextStyle(context, wght: 600));
13951407

1408+
final trailing = buildTrailing(context);
13961409
return DecoratedBox(
13971410
decoration: BoxDecoration(
13981411
color: getBackgroundColor(designVariables)),
@@ -1409,9 +1422,11 @@ abstract class _Banner extends StatelessWidget {
14091422
padding: const EdgeInsets.symmetric(vertical: 4),
14101423
child: Text(style: labelTextStyle,
14111424
label))),
1412-
const SizedBox(width: 8),
1413-
// TODO(#720) "x" button for the error banner goes here.
1414-
// 24px square with 8px touchable padding in all directions?
1425+
if (trailing != null) ...[
1426+
const SizedBox(width: 8),
1427+
trailing,
1428+
],
1429+
if (padEnd) const SizedBox(width: 8),
14151430
]))));
14161431
}
14171432
}
@@ -1426,6 +1441,15 @@ class _ErrorBanner extends _Banner {
14261441
@override
14271442
Color getBackgroundColor(DesignVariables designVariables) =>
14281443
designVariables.bannerBgIntDanger;
1444+
1445+
@override
1446+
Widget? buildTrailing(context) {
1447+
// TODO(#720) "x" button goes here.
1448+
// 24px square with 8px touchable padding in all directions?
1449+
// and `bool get padEnd => false`; see Figma:
1450+
// https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=4031-17029&m=dev
1451+
return null;
1452+
}
14291453
}
14301454

14311455
/// The compose box.

0 commit comments

Comments
 (0)