Skip to content

Commit bb5ae15

Browse files
committed
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 fff4b33 commit bb5ae15

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
@@ -1328,6 +1328,18 @@ abstract class _Banner extends StatelessWidget {
13281328
Color getLabelColor(DesignVariables designVariables);
13291329
Color getBackgroundColor(DesignVariables designVariables);
13301330

1331+
/// A trailing element, with no outer padding for spacing/positioning.
1332+
///
1333+
/// To control the element's distance from the end edge, override [padEnd].
1334+
Widget? buildTrailing(BuildContext context);
1335+
1336+
/// Whether to add 8px trailing padding.
1337+
///
1338+
/// Subclasses can use `false` when the [buildTrailing] element
1339+
/// is meant to abut the edge of the screen
1340+
/// in the common case that there are no horizontal device insets.
1341+
bool get padEnd => true;
1342+
13311343
@override
13321344
Widget build(BuildContext context) {
13331345
final designVariables = DesignVariables.of(context);
@@ -1337,6 +1349,7 @@ abstract class _Banner extends StatelessWidget {
13371349
color: getLabelColor(designVariables),
13381350
).merge(weightVariableTextStyle(context, wght: 600));
13391351

1352+
final trailing = buildTrailing(context);
13401353
return DecoratedBox(
13411354
decoration: BoxDecoration(
13421355
color: getBackgroundColor(designVariables)),
@@ -1353,9 +1366,11 @@ abstract class _Banner extends StatelessWidget {
13531366
padding: const EdgeInsets.symmetric(vertical: 4),
13541367
child: Text(style: labelTextStyle,
13551368
label))),
1356-
const SizedBox(width: 8),
1357-
// TODO(#720) "x" button for the error banner goes here.
1358-
// 24px square with 8px touchable padding in all directions?
1369+
if (trailing != null) ...[
1370+
const SizedBox(width: 8),
1371+
trailing,
1372+
],
1373+
if (padEnd) const SizedBox(width: 8),
13591374
]))));
13601375
}
13611376
}
@@ -1370,6 +1385,15 @@ class _ErrorBanner extends _Banner {
13701385
@override
13711386
Color getBackgroundColor(DesignVariables designVariables) =>
13721387
designVariables.bannerBgIntDanger;
1388+
1389+
@override
1390+
Widget? buildTrailing(context) {
1391+
// TODO(#720) "x" button goes here.
1392+
// 24px square with 8px touchable padding in all directions?
1393+
// and `bool get padEnd => false`; see Figma:
1394+
// https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=4031-17029&m=dev
1395+
return null;
1396+
}
13731397
}
13741398

13751399
/// The compose box.

0 commit comments

Comments
 (0)