Skip to content

Commit 9051195

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 fae4af1 commit 9051195

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

lib/widgets/compose_box.dart

+36-36
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,42 @@ 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, wght: 600));
292+
293+
final padding = (action == null)
294+
// Ensure that the text is centered when it is the only element.
295+
? const EdgeInsets.symmetric(horizontal: 16, vertical: 9)
296+
: const EdgeInsetsDirectional.fromSTEB(16, 9, 8, 9);
297+
298+
return Container(
299+
constraints: const BoxConstraints(minHeight: 40),
300+
decoration: BoxDecoration(color: designVariables.bannerBgIntDanger),
301+
child: Row(
302+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
303+
crossAxisAlignment: CrossAxisAlignment.start,
304+
children: [
305+
Expanded(
306+
child: Padding(
307+
padding: padding,
308+
child: Text(label, style: labelTextStyle))),
309+
if (action != null) action!,
310+
]));
311+
}
312+
}
313+
278314
class _TopBar extends StatelessWidget {
279315
const _TopBar({required this.showProgressIndicator, required this.sendMessageError});
280316

@@ -1301,42 +1337,6 @@ class _StreamComposeBoxState extends State<_StreamComposeBox> implements Compose
13011337
}
13021338
}
13031339

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, wght: 600));
1318-
1319-
final padding = (action == null)
1320-
// Ensure that the text is centered when it is the only element.
1321-
? const EdgeInsets.symmetric(horizontal: 16, vertical: 9)
1322-
: const EdgeInsetsDirectional.fromSTEB(16, 9, 8, 9);
1323-
1324-
return Container(
1325-
constraints: const BoxConstraints(minHeight: 40),
1326-
decoration: BoxDecoration(color: designVariables.bannerBgIntDanger),
1327-
child: Row(
1328-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
1329-
crossAxisAlignment: CrossAxisAlignment.start,
1330-
children: [
1331-
Expanded(
1332-
child: Padding(
1333-
padding: padding,
1334-
child: Text(label, style: labelTextStyle))),
1335-
if (action != null) action!,
1336-
]));
1337-
}
1338-
}
1339-
13401340
class _FixedDestinationComposeBox extends StatefulWidget {
13411341
const _FixedDestinationComposeBox({super.key, required this.narrow});
13421342

0 commit comments

Comments
 (0)