Skip to content

Commit 79fc2c2

Browse files
committed
compose_box: Support redesigned button feedback
This disables the splash effect for all the compose buttons and the send button, and implements a rounded rectangular background that appears on hover/pressed. In the future we should migrate more buttons to use this style. See also: https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3707-41711&node-type=frame&t=sSYomsJzGCt34D8N-0 Signed-off-by: Zixuan James Li <[email protected]>
1 parent 7b30960 commit 79fc2c2

File tree

2 files changed

+39
-16
lines changed

2 files changed

+39
-16
lines changed

lib/widgets/compose_box.dart

+32-16
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,7 @@ class _ComposeBoxLayout extends StatelessWidget {
983983
@override
984984
Widget build(BuildContext context) {
985985
final themeData = Theme.of(context);
986+
final designVariables = DesignVariables.of(context);
986987

987988
final inputThemeData = themeData.copyWith(
988989
inputDecorationTheme: const InputDecorationTheme(
@@ -991,6 +992,19 @@ class _ComposeBoxLayout extends StatelessWidget {
991992
contentPadding: EdgeInsets.zero,
992993
border: InputBorder.none));
993994

995+
// TODO(#417): Disable splash effects for all buttons globally.
996+
final iconButtonThemeData = themeData.copyWith(
997+
iconButtonTheme: IconButtonThemeData(
998+
style: IconButton.styleFrom(
999+
splashFactory: NoSplash.splashFactory,
1000+
// TODO(#417): The Figma design specifies a different icon color on
1001+
// pressed, but `IconButton` currently does not have support for
1002+
// that. See also:
1003+
// https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3707-41711&node-type=frame&t=sSYomsJzGCt34D8N-0
1004+
highlightColor: designVariables.editorButtonPressedBg,
1005+
shape: const RoundedRectangleBorder(
1006+
borderRadius: BorderRadius.all(Radius.circular(4))))));
1007+
9941008
return _ComposeBoxContainer(
9951009
child: Column(children: [
9961010
Padding(
@@ -1004,22 +1018,24 @@ class _ComposeBoxLayout extends StatelessWidget {
10041018
Container(
10051019
padding: const EdgeInsets.symmetric(horizontal: 8),
10061020
height: _composeButtonsRowHeight,
1007-
child: Row(
1008-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
1009-
children: [
1010-
Row(children: [
1011-
_AttachFileButton(
1012-
contentController: contentController,
1013-
contentFocusNode: contentFocusNode),
1014-
_AttachMediaButton(
1015-
contentController: contentController,
1016-
contentFocusNode: contentFocusNode),
1017-
_AttachFromCameraButton(
1018-
contentController: contentController,
1019-
contentFocusNode: contentFocusNode),
1020-
]),
1021-
sendButton,
1022-
])),
1021+
child: Theme(
1022+
data: iconButtonThemeData,
1023+
child: Row(
1024+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
1025+
children: [
1026+
Row(children: [
1027+
_AttachFileButton(
1028+
contentController: contentController,
1029+
contentFocusNode: contentFocusNode),
1030+
_AttachMediaButton(
1031+
contentController: contentController,
1032+
contentFocusNode: contentFocusNode),
1033+
_AttachFromCameraButton(
1034+
contentController: contentController,
1035+
contentFocusNode: contentFocusNode),
1036+
]),
1037+
sendButton,
1038+
]))),
10231039
]));
10241040
}
10251041
}

lib/widgets/theme.dart

+7
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
122122
contextMenuCancelText: const Color(0xff222222),
123123
contextMenuItemBg: const Color(0xff6159e1),
124124
contextMenuItemText: const Color(0xff381da7),
125+
editorButtonPressedBg: Colors.black.withValues(alpha: 0.06),
125126
foreground: const Color(0xff000000),
126127
icon: const Color(0xff6159e1),
127128
labelCounterUnread: const Color(0xff222222),
@@ -160,6 +161,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
160161
contextMenuCancelText: const Color(0xffffffff).withValues(alpha: 0.75),
161162
contextMenuItemBg: const Color(0xff7977fe),
162163
contextMenuItemText: const Color(0xff9398fd),
164+
editorButtonPressedBg: Colors.white.withValues(alpha: 0.06),
163165
foreground: const Color(0xffffffff),
164166
icon: const Color(0xff7977fe),
165167
labelCounterUnread: const Color(0xffffffff).withValues(alpha: 0.7),
@@ -205,6 +207,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
205207
required this.contextMenuCancelText,
206208
required this.contextMenuItemBg,
207209
required this.contextMenuItemText,
210+
required this.editorButtonPressedBg,
208211
required this.foreground,
209212
required this.icon,
210213
required this.labelCounterUnread,
@@ -251,6 +254,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
251254
final Color contextMenuCancelText;
252255
final Color contextMenuItemBg;
253256
final Color contextMenuItemText;
257+
final Color editorButtonPressedBg;
254258
final Color foreground;
255259
final Color icon;
256260
final Color labelCounterUnread;
@@ -292,6 +296,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
292296
Color? contextMenuCancelText,
293297
Color? contextMenuItemBg,
294298
Color? contextMenuItemText,
299+
Color? editorButtonPressedBg,
295300
Color? foreground,
296301
Color? icon,
297302
Color? labelCounterUnread,
@@ -328,6 +333,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
328333
contextMenuCancelText: contextMenuCancelText ?? this.contextMenuCancelText,
329334
contextMenuItemBg: contextMenuItemBg ?? this.contextMenuItemBg,
330335
contextMenuItemText: contextMenuItemText ?? this.contextMenuItemBg,
336+
editorButtonPressedBg: editorButtonPressedBg ?? this.editorButtonPressedBg,
331337
foreground: foreground ?? this.foreground,
332338
icon: icon ?? this.icon,
333339
labelCounterUnread: labelCounterUnread ?? this.labelCounterUnread,
@@ -371,6 +377,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
371377
contextMenuCancelText: Color.lerp(contextMenuCancelText, other.contextMenuCancelText, t)!,
372378
contextMenuItemBg: Color.lerp(contextMenuItemBg, other.contextMenuItemBg, t)!,
373379
contextMenuItemText: Color.lerp(contextMenuItemText, other.contextMenuItemBg, t)!,
380+
editorButtonPressedBg: Color.lerp(editorButtonPressedBg, other.editorButtonPressedBg, t)!,
374381
foreground: Color.lerp(foreground, other.foreground, t)!,
375382
icon: Color.lerp(icon, other.icon, t)!,
376383
labelCounterUnread: Color.lerp(labelCounterUnread, other.labelCounterUnread, t)!,

0 commit comments

Comments
 (0)