@@ -14,13 +14,15 @@ import '../model/compose.dart';
14
14
import '../model/narrow.dart' ;
15
15
import '../model/store.dart' ;
16
16
import 'autocomplete.dart' ;
17
+ import 'color.dart' ;
17
18
import 'dialog.dart' ;
18
19
import 'icons.dart' ;
20
+ import 'inset_shadow.dart' ;
19
21
import 'store.dart' ;
22
+ import 'text.dart' ;
20
23
import 'theme.dart' ;
21
24
22
- const double _inputVerticalPadding = 8 ;
23
- const double _sendButtonSize = 36 ;
25
+ const double _composeButtonSize = 44 ;
24
26
25
27
/// A [TextEditingController] for use in the compose box.
26
28
///
@@ -364,34 +366,76 @@ class _ContentInputState extends State<_ContentInput> with WidgetsBindingObserve
364
366
}
365
367
}
366
368
369
+ static double maxHeight (BuildContext context) {
370
+ final clampingTextScaler = MediaQuery .textScalerOf (context)
371
+ .clamp (maxScaleFactor: 1.5 );
372
+ final scaledLineHeight = clampingTextScaler.scale (_fontSize) * _lineHeightRatio;
373
+
374
+ // Reserve space to fully show the first 7th lines and just partially
375
+ // clip the 8th line, where the height matches the spec at
376
+ // https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3960-5147&node-type=text&m=dev
377
+ // > Maximum size of the compose box is suggested to be 178px. Which
378
+ // > has 7 fully visible lines of text
379
+ //
380
+ // The partial line hints that the content input is scrollable.
381
+ //
382
+ // Using the ambient TextScale means this works for different values of the
383
+ // system text-size setting. We clamp to a max scale factor to limit
384
+ // how tall the content input can get; that's to save room for the message
385
+ // list. The user can still scroll the input to see everything.
386
+ return _verticalPadding + 7.727 * scaledLineHeight;
387
+ }
388
+
389
+ static const _verticalPadding = 8.0 ;
390
+ static const _fontSize = 17.0 ;
391
+ static const _lineHeight = 22.0 ;
392
+ static const _lineHeightRatio = _lineHeight / _fontSize;
393
+
367
394
@override
368
395
Widget build (BuildContext context) {
369
- ColorScheme colorScheme = Theme .of (context).colorScheme;
370
-
371
- return InputDecorator (
372
- decoration: const InputDecoration (),
373
- child: ConstrainedBox (
374
- constraints: const BoxConstraints (
375
- minHeight: _sendButtonSize - 2 * _inputVerticalPadding,
376
-
377
- // TODO constrain this adaptively (i.e. not hard-coded 200)
378
- maxHeight: 200 ,
379
- ),
380
- child: ComposeAutocomplete (
381
- narrow: widget.narrow,
382
- controller: widget.controller,
383
- focusNode: widget.focusNode,
384
- fieldViewBuilder: (context) {
385
- return TextField (
396
+ final designVariables = DesignVariables .of (context);
397
+
398
+ return ComposeAutocomplete (
399
+ narrow: widget.narrow,
400
+ controller: widget.controller,
401
+ focusNode: widget.focusNode,
402
+ fieldViewBuilder: (context) => ConstrainedBox (
403
+ constraints: BoxConstraints (maxHeight: maxHeight (context)),
404
+ child: ClipRect (
405
+ child: InsetShadowBox (
406
+ top: _verticalPadding, bottom: _verticalPadding,
407
+ color: designVariables.composeBoxBg,
408
+ child: TextField (
386
409
controller: widget.controller,
387
410
focusNode: widget.focusNode,
388
- style: TextStyle (color: colorScheme.onSurface),
389
- decoration: InputDecoration .collapsed (hintText: widget.hintText),
411
+ // Let the content show through the `contentPadding` so that
412
+ // our [InsetShadowBox] can fade it smoothly there.
413
+ clipBehavior: Clip .none,
414
+ style: TextStyle (
415
+ fontSize: _fontSize,
416
+ height: _lineHeightRatio,
417
+ color: designVariables.textInput),
418
+ // From the spec at
419
+ // https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3960-5147&node-type=text&m=dev
420
+ // > Compose box has the height to fit 2 lines. This is [done] to
421
+ // > have a bigger hit area for the user to start the input. […]
422
+ minLines: 2 ,
390
423
maxLines: null ,
391
424
textCapitalization: TextCapitalization .sentences,
392
- );
393
- }),
394
- ));
425
+ decoration: InputDecoration (
426
+ // This padding ensures that the user can always scroll long
427
+ // content entirely out of the top or bottom shadow if desired.
428
+ // With this and the `minLines: 2` above, an empty content input
429
+ // gets 60px vertical distance (with no text-size scaling)
430
+ // between the top of the top shadow and the bottom of the
431
+ // bottom shadow. That's a bit more than the 54px given in the
432
+ // Figma, and we can revisit if needed, but it's tricky to get
433
+ // that 54px distance while also making the scrolling work like
434
+ // this and offering two lines of touchable area.
435
+ contentPadding: const EdgeInsets .symmetric (vertical: _verticalPadding),
436
+ hintText: widget.hintText,
437
+ hintStyle: TextStyle (
438
+ color: designVariables.textInput.withFadedAlpha (0.5 ))))))));
395
439
}
396
440
}
397
441
@@ -474,20 +518,32 @@ class _TopicInput extends StatelessWidget {
474
518
@override
475
519
Widget build (BuildContext context) {
476
520
final zulipLocalizations = ZulipLocalizations .of (context);
477
- ColorScheme colorScheme = Theme .of (context).colorScheme;
521
+ final designVariables = DesignVariables .of (context);
522
+ TextStyle topicTextStyle = TextStyle (
523
+ fontSize: 20 ,
524
+ height: 22 / 20 ,
525
+ color: designVariables.textInput.withFadedAlpha (0.9 ),
526
+ ).merge (weightVariableTextStyle (context, wght: 600 ));
478
527
479
528
return TopicAutocomplete (
480
529
streamId: streamId,
481
530
controller: controller,
482
531
focusNode: focusNode,
483
532
contentFocusNode: contentFocusNode,
484
- fieldViewBuilder: (context) => TextField (
485
- controller: controller,
486
- focusNode: focusNode,
487
- textInputAction: TextInputAction .next,
488
- style: TextStyle (color: colorScheme.onSurface),
489
- decoration: InputDecoration (hintText: zulipLocalizations.composeBoxTopicHintText),
490
- ));
533
+ fieldViewBuilder: (context) => Container (
534
+ padding: const EdgeInsets .only (top: 10 , bottom: 9 ),
535
+ decoration: BoxDecoration (border: Border (bottom: BorderSide (
536
+ width: 1 ,
537
+ color: designVariables.foreground.withFadedAlpha (0.2 )))),
538
+ child: TextField (
539
+ controller: controller,
540
+ focusNode: focusNode,
541
+ textInputAction: TextInputAction .next,
542
+ style: topicTextStyle,
543
+ decoration: InputDecoration (
544
+ hintText: zulipLocalizations.composeBoxTopicHintText,
545
+ hintStyle: topicTextStyle.copyWith (
546
+ color: designVariables.textInput.withFadedAlpha (0.5 ))))));
491
547
}
492
548
}
493
549
@@ -660,12 +716,14 @@ abstract class _AttachUploadsButton extends StatelessWidget {
660
716
661
717
@override
662
718
Widget build (BuildContext context) {
663
- ColorScheme colorScheme = Theme .of (context).colorScheme ;
719
+ final designVariables = DesignVariables .of (context);
664
720
final zulipLocalizations = ZulipLocalizations .of (context);
665
- return IconButton (
666
- icon: Icon (icon, color: colorScheme.onSurfaceVariant),
667
- tooltip: tooltip (zulipLocalizations),
668
- onPressed: () => _handlePress (context));
721
+ return SizedBox (
722
+ width: _composeButtonSize,
723
+ child: IconButton (
724
+ icon: Icon (icon, color: designVariables.foreground.withFadedAlpha (0.5 )),
725
+ tooltip: tooltip (zulipLocalizations),
726
+ onPressed: () => _handlePress (context)));
669
727
}
670
728
}
671
729
@@ -929,38 +987,22 @@ class _SendButtonState extends State<_SendButton> {
929
987
930
988
@override
931
989
Widget build (BuildContext context) {
932
- final disabled = _hasValidationErrors;
933
- final colorScheme = Theme .of (context).colorScheme;
990
+ final designVariables = DesignVariables .of (context);
934
991
final zulipLocalizations = ZulipLocalizations .of (context);
935
992
936
- // Copy FilledButton defaults (_FilledButtonDefaultsM3.backgroundColor)
937
- final backgroundColor = disabled
938
- ? colorScheme.onSurface.withValues (alpha: 0.12 )
939
- : colorScheme.primary;
993
+ final iconColor = _hasValidationErrors
994
+ ? designVariables.icon.withFadedAlpha (0.5 )
995
+ : designVariables.icon;
940
996
941
- // Copy FilledButton defaults (_FilledButtonDefaultsM3.foregroundColor)
942
- final foregroundColor = disabled
943
- ? colorScheme.onSurface.withValues (alpha: 0.38 )
944
- : colorScheme.onPrimary;
945
-
946
- return Ink (
947
- decoration: BoxDecoration (
948
- borderRadius: const BorderRadius .all (Radius .circular (8.0 )),
949
- color: backgroundColor,
950
- ),
997
+ return SizedBox (
998
+ width: _composeButtonSize,
951
999
child: IconButton (
952
1000
tooltip: zulipLocalizations.composeBoxSendTooltip,
953
- style: const ButtonStyle (
954
- // Match the height of the content input.
955
- minimumSize: WidgetStatePropertyAll (Size .square (_sendButtonSize)),
956
- // With the default of [MaterialTapTargetSize.padded], not just the
957
- // tap target but the visual button would get padded to 48px square.
958
- // It would be nice if the tap target extended invisibly out from the
959
- // button, to make a 48px square, but that's not the behavior we get.
960
- tapTargetSize: MaterialTapTargetSize .shrinkWrap,
961
- ),
962
- color: foregroundColor,
963
- icon: const Icon (ZulipIcons .send),
1001
+ icon: Icon (ZulipIcons .send,
1002
+ // We set [Icon.color] instead of [IconButton.color] because the
1003
+ // latter implicitly uses colors derived from it to override the
1004
+ // ambient [ButtonStyle.overlayColor].
1005
+ color: iconColor),
964
1006
onPressed: _send));
965
1007
}
966
1008
}
@@ -972,18 +1014,17 @@ class _ComposeBoxContainer extends StatelessWidget {
972
1014
973
1015
@override
974
1016
Widget build (BuildContext context) {
975
- ColorScheme colorScheme = Theme .of (context).colorScheme ;
1017
+ final designVariables = DesignVariables .of (context);
976
1018
977
1019
// TODO(design): Maybe put a max width on the compose box, like we do on
978
1020
// the message list itself
979
- return SizedBox (width: double .infinity,
1021
+ return Container (width: double .infinity,
1022
+ decoration: BoxDecoration (
1023
+ border: Border (top: BorderSide (color: designVariables.borderBar))),
980
1024
child: Material (
981
- color: colorScheme.surfaceContainerHighest,
982
- child: SafeArea (
983
- minimum: const EdgeInsets .fromLTRB (8 , 0 , 8 , 8 ),
984
- child: Padding (
985
- padding: const EdgeInsets .only (top: 8.0 ),
986
- child: child))));
1025
+ color: designVariables.composeBoxBg,
1026
+ child: SafeArea (minimum: const EdgeInsets .symmetric (horizontal: 8 ),
1027
+ child: child)));
987
1028
}
988
1029
}
989
1030
@@ -1004,22 +1045,14 @@ class _ComposeBoxLayout extends StatelessWidget {
1004
1045
1005
1046
@override
1006
1047
Widget build (BuildContext context) {
1007
- ThemeData themeData = Theme .of (context);
1008
- ColorScheme colorScheme = themeData.colorScheme;
1048
+ final themeData = Theme .of (context);
1009
1049
1010
1050
final inputThemeData = themeData.copyWith (
1011
- inputDecorationTheme: InputDecorationTheme (
1051
+ inputDecorationTheme: const InputDecorationTheme (
1012
1052
// Both [contentPadding] and [isDense] combine to make the layout compact.
1013
1053
isDense: true ,
1014
- contentPadding: const EdgeInsets .symmetric (
1015
- horizontal: 12.0 , vertical: _inputVerticalPadding),
1016
- border: const OutlineInputBorder (
1017
- borderRadius: BorderRadius .all (Radius .circular (4.0 )),
1018
- borderSide: BorderSide .none),
1019
- filled: true ,
1020
- fillColor: colorScheme.surface,
1021
- ),
1022
- );
1054
+ contentPadding: EdgeInsets .zero,
1055
+ border: InputBorder .none));
1023
1056
1024
1057
final composeButtons = [
1025
1058
_AttachFileButton (contentController: contentController, contentFocusNode: contentFocusNode),
@@ -1029,19 +1062,22 @@ class _ComposeBoxLayout extends StatelessWidget {
1029
1062
1030
1063
return _ComposeBoxContainer (
1031
1064
child: Column (children: [
1032
- Row (crossAxisAlignment: CrossAxisAlignment .end, children: [
1033
- Expanded (
1034
- child: Theme (
1035
- data: inputThemeData,
1036
- child: Column (children: [
1037
- if (topicInput != null ) topicInput! ,
1038
- if (topicInput != null ) const SizedBox (height: 8 ),
1039
- contentInput,
1040
- ]))),
1041
- const SizedBox (width: 8 ),
1042
- sendButton,
1043
- ]),
1044
- Row (children: composeButtons),
1065
+ Padding (
1066
+ padding: const EdgeInsets .symmetric (horizontal: 8 ),
1067
+ child: Theme (
1068
+ data: inputThemeData,
1069
+ child: Column (children: [
1070
+ if (topicInput != null ) topicInput! ,
1071
+ contentInput,
1072
+ ]))),
1073
+ SizedBox (
1074
+ height: _composeButtonSize,
1075
+ child: Row (
1076
+ mainAxisAlignment: MainAxisAlignment .spaceBetween,
1077
+ children: [
1078
+ Row (children: composeButtons),
1079
+ sendButton,
1080
+ ])),
1045
1081
]));
1046
1082
}
1047
1083
}
0 commit comments