Skip to content

Commit a24fa3e

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 298bddf commit a24fa3e

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;
@@ -394,20 +395,36 @@ class _TopicInput extends StatelessWidget {
394395
@override
395396
Widget build(BuildContext context) {
396397
final zulipLocalizations = ZulipLocalizations.of(context);
397-
ColorScheme colorScheme = Theme.of(context).colorScheme;
398+
final designVariables = DesignVariables.of(context);
399+
const textFieldHeight = 42;
400+
TextStyle topicTextStyle = TextStyle(
401+
fontSize: 22,
402+
height: textFieldHeight / 22,
403+
color: designVariables.textInput,
404+
).merge(weightVariableTextStyle(context, wght: 600));
398405

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

lib/widgets/theme.dart

+7
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
117117
mainBackground: const Color(0xfff0f0f0),
118118
title: const Color(0xff1a1a1a),
119119
bgComposeBox: const Color(0xffffffff),
120+
textInput: const Color(0xff000000),
120121
foreground: const Color(0xff000000),
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
mainBackground: const Color(0xff1d1d1d),
149150
title: const Color(0xffffffff),
150151
bgComposeBox: const Color(0xff0f0f0f),
152+
textInput: const Color(0xffffffff).withValues(alpha: 0.9),
151153
foreground: 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.mainBackground,
186188
required this.title,
187189
required this.bgComposeBox,
190+
required this.textInput,
188191
required this.foreground,
189192
required this.channelColorSwatches,
190193
required this.atMentionMarker,
@@ -224,6 +227,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
224227
final Color mainBackground;
225228
final Color title;
226229
final Color bgComposeBox;
230+
final Color textInput;
227231
final Color foreground;
228232

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

0 commit comments

Comments
 (0)