Skip to content

Commit 94cf40e

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: #915 Signed-off-by: Zixuan James Li <[email protected]>
1 parent 3adb395 commit 94cf40e

File tree

2 files changed

+30
-7
lines changed

2 files changed

+30
-7
lines changed

lib/widgets/compose_box.dart

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

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

1060+
// TODO(#417): Disable splash effects for all buttons globally.
1061+
final iconButtonThemeData = IconButtonThemeData(
1062+
style: IconButton.styleFrom(
1063+
splashFactory: NoSplash.splashFactory,
1064+
// TODO(#417): The Figma design specifies a different icon color on
1065+
// pressed, but `IconButton` currently does not have support for
1066+
// that. See also:
1067+
// https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=3707-41711&node-type=frame&t=sSYomsJzGCt34D8N-0
1068+
highlightColor: designVariables.editorButtonPressedBg,
1069+
shape: const RoundedRectangleBorder(
1070+
borderRadius: BorderRadius.all(Radius.circular(4)))));
1071+
10581072
final composeButtons = [
10591073
_AttachFileButton(contentController: contentController, contentFocusNode: contentFocusNode),
10601074
_AttachMediaButton(contentController: contentController, contentFocusNode: contentFocusNode),
@@ -1073,12 +1087,14 @@ class _ComposeBoxLayout extends StatelessWidget {
10731087
]))),
10741088
SizedBox(
10751089
height: _composeButtonSize,
1076-
child: Row(
1077-
mainAxisAlignment: MainAxisAlignment.spaceBetween,
1078-
children: [
1079-
Row(children: composeButtons),
1080-
sendButton,
1081-
])),
1090+
child: IconButtonTheme(
1091+
data: iconButtonThemeData,
1092+
child: Row(
1093+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
1094+
children: [
1095+
Row(children: composeButtons),
1096+
sendButton,
1097+
]))),
10821098
]));
10831099
}
10841100
}

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)