Skip to content

Commit 23a9705

Browse files
committed
compose: Make compose-box border more prominent in dark mode
Updated the top border and added shadow effect to the top of the compose box to ensure it is subtle in dark mode. For reference, see the Figma design: https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=5908-64038&t=alSmAmdRXFDwT4IT-1 Fixes: #1207
1 parent ae7939a commit 23a9705

File tree

3 files changed

+67
-2
lines changed

3 files changed

+67
-2
lines changed

lib/widgets/compose_box.dart

+56-1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,59 @@ import 'store.dart';
2222
import 'text.dart';
2323
import 'theme.dart';
2424

25+
/// Compose-box styles that differ between light and dark theme.
26+
///
27+
/// These styles will animate on theme changes (with help from [lerp]).
28+
class ComposeBoxTheme extends ThemeExtension<ComposeBoxTheme> {
29+
static final light = ComposeBoxTheme._(
30+
boxShadow: null,
31+
);
32+
33+
static final dark = ComposeBoxTheme._(
34+
boxShadow: [BoxShadow(
35+
color: DesignVariables.dark.bgTopBar,
36+
offset: const Offset(0, -4),
37+
blurRadius: 16,
38+
spreadRadius: 0,
39+
)],
40+
);
41+
42+
ComposeBoxTheme._({
43+
required this.boxShadow,
44+
});
45+
46+
/// The [ComposeBoxTheme] from the context's active theme.
47+
///
48+
/// The [ThemeData] must include [ComposeBoxTheme] in [ThemeData.extensions].
49+
static ComposeBoxTheme of(BuildContext context) {
50+
final theme = Theme.of(context);
51+
final extension = theme.extension<ComposeBoxTheme>();
52+
assert(extension != null);
53+
return extension!;
54+
}
55+
56+
final List<BoxShadow>? boxShadow;
57+
58+
@override
59+
ComposeBoxTheme copyWith({
60+
List<BoxShadow>? boxShadow,
61+
}) {
62+
return ComposeBoxTheme._(
63+
boxShadow: boxShadow ?? this.boxShadow,
64+
);
65+
}
66+
67+
@override
68+
ComposeBoxTheme lerp(ComposeBoxTheme other, double t) {
69+
if (identical(this, other)) {
70+
return this;
71+
}
72+
return ComposeBoxTheme._(
73+
boxShadow: BoxShadow.lerpList(boxShadow, other.boxShadow, t)!,
74+
);
75+
}
76+
}
77+
2578
const double _composeButtonSize = 44;
2679

2780
/// A [TextEditingController] for use in the compose box.
@@ -1089,7 +1142,9 @@ class _ComposeBoxContainer extends StatelessWidget {
10891142
// the message list itself; if so, remember to update ComposeBox's dartdoc.
10901143
return Container(width: double.infinity,
10911144
decoration: BoxDecoration(
1092-
border: Border(top: BorderSide(color: designVariables.borderBar))),
1145+
border: Border(top: BorderSide(color: designVariables.borderBar)),
1146+
boxShadow: ComposeBoxTheme.of(context).boxShadow,
1147+
),
10931148
// TODO(#720) try a Stack for the overlaid linear progress indicator
10941149
child: Material(
10951150
color: designVariables.composeBoxBg,

lib/widgets/theme.dart

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'package:flutter/material.dart';
22

33
import '../api/model/model.dart';
4+
import 'compose_box.dart';
45
import 'content.dart';
56
import 'emoji_reaction.dart';
67
import 'message_list.dart';
@@ -32,6 +33,7 @@ ThemeData zulipThemeData(BuildContext context) {
3233
designVariables,
3334
EmojiReactionTheme.light,
3435
MessageListTheme.light,
36+
ComposeBoxTheme.light,
3537
];
3638
}
3739
case Brightness.dark: {
@@ -41,6 +43,7 @@ ThemeData zulipThemeData(BuildContext context) {
4143
designVariables,
4244
EmojiReactionTheme.dark,
4345
MessageListTheme.dark,
46+
ComposeBoxTheme.dark,
4447
];
4548
}
4649
}
@@ -175,7 +178,7 @@ class DesignVariables extends ThemeExtension<DesignVariables> {
175178
bgMenuButtonActive: Colors.black.withValues(alpha: 0.2),
176179
bgMenuButtonSelected: Colors.black.withValues(alpha: 0.25),
177180
bgTopBar: const Color(0xff242424),
178-
borderBar: Colors.black.withValues(alpha: 0.5),
181+
borderBar: const Color(0xffffffff).withValues(alpha: 0.1),
179182
borderMenuButtonSelected: Colors.white.withValues(alpha: 0.1),
180183
btnLabelAttLowIntDanger: const Color(0xffff8b7c),
181184
btnLabelAttMediumIntDanger: const Color(0xffff8b7c),

test/widgets/compose_box_test.dart

+7
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@ import 'test_app.dart';
3737
void main() {
3838
TestZulipBinding.ensureInitialized();
3939

40+
testWidgets('lerp light to dark, no crash', (test) async {
41+
final a = ComposeBoxTheme.light;
42+
final b = ComposeBoxTheme.dark;
43+
44+
check(() => a.lerp(b, 0.5)).returnsNormally();
45+
});
46+
4047
late PerAccountStore store;
4148
late FakeApiConnection connection;
4249
late ComposeBoxController? controller;

0 commit comments

Comments
 (0)