theme chaging bug fixed | code cleaning
This commit is contained in:
parent
5420d52ada
commit
792be0af96
|
|
@ -1,9 +1,10 @@
|
||||||
import 'package:didvan/config/theme_data.dart';
|
import 'package:didvan/config/theme_data.dart';
|
||||||
|
import 'package:didvan/main.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
class DesignConfig {
|
class DesignConfig {
|
||||||
static late BuildContext context;
|
static BuildContext get context => navigatorKey.currentContext!;
|
||||||
|
|
||||||
static const BorderRadius lowBorderRadius = BorderRadius.all(
|
static const BorderRadius lowBorderRadius = BorderRadius.all(
|
||||||
Radius.circular(8),
|
Radius.circular(8),
|
||||||
|
|
@ -35,20 +36,20 @@ class DesignConfig {
|
||||||
|
|
||||||
static SystemUiOverlayStyle get systemUiOverlayStyle {
|
static SystemUiOverlayStyle get systemUiOverlayStyle {
|
||||||
return SystemUiOverlayStyle(
|
return SystemUiOverlayStyle(
|
||||||
statusBarIconBrightness: Theme.of(context).brightness == Brightness.dark
|
statusBarIconBrightness:
|
||||||
? Brightness.light
|
brightness == Brightness.dark ? Brightness.light : Brightness.dark,
|
||||||
: Brightness.dark,
|
|
||||||
statusBarColor: Colors.transparent,
|
statusBarColor: Colors.transparent,
|
||||||
// systemNavigationBarColor: Theme.of(context).colorScheme.surface,
|
systemNavigationBarColor: Theme.of(context).colorScheme.surface,
|
||||||
// systemNavigationBarDividerColor: Colors.transparent,
|
systemNavigationBarDividerColor: Colors.transparent,
|
||||||
// systemNavigationBarIconBrightness:
|
systemNavigationBarIconBrightness:
|
||||||
// Theme.of(context).colorScheme.brightness == Brightness.dark
|
brightness == Brightness.dark ? Brightness.light : Brightness.dark,
|
||||||
// ? Brightness.light
|
|
||||||
// : Brightness.dark,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void updateSystemUiOverlayStyle() {
|
static void updateSystemUiOverlayStyle() {
|
||||||
SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
|
Future.delayed(
|
||||||
|
DesignConfig.lowAnimationDuration,
|
||||||
|
() => SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ void main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
|
||||||
|
final GlobalKey materialKey = GlobalKey();
|
||||||
|
|
||||||
class Didvan extends StatelessWidget {
|
class Didvan extends StatelessWidget {
|
||||||
const Didvan({Key? key}) : super(key: key);
|
const Didvan({Key? key}) : super(key: key);
|
||||||
|
|
@ -27,6 +28,7 @@ class Didvan extends StatelessWidget {
|
||||||
],
|
],
|
||||||
child: Consumer<ThemeProvider>(
|
child: Consumer<ThemeProvider>(
|
||||||
builder: (context, themeProvider, child) => MaterialApp(
|
builder: (context, themeProvider, child) => MaterialApp(
|
||||||
|
key: materialKey,
|
||||||
navigatorKey: navigatorKey,
|
navigatorKey: navigatorKey,
|
||||||
debugShowCheckedModeBanner: false,
|
debugShowCheckedModeBanner: false,
|
||||||
title: 'Didvan',
|
title: 'Didvan',
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,4 @@
|
||||||
import 'dart:developer';
|
|
||||||
|
|
||||||
import 'package:just_audio/just_audio.dart';
|
import 'package:just_audio/just_audio.dart';
|
||||||
import 'package:path_provider/path_provider.dart';
|
|
||||||
import 'package:record/record.dart';
|
import 'package:record/record.dart';
|
||||||
import 'package:universal_html/js.dart' as js;
|
import 'package:universal_html/js.dart' as js;
|
||||||
import 'package:didvan/config/theme_data.dart';
|
import 'package:didvan/config/theme_data.dart';
|
||||||
|
|
|
||||||
|
|
@ -22,10 +22,7 @@ class _HomeState extends State<Home> with SingleTickerProviderStateMixin {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
Future.delayed(const Duration(milliseconds: 400), () {
|
|
||||||
DesignConfig.context = context;
|
|
||||||
DesignConfig.updateSystemUiOverlayStyle();
|
DesignConfig.updateSystemUiOverlayStyle();
|
||||||
});
|
|
||||||
_tabController = TabController(length: 5, vsync: this);
|
_tabController = TabController(length: 5, vsync: this);
|
||||||
_tabController.addListener(() {
|
_tabController.addListener(() {
|
||||||
context.read<HomeState>().currentPageIndex = _tabController.index;
|
context.read<HomeState>().currentPageIndex = _tabController.index;
|
||||||
|
|
|
||||||
|
|
@ -171,11 +171,10 @@ class Settings extends StatelessWidget {
|
||||||
} else {
|
} else {
|
||||||
if (isDarkTheme) {
|
if (isDarkTheme) {
|
||||||
context.read<ThemeProvider>().themeMode = ThemeMode.dark;
|
context.read<ThemeProvider>().themeMode = ThemeMode.dark;
|
||||||
DesignConfig.updateSystemUiOverlayStyle();
|
|
||||||
} else {
|
} else {
|
||||||
context.read<ThemeProvider>().themeMode = ThemeMode.light;
|
context.read<ThemeProvider>().themeMode = ThemeMode.light;
|
||||||
DesignConfig.updateSystemUiOverlayStyle();
|
|
||||||
}
|
}
|
||||||
|
DesignConfig.updateSystemUiOverlayStyle();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: Column(
|
child: Column(
|
||||||
|
|
|
||||||
|
|
@ -42,7 +42,6 @@ class _SplashState extends State<Splash> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
DesignConfig.context = context;
|
|
||||||
if (_isGettingThemeData) {
|
if (_isGettingThemeData) {
|
||||||
return Container(
|
return Container(
|
||||||
color: Colors.black,
|
color: Colors.black,
|
||||||
|
|
@ -52,7 +51,7 @@ class _SplashState extends State<Splash> {
|
||||||
}
|
}
|
||||||
return AnnotatedRegion<SystemUiOverlayStyle>(
|
return AnnotatedRegion<SystemUiOverlayStyle>(
|
||||||
value: DesignConfig.systemUiOverlayStyle.copyWith(
|
value: DesignConfig.systemUiOverlayStyle.copyWith(
|
||||||
// systemNavigationBarColor: Theme.of(context).colorScheme.focused,
|
systemNavigationBarColor: Theme.of(context).colorScheme.background,
|
||||||
),
|
),
|
||||||
child: Scaffold(
|
child: Scaffold(
|
||||||
body: Container(
|
body: Container(
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,11 @@
|
||||||
import 'package:didvan/models/settings_data.dart';
|
import 'package:didvan/models/settings_data.dart';
|
||||||
import 'package:didvan/services/storage/storage.dart';
|
import 'package:didvan/services/storage/storage.dart';
|
||||||
import 'package:flutter/foundation.dart';
|
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:hive_flutter/hive_flutter.dart';
|
import 'package:hive_flutter/hive_flutter.dart';
|
||||||
import 'package:permission_handler/permission_handler.dart';
|
|
||||||
|
|
||||||
class AppInitializer {
|
class AppInitializer {
|
||||||
static Future<void> setupServices() async {
|
static Future<void> setupServices() async {
|
||||||
// late final Directory appDir;
|
|
||||||
// late final Directory appTempsDir;
|
|
||||||
// if (!kIsWeb) {
|
|
||||||
await Hive.initFlutter();
|
await Hive.initFlutter();
|
||||||
// appDir = await getApplicationDocumentsDirectory();
|
|
||||||
// appTempsDir = await getApplicationDocumentsDirectory();
|
|
||||||
// }
|
|
||||||
// Hive.init(appDir.path);
|
|
||||||
// StorageService.appDocsDir = appDir.path;
|
|
||||||
// StorageService.appTempsDir = appTempsDir.path;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Future<ThemeMode> initilizeSettings() async {
|
static Future<ThemeMode> initilizeSettings() async {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue