Skip to content

Commit 7659479

Browse files
lakshya1goelgnprice
authored andcommitted
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 make it more visible 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 449f326 commit 7659479

File tree

3 files changed

+69
-2
lines changed

3 files changed

+69
-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.
@@ -1090,7 +1143,9 @@ class _ComposeBoxContainer extends StatelessWidget {
10901143
// the message list itself; if so, remember to update ComposeBox's dartdoc.
10911144
return Container(width: double.infinity,
10921145
decoration: BoxDecoration(
1093-
border: Border(top: BorderSide(color: designVariables.borderBar))),
1146+
border: Border(top: BorderSide(color: designVariables.borderBar)),
1147+
boxShadow: ComposeBoxTheme.of(context).boxShadow,
1148+
),
10941149
// TODO(#720) try a Stack for the overlaid linear progress indicator
10951150
child: Material(
10961151
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

+9
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,15 @@ void main() {
111111
await tester.pump(Duration.zero);
112112
}
113113

114+
group('ComposeBoxTheme', () {
115+
test('lerp light to dark, no crash', () {
116+
final a = ComposeBoxTheme.light;
117+
final b = ComposeBoxTheme.dark;
118+
119+
check(() => a.lerp(b, 0.5)).returnsNormally();
120+
});
121+
});
122+
114123
group('ComposeContentController', () {
115124
group('insertPadded', () {
116125
// Like `parseMarkedText` in test/model/autocomplete_test.dart,

0 commit comments

Comments
 (0)