Skip to content

Commit c98acbd

Browse files
committed
compose_box: Implement topic input redesign
`Spoiler` has a similar bottom underline implementation. We could have used `UnderlineInputBorder` on `InputDecoration`, but that also comes with other input state styles (e.g.: focused, disabled, etc.). See also: - https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3954-13395 - https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3862-14350 Signed-off-by: Zixuan James Li <[email protected]>
1 parent a34d05a commit c98acbd

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

lib/widgets/compose_box.dart

+25-8
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import 'autocomplete.dart';
1717
import 'dialog.dart';
1818
import 'icons.dart';
1919
import 'store.dart';
20+
import 'text.dart';
2021
import 'theme.dart';
2122

2223
const double _inputVerticalPadding = 8;
@@ -391,20 +392,36 @@ class _TopicInput extends StatelessWidget {
391392
@override
392393
Widget build(BuildContext context) {
393394
final zulipLocalizations = ZulipLocalizations.of(context);
394-
ColorScheme colorScheme = Theme.of(context).colorScheme;
395+
final designVariables = DesignVariables.of(context);
396+
const textFieldHeight = 42;
397+
TextStyle topicTextStyle = TextStyle(
398+
fontSize: 22,
399+
height: textFieldHeight / 22,
400+
color: designVariables.textInput,
401+
).merge(weightVariableTextStyle(context, wght: 600));
395402

396403
return TopicAutocomplete(
397404
streamId: streamId,
398405
controller: controller,
399406
focusNode: focusNode,
400407
contentFocusNode: contentFocusNode,
401-
fieldViewBuilder: (context) => TextField(
402-
controller: controller,
403-
focusNode: focusNode,
404-
textInputAction: TextInputAction.next,
405-
style: TextStyle(color: colorScheme.onSurface),
406-
decoration: InputDecoration(hintText: zulipLocalizations.composeBoxTopicHintText),
407-
));
408+
fieldViewBuilder: (context) => Stack(
409+
children: [
410+
TextField(
411+
controller: controller,
412+
focusNode: focusNode,
413+
textInputAction: TextInputAction.next,
414+
style: topicTextStyle,
415+
decoration: InputDecoration(
416+
hintText: zulipLocalizations.composeBoxTopicHintText,
417+
hintStyle: topicTextStyle.copyWith(
418+
color: designVariables.textInput.withValues(alpha: 0.5)))),
419+
Positioned(bottom: 0, left: 0, right: 0,
420+
child: Container(height: 1, decoration: BoxDecoration(
421+
border: Border(
422+
bottom: BorderSide(width: 1,
423+
color: designVariables.foreground.withValues(alpha: 0.2)))))),
424+
]));
408425
}
409426
}
410427

lib/widgets/theme.dart

+7
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
117117
labelEdited: const HSLColor.fromAHSL(0.35, 0, 0, 0).toColor(),
118118
labelMenuButton: const Color(0xff222222),
119119
mainBackground: const Color(0xfff0f0f0),
120+
textInput: const Color(0xff000000),
120121
title: const Color(0xff1a1a1a),
121122
channelColorSwatches: ChannelColorSwatches.light,
122123
atMentionMarker: const HSLColor.fromAHSL(0.5, 0, 0, 0.2).toColor(),
@@ -148,6 +149,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
148149
labelEdited: const HSLColor.fromAHSL(0.35, 0, 0, 1).toColor(),
149150
labelMenuButton: const Color(0xffffffff).withValues(alpha: 0.85),
150151
mainBackground: const Color(0xff1d1d1d),
152+
textInput: const Color(0xffffffff).withValues(alpha: 0.9),
151153
title: const Color(0xffffffff),
152154
channelColorSwatches: ChannelColorSwatches.dark,
153155
// TODO(design-dark) need proper dark-theme color (this is ad hoc)
@@ -185,6 +187,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
185187
required this.labelEdited,
186188
required this.labelMenuButton,
187189
required this.mainBackground,
190+
required this.textInput,
188191
required this.title,
189192
required this.channelColorSwatches,
190193
required this.atMentionMarker,
@@ -224,6 +227,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
224227
final Color labelEdited;
225228
final Color labelMenuButton;
226229
final Color mainBackground;
230+
final Color textInput;
227231
final Color title;
228232

229233
// Not exactly from the Figma design, but from Vlad anyway.
@@ -258,6 +262,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
258262
Color? labelEdited,
259263
Color? labelMenuButton,
260264
Color? mainBackground,
265+
Color? textInput,
261266
Color? title,
262267
ChannelColorSwatches? channelColorSwatches,
263268
Color? atMentionMarker,
@@ -287,6 +292,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
287292
labelEdited: labelEdited ?? this.labelEdited,
288293
labelMenuButton: labelMenuButton ?? this.labelMenuButton,
289294
mainBackground: mainBackground ?? this.mainBackground,
295+
textInput: textInput ?? this.textInput,
290296
title: title ?? this.title,
291297
channelColorSwatches: channelColorSwatches ?? this.channelColorSwatches,
292298
atMentionMarker: atMentionMarker ?? this.atMentionMarker,
@@ -323,6 +329,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
323329
labelEdited: Color.lerp(labelEdited, other.labelEdited, t)!,
324330
labelMenuButton: Color.lerp(labelMenuButton, other.labelMenuButton, t)!,
325331
mainBackground: Color.lerp(mainBackground, other.mainBackground, t)!,
332+
textInput: Color.lerp(textInput, other.textInput, t)!,
326333
title: Color.lerp(title, other.title, t)!,
327334
channelColorSwatches: ChannelColorSwatches.lerp(channelColorSwatches, other.channelColorSwatches, t),
328335
atMentionMarker: Color.lerp(atMentionMarker, other.atMentionMarker, t)!,

0 commit comments

Comments
 (0)