Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

theme: Follow system setting for light/dark theme! #867

Merged
merged 2 commits into from
Aug 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 1 addition & 26 deletions lib/widgets/theme.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,10 @@ import 'message_list.dart';
import 'channel_colors.dart';
import 'text.dart';

/// In debug mode, controls whether the UI responds to
/// [MediaQueryData.platformBrightness].
///
/// Outside of debug mode, this is always false and the setter has no effect.
// TODO(#95) when dark theme is fully implemented, simplify away;
// the UI should always respond.
bool get debugFollowPlatformBrightness {
bool result = false;
assert(() {
result = _debugFollowPlatformBrightness;
return true;
}());
return result;
}
bool _debugFollowPlatformBrightness = false;
set debugFollowPlatformBrightness(bool value) {
assert(() {
_debugFollowPlatformBrightness = value;
return true;
}());
}


ThemeData zulipThemeData(BuildContext context) {
final DesignVariables designVariables;
final List<ThemeExtension> themeExtensions;
Brightness brightness = debugFollowPlatformBrightness
? MediaQuery.of(context).platformBrightness
: Brightness.light;
Brightness brightness = MediaQuery.platformBrightnessOf(context);
switch (brightness) {
case Brightness.light: {
designVariables = DesignVariables.light();
Expand Down
4 changes: 0 additions & 4 deletions test/widgets/emoji_reaction_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import 'package:zulip/api/model/events.dart';
import 'package:zulip/api/model/model.dart';
import 'package:zulip/model/store.dart';
import 'package:zulip/widgets/emoji_reaction.dart';
import 'package:zulip/widgets/theme.dart';

import '../example_data.dart' as eg;
import '../flutter_checks.dart';
Expand Down Expand Up @@ -221,9 +220,6 @@ void main() {
await prepare();
await store.addUsers([eg.selfUser, eg.otherUser]);

assert(!debugFollowPlatformBrightness); // to be removed with #95
debugFollowPlatformBrightness = true;
addTearDown(() { debugFollowPlatformBrightness = false; });
tester.platformDispatcher.platformBrightnessTestValue = Brightness.light;
addTearDown(tester.platformDispatcher.clearPlatformBrightnessTestValue);

Expand Down
5 changes: 0 additions & 5 deletions test/widgets/message_list_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import 'package:zulip/widgets/icons.dart';
import 'package:zulip/widgets/message_list.dart';
import 'package:zulip/widgets/store.dart';
import 'package:zulip/widgets/channel_colors.dart';
import 'package:zulip/widgets/theme.dart';

import '../api/fake_api.dart';
import '../example_data.dart' as eg;
Expand Down Expand Up @@ -152,10 +151,6 @@ void main() {
});

testWidgets('smoke test for light/dark/lerped', (tester) async {
assert(!debugFollowPlatformBrightness); // to be removed with #95
debugFollowPlatformBrightness = true;
addTearDown(() { debugFollowPlatformBrightness = false; });

tester.platformDispatcher.platformBrightnessTestValue = Brightness.light;
addTearDown(tester.platformDispatcher.clearPlatformBrightnessTestValue);

Expand Down
3 changes: 0 additions & 3 deletions test/widgets/theme_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ void main() {

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

assert(!debugFollowPlatformBrightness); // to be removed with #95
debugFollowPlatformBrightness = true;
addTearDown(() { debugFollowPlatformBrightness = false; });
tester.platformDispatcher.platformBrightnessTestValue = Brightness.light;
addTearDown(tester.platformDispatcher.clearPlatformBrightnessTestValue);

Expand Down