Skip to content

Commit 806e4fa

Browse files
chrisbobbegnprice
authored andcommitted
theme: Follow system setting for light/dark theme!
We now have dark-theme variants in all the styles that differ between light and dark, in all of the app we've implemented so far. It's time to let users benefit from that work! We don't yet let the user choose between dark/light/system in the app -- that's #97 "Store some client settings" -- but the "system" behavior should be the default anyway, and this commit provides that. The dark-theme colors come from various sources. For each color, I believe the source is clear either in the code or the Git history. Those sources are: - Flutter's library of Material Design widgets, for UI that's been using those (like the compose box) - the "ready for dev" parts of the new Figma, like this: https://www.figma.com/design/1JTNtYo9memgW7vV6d0ygq/Zulip-Mobile?node-id=2940-48987&m=dev - the web app (in its state when we wrote the zulip-flutter commit) - the table of variables in the new Figma, with a note that we're not sure if we chose the right variable (because that part of the UI doesn't have a "ready for dev" design in the Figma yet) - my brain and a quick check that it looked OK, as a last resort We'll want to update the colors as Vlad's work on the new Figma progresses, and also incorporate his feedback from trying out the app in dark theme. Fixes: #95
1 parent e9b5f6f commit 806e4fa

File tree

4 files changed

+1
-38
lines changed

4 files changed

+1
-38
lines changed

lib/widgets/theme.dart

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,10 @@ import 'message_list.dart';
77
import 'channel_colors.dart';
88
import 'text.dart';
99

10-
/// In debug mode, controls whether the UI responds to
11-
/// [MediaQueryData.platformBrightness].
12-
///
13-
/// Outside of debug mode, this is always false and the setter has no effect.
14-
// TODO(#95) when dark theme is fully implemented, simplify away;
15-
// the UI should always respond.
16-
bool get debugFollowPlatformBrightness {
17-
bool result = false;
18-
assert(() {
19-
result = _debugFollowPlatformBrightness;
20-
return true;
21-
}());
22-
return result;
23-
}
24-
bool _debugFollowPlatformBrightness = false;
25-
set debugFollowPlatformBrightness(bool value) {
26-
assert(() {
27-
_debugFollowPlatformBrightness = value;
28-
return true;
29-
}());
30-
}
31-
32-
3310
ThemeData zulipThemeData(BuildContext context) {
3411
final DesignVariables designVariables;
3512
final List<ThemeExtension> themeExtensions;
36-
Brightness brightness = debugFollowPlatformBrightness
37-
? MediaQuery.of(context).platformBrightness
38-
: Brightness.light;
13+
Brightness brightness = MediaQuery.of(context).platformBrightness;
3914
switch (brightness) {
4015
case Brightness.light: {
4116
designVariables = DesignVariables.light();

test/widgets/emoji_reaction_test.dart

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import 'package:zulip/api/model/events.dart';
1111
import 'package:zulip/api/model/model.dart';
1212
import 'package:zulip/model/store.dart';
1313
import 'package:zulip/widgets/emoji_reaction.dart';
14-
import 'package:zulip/widgets/theme.dart';
1514

1615
import '../example_data.dart' as eg;
1716
import '../flutter_checks.dart';
@@ -221,9 +220,6 @@ void main() {
221220
await prepare();
222221
await store.addUsers([eg.selfUser, eg.otherUser]);
223222

224-
assert(!debugFollowPlatformBrightness); // to be removed with #95
225-
debugFollowPlatformBrightness = true;
226-
addTearDown(() { debugFollowPlatformBrightness = false; });
227223
tester.platformDispatcher.platformBrightnessTestValue = Brightness.light;
228224
addTearDown(tester.platformDispatcher.clearPlatformBrightnessTestValue);
229225

test/widgets/message_list_test.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ import 'package:zulip/widgets/icons.dart';
2121
import 'package:zulip/widgets/message_list.dart';
2222
import 'package:zulip/widgets/store.dart';
2323
import 'package:zulip/widgets/channel_colors.dart';
24-
import 'package:zulip/widgets/theme.dart';
2524

2625
import '../api/fake_api.dart';
2726
import '../example_data.dart' as eg;
@@ -152,10 +151,6 @@ void main() {
152151
});
153152

154153
testWidgets('smoke test for light/dark/lerped', (tester) async {
155-
assert(!debugFollowPlatformBrightness); // to be removed with #95
156-
debugFollowPlatformBrightness = true;
157-
addTearDown(() { debugFollowPlatformBrightness = false; });
158-
159154
tester.platformDispatcher.platformBrightnessTestValue = Brightness.light;
160155
addTearDown(tester.platformDispatcher.clearPlatformBrightnessTestValue);
161156

test/widgets/theme_test.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,6 @@ void main() {
106106

107107
final subscription = eg.subscription(eg.stream(), color: baseColor);
108108

109-
assert(!debugFollowPlatformBrightness); // to be removed with #95
110-
debugFollowPlatformBrightness = true;
111-
addTearDown(() { debugFollowPlatformBrightness = false; });
112109
tester.platformDispatcher.platformBrightnessTestValue = Brightness.light;
113110
addTearDown(tester.platformDispatcher.clearPlatformBrightnessTestValue);
114111

0 commit comments

Comments
 (0)