Skip to content

Commit

Permalink
fix: Follow system theme immediately (#1942)
Browse files Browse the repository at this point in the history
Co-authored-by: surya-technovert <surya.m@technovert.com>
  • Loading branch information
snehithssv and surya-technovert authored Jun 29, 2024
1 parent 7720408 commit 694f2a9
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion lib/ui/theme/dynamic_theme_builder.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:ui';
import 'package:dynamic_color/dynamic_color.dart';
import 'package:dynamic_themes/dynamic_themes.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:revanced_manager/app/app.router.dart';
Expand All @@ -24,14 +25,26 @@ class DynamicThemeBuilder extends StatefulWidget {

class _DynamicThemeBuilderState extends State<DynamicThemeBuilder>
with WidgetsBindingObserver {
Brightness brightness = PlatformDispatcher.instance.platformBrightness;
late Brightness brightness;

@override
void initState() {
super.initState();
brightness = PlatformDispatcher.instance.platformBrightness;
WidgetsBinding.instance.addObserver(this);
}

@override
void didChangeAppLifecycleState(AppLifecycleState state) {
if (state == AppLifecycleState.resumed) {
final systemBrightness = PlatformDispatcher.instance.platformBrightness;
if (brightness != systemBrightness) {
brightness = systemBrightness;
setState(() {});
}
}
}

@override
Widget build(BuildContext context) {
return DynamicColorBuilder(
Expand Down

0 comments on commit 694f2a9

Please sign in to comment.