diff --git a/lib/widgets/compose_box.dart b/lib/widgets/compose_box.dart index 1294fc787f..1c62bc237b 100644 --- a/lib/widgets/compose_box.dart +++ b/lib/widgets/compose_box.dart @@ -844,6 +844,28 @@ class _SendButtonState extends State<_SendButton> { } } +class _ComposeBoxContainer extends StatelessWidget { + const _ComposeBoxContainer({required this.child}); + + final Widget child; + + @override + Widget build(BuildContext context) { + ColorScheme colorScheme = Theme.of(context).colorScheme; + + // TODO(design): Maybe put a max width on the compose box, like we do on + // the message list itself + return SizedBox(width: double.infinity, + child: Material( + color: colorScheme.surfaceContainerHighest, + child: SafeArea( + minimum: const EdgeInsets.fromLTRB(8, 0, 8, 8), + child: Padding( + padding: const EdgeInsets.only(top: 8.0), + child: child)))); + } +} + class _ComposeBoxLayout extends StatelessWidget { const _ComposeBoxLayout({ required this.topicInput, @@ -851,13 +873,11 @@ class _ComposeBoxLayout extends StatelessWidget { required this.sendButton, required this.contentController, required this.contentFocusNode, - this.blockingErrorBanner, }); final Widget? topicInput; final Widget contentInput; final Widget sendButton; - final Widget? blockingErrorBanner; final ComposeContentController contentController; final FocusNode contentFocusNode; @@ -880,36 +900,30 @@ class _ComposeBoxLayout extends StatelessWidget { ), ); - return Material( - color: colorScheme.surfaceContainerHighest, - child: SafeArea( - minimum: const EdgeInsets.fromLTRB(8, 0, 8, 8), - child: Padding( - padding: const EdgeInsets.only(top: 8.0), - child: blockingErrorBanner != null - ? SizedBox(width: double.infinity, child: blockingErrorBanner) - : Column(children: [ - Row(crossAxisAlignment: CrossAxisAlignment.end, children: [ - Expanded( - child: Theme( - data: inputThemeData, - child: Column(children: [ - if (topicInput != null) topicInput!, - if (topicInput != null) const SizedBox(height: 8), - contentInput, - ]))), - const SizedBox(width: 8), - sendButton, - ]), - Theme( - data: themeData.copyWith( - iconTheme: themeData.iconTheme.copyWith(color: colorScheme.onSurfaceVariant)), - child: Row(children: [ - _AttachFileButton(contentController: contentController, contentFocusNode: contentFocusNode), - _AttachMediaButton(contentController: contentController, contentFocusNode: contentFocusNode), - _AttachFromCameraButton(contentController: contentController, contentFocusNode: contentFocusNode), - ])), - ])))); } + return _ComposeBoxContainer( + child: Column(children: [ + Row(crossAxisAlignment: CrossAxisAlignment.end, children: [ + Expanded( + child: Theme( + data: inputThemeData, + child: Column(children: [ + if (topicInput != null) topicInput!, + if (topicInput != null) const SizedBox(height: 8), + contentInput, + ]))), + const SizedBox(width: 8), + sendButton, + ]), + Theme( + data: themeData.copyWith( + iconTheme: themeData.iconTheme.copyWith(color: colorScheme.onSurfaceVariant)), + child: Row(children: [ + _AttachFileButton(contentController: contentController, contentFocusNode: contentFocusNode), + _AttachMediaButton(contentController: contentController, contentFocusNode: contentFocusNode), + _AttachFromCameraButton(contentController: contentController, contentFocusNode: contentFocusNode), + ])), + ])); + } } abstract class ComposeBoxController extends State { @@ -1039,6 +1053,11 @@ class _FixedDestinationComposeBoxState extends State<_FixedDestinationComposeBox @override Widget build(BuildContext context) { + final errorBanner = _errorBanner(context); + if (errorBanner != null) { + return _ComposeBoxContainer(child: errorBanner); + } + return _ComposeBoxLayout( contentController: _contentController, contentFocusNode: _contentFocusNode, @@ -1052,8 +1071,7 @@ class _FixedDestinationComposeBoxState extends State<_FixedDestinationComposeBox topicController: null, contentController: _contentController, getDestination: () => widget.narrow.destination, - ), - blockingErrorBanner: _errorBanner(context)); + )); } }