Skip to content

Commit ea7d8b3

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 Fixes: zulip#915 Signed-off-by: Zixuan James Li <[email protected]>
1 parent 1f49f51 commit ea7d8b3

File tree

2 files changed

+38
-16
lines changed

2 files changed

+38
-16
lines changed

lib/widgets/compose_box.dart

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,7 @@ class _ComposeBoxLayout extends StatelessWidget {
10471047
@override
10481048
Widget build(BuildContext context) {
10491049
final themeData = Theme.of(context);
1050+
final designVariables = DesignVariables.of(context);
10501051

10511052
final inputThemeData = themeData.copyWith(
10521053
inputDecorationTheme: const InputDecorationTheme(
@@ -1055,6 +1056,18 @@ class _ComposeBoxLayout extends StatelessWidget {
10551056
contentPadding: EdgeInsets.zero,
10561057
border: InputBorder.none));
10571058

1059+
// TODO(#417): Disable splash effects for all buttons globally.
1060+
final iconButtonThemeData = IconButtonThemeData(
1061+
style: IconButton.styleFrom(
1062+
splashFactory: NoSplash.splashFactory,
1063+
// TODO(#417): The Figma design specifies a different icon color on
1064+
// pressed, but `IconButton` currently does not have support for
1065+
// that. See also:
1066+
// https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3707-41711&node-type=frame&t=sSYomsJzGCt34D8N-0
1067+
highlightColor: designVariables.editorButtonPressedBg,
1068+
shape: const RoundedRectangleBorder(
1069+
borderRadius: BorderRadius.all(Radius.circular(4)))));
1070+
10581071
return _ComposeBoxContainer(
10591072
child: Column(children: [
10601073
SafeArea(
@@ -1069,22 +1082,24 @@ class _ComposeBoxLayout extends StatelessWidget {
10691082
minimum: const EdgeInsets.symmetric(horizontal: 8),
10701083
child: SizedBox(
10711084
height: _composeButtonsRowHeight,
1072-
child: Row(
1073-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
1074-
children: [
1075-
Row(children: [
1076-
_AttachFileButton(
1077-
contentController: contentController,
1078-
contentFocusNode: contentFocusNode),
1079-
_AttachMediaButton(
1080-
contentController: contentController,
1081-
contentFocusNode: contentFocusNode),
1082-
_AttachFromCameraButton(
1083-
contentController: contentController,
1084-
contentFocusNode: contentFocusNode),
1085-
]),
1086-
sendButton,
1087-
]))),
1085+
child: IconButtonTheme(
1086+
data: iconButtonThemeData,
1087+
child: Row(
1088+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
1089+
children: [
1090+
Row(children: [
1091+
_AttachFileButton(
1092+
contentController: contentController,
1093+
contentFocusNode: contentFocusNode),
1094+
_AttachMediaButton(
1095+
contentController: contentController,
1096+
contentFocusNode: contentFocusNode),
1097+
_AttachFromCameraButton(
1098+
contentController: contentController,
1099+
contentFocusNode: contentFocusNode),
1100+
]),
1101+
sendButton,
1102+
])))),
10881103
]));
10891104
}
10901105
}

lib/widgets/theme.dart

Lines changed: 7 additions & 0 deletions
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),
@@ -161,6 +162,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
161162
contextMenuCancelText: const Color(0xffffffff).withValues(alpha: 0.75),
162163
contextMenuItemBg: const Color(0xff7977fe),
163164
contextMenuItemText: const Color(0xff9398fd),
165+
editorButtonPressedBg: Colors.white.withValues(alpha: 0.06),
164166
foreground: const Color(0xffffffff),
165167
icon: const Color(0xff7977fe),
166168
labelCounterUnread: const Color(0xffffffff).withValues(alpha: 0.7),
@@ -207,6 +209,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
207209
required this.contextMenuCancelText,
208210
required this.contextMenuItemBg,
209211
required this.contextMenuItemText,
212+
required this.editorButtonPressedBg,
210213
required this.foreground,
211214
required this.icon,
212215
required this.labelCounterUnread,
@@ -254,6 +257,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
254257
final Color contextMenuCancelText;
255258
final Color contextMenuItemBg;
256259
final Color contextMenuItemText;
260+
final Color editorButtonPressedBg;
257261
final Color foreground;
258262
final Color icon;
259263
final Color labelCounterUnread;
@@ -296,6 +300,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
296300
Color? contextMenuCancelText,
297301
Color? contextMenuItemBg,
298302
Color? contextMenuItemText,
303+
Color? editorButtonPressedBg,
299304
Color? foreground,
300305
Color? icon,
301306
Color? labelCounterUnread,
@@ -333,6 +338,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
333338
contextMenuCancelText: contextMenuCancelText ?? this.contextMenuCancelText,
334339
contextMenuItemBg: contextMenuItemBg ?? this.contextMenuItemBg,
335340
contextMenuItemText: contextMenuItemText ?? this.contextMenuItemBg,
341+
editorButtonPressedBg: editorButtonPressedBg ?? this.editorButtonPressedBg,
336342
foreground: foreground ?? this.foreground,
337343
icon: icon ?? this.icon,
338344
labelCounterUnread: labelCounterUnread ?? this.labelCounterUnread,
@@ -377,6 +383,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
377383
contextMenuCancelText: Color.lerp(contextMenuCancelText, other.contextMenuCancelText, t)!,
378384
contextMenuItemBg: Color.lerp(contextMenuItemBg, other.contextMenuItemBg, t)!,
379385
contextMenuItemText: Color.lerp(contextMenuItemText, other.contextMenuItemBg, t)!,
386+
editorButtonPressedBg: Color.lerp(editorButtonPressedBg, other.editorButtonPressedBg, t)!,
380387
foreground: Color.lerp(foreground, other.foreground, t)!,
381388
icon: Color.lerp(icon, other.icon, t)!,
382389
labelCounterUnread: Color.lerp(labelCounterUnread, other.labelCounterUnread, t)!,

0 commit comments

Comments
 (0)