Skip to content

Commit c5b5a24

Browse files
committed
compose [nfc]: Move _ErrorBanner to where it is first used
This could potentially be the home to other top bar banners (e.g. message edit) once we support them. Signed-off-by: Zixuan James Li <[email protected]>
1 parent 175cae0 commit c5b5a24

File tree

1 file changed

+39
-39
lines changed

1 file changed

+39
-39
lines changed

lib/widgets/compose_box.dart

+39-39
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,45 @@ class ComposeContentController extends ComposeController<ContentValidationError>
275275
}
276276
}
277277

278+
class _ErrorBanner extends StatelessWidget {
279+
const _ErrorBanner({required this.label, this.action});
280+
281+
final String label;
282+
final Widget? action;
283+
284+
@override
285+
Widget build(BuildContext context) {
286+
final designVariables = DesignVariables.of(context);
287+
final labelTextStyle = TextStyle(
288+
fontSize: 17,
289+
height: 22 / 17,
290+
color: designVariables.btnLabelAttMediumDanger,
291+
).merge(weightVariableTextStyle(context,
292+
// The Figma uses a weight of SemiBold,
293+
// which is a variable equivalent to this value.
294+
wght: 600));
295+
296+
final padding = (action == null)
297+
// Ensure that the text is centered when it is the only element.
298+
? const EdgeInsets.symmetric(horizontal: 16, vertical: 9)
299+
: const EdgeInsetsDirectional.fromSTEB(16, 9, 8, 9);
300+
301+
return Container(
302+
constraints: const BoxConstraints(minHeight: 40),
303+
decoration: BoxDecoration(color: designVariables.bannerBgIntDanger),
304+
child: Row(
305+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
306+
crossAxisAlignment: CrossAxisAlignment.start,
307+
children: [
308+
Expanded(
309+
child: Padding(
310+
padding: padding,
311+
child: Text(label, style: labelTextStyle))),
312+
if (action != null) action!,
313+
]));
314+
}
315+
}
316+
278317
class _TopBar extends StatelessWidget {
279318
const _TopBar({required this.showProgressIndicator, required this.sendMessageError});
280319

@@ -1301,45 +1340,6 @@ class _StreamComposeBoxState extends State<_StreamComposeBox> implements Compose
13011340
}
13021341
}
13031342

1304-
class _ErrorBanner extends StatelessWidget {
1305-
const _ErrorBanner({required this.label, this.action});
1306-
1307-
final String label;
1308-
final Widget? action;
1309-
1310-
@override
1311-
Widget build(BuildContext context) {
1312-
final designVariables = DesignVariables.of(context);
1313-
final labelTextStyle = TextStyle(
1314-
fontSize: 17,
1315-
height: 22 / 17,
1316-
color: designVariables.btnLabelAttMediumDanger,
1317-
).merge(weightVariableTextStyle(context,
1318-
// The Figma uses a weight of SemiBold,
1319-
// which is a variable equivalent to this value.
1320-
wght: 600));
1321-
1322-
final padding = (action == null)
1323-
// Ensure that the text is centered when it is the only element.
1324-
? const EdgeInsets.symmetric(horizontal: 16, vertical: 9)
1325-
: const EdgeInsetsDirectional.fromSTEB(16, 9, 8, 9);
1326-
1327-
return Container(
1328-
constraints: const BoxConstraints(minHeight: 40),
1329-
decoration: BoxDecoration(color: designVariables.bannerBgIntDanger),
1330-
child: Row(
1331-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
1332-
crossAxisAlignment: CrossAxisAlignment.start,
1333-
children: [
1334-
Expanded(
1335-
child: Padding(
1336-
padding: padding,
1337-
child: Text(label, style: labelTextStyle))),
1338-
if (action != null) action!,
1339-
]));
1340-
}
1341-
}
1342-
13431343
class _FixedDestinationComposeBox extends StatefulWidget {
13441344
const _FixedDestinationComposeBox({super.key, required this.narrow});
13451345

0 commit comments

Comments
 (0)