Skip to content

Commit e4fa683

Browse files
committed
compose: 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. Different from the style that all the compose buttons share, this feedback also applies to the send button, and will apply to more buttons in the app. In the future we should migrate more buttons to use this style, so it doesn't belong to a shared base class. 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 9e9280d commit e4fa683

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

lib/widgets/compose_box.dart

+23-7
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,8 @@ class _SendButtonState extends State<_SendButton> {
10011001
icon: Icon(ZulipIcons.send,
10021002
// We set [Icon.color] instead of [IconButton.color] because the
10031003
// latter implicitly uses colors derived from it to override the
1004-
// ambient [ButtonStyle.overlayColor].
1004+
// ambient [ButtonStyle.overlayColor], where we set the color for
1005+
// the highlight state to match the Figma design.
10051006
color: iconColor),
10061007
onPressed: _send));
10071008
}
@@ -1046,6 +1047,7 @@ class _ComposeBoxLayout extends StatelessWidget {
10461047
@override
10471048
Widget build(BuildContext context) {
10481049
final themeData = Theme.of(context);
1050+
final designVariables = DesignVariables.of(context);
10491051

10501052
final inputThemeData = themeData.copyWith(
10511053
inputDecorationTheme: const InputDecorationTheme(
@@ -1054,6 +1056,18 @@ class _ComposeBoxLayout extends StatelessWidget {
10541056
contentPadding: EdgeInsets.zero,
10551057
border: InputBorder.none));
10561058

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+
10571071
final composeButtons = [
10581072
_AttachFileButton(contentController: contentController, contentFocusNode: contentFocusNode),
10591073
_AttachMediaButton(contentController: contentController, contentFocusNode: contentFocusNode),
@@ -1072,12 +1086,14 @@ class _ComposeBoxLayout extends StatelessWidget {
10721086
]))),
10731087
SizedBox(
10741088
height: _composeButtonSize,
1075-
child: Row(
1076-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
1077-
children: [
1078-
Row(children: composeButtons),
1079-
sendButton,
1080-
])),
1089+
child: IconButtonTheme(
1090+
data: iconButtonThemeData,
1091+
child: Row(
1092+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
1093+
children: [
1094+
Row(children: composeButtons),
1095+
sendButton,
1096+
]))),
10811097
]));
10821098
}
10831099
}

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),
@@ -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)