diff --git a/lib/main.dart b/lib/main.dart index 6e46644d..bcaaeef1 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -8,5 +8,10 @@ void main() async { WidgetsFlutterBinding.ensureInitialized(); LocalStorage(); await DatabaseConfig.init(StoreRef.main()); - runApp(ProviderScope(child: MyApp())); + runApp( + ProviderScope( + observers: [RiverpodObserver()], + child: MyApp(), + ), + ); } diff --git a/lib/src/app.dart b/lib/src/app.dart index 437f08cb..747deafe 100644 --- a/lib/src/app.dart +++ b/lib/src/app.dart @@ -16,11 +16,9 @@ class MyApp extends ConsumerWidget { debugShowCheckedModeBanner: false, title: Strings.appName, theme: themeData( - currentAppTheme.value == CurrentAppTheme.dark - ? ThemeConfig.darkTheme - : ThemeConfig.lightTheme, + currentAppTheme.value == CurrentAppTheme.dark ? darkTheme : lightTheme, ), - darkTheme: themeData(ThemeConfig.darkTheme), + darkTheme: themeData(darkTheme), themeMode: currentAppTheme.value?.themeMode, routerConfig: _appRouter.config( navigatorObservers: () => [ @@ -37,7 +35,7 @@ class MyApp extends ConsumerWidget { theme.textTheme, ), colorScheme: theme.colorScheme.copyWith( - secondary: ThemeConfig.lightAccent, + secondary: lightAccent, ), ); } diff --git a/lib/src/common/common.dart b/lib/src/common/common.dart index 6e753c5b..c4c23e29 100644 --- a/lib/src/common/common.dart +++ b/lib/src/common/common.dart @@ -5,3 +5,4 @@ export 'domain/domain.dart'; export 'extensions/extensions.dart'; export 'presentation/presentation.dart'; export 'router/app_router.dart'; +export 'utils/utils.dart'; diff --git a/lib/src/common/presentation/theme/theme_config.dart b/lib/src/common/presentation/theme/theme_config.dart index 2a390333..e4fbf936 100644 --- a/lib/src/common/presentation/theme/theme_config.dart +++ b/lib/src/common/presentation/theme/theme_config.dart @@ -1,60 +1,72 @@ import 'package:flutter/material.dart'; -class ThemeConfig { - static Color lightPrimary = const Color(0xffF5F5F5); - static Color darkPrimary = const Color(0xff1f1f1f); - static Color lightAccent = const Color(0xff2ca8e2); - static Color darkAccent = const Color(0xff2ca8e2); - static Color lightBG = Colors.white; - static Color darkBG = const Color(0xff121212); - static Color smokeWhite = const Color(0xffF5F5F5); +const Color lightPrimary = Color(0xffF5F5F5); +const Color darkPrimary = Color(0xff1f1f1f); +const Color lightAccent = Color(0xff2ca8e2); +const Color darkAccent = Color(0xff2ca8e2); +const Color lightBG = Colors.white; +const Color darkBG = Color(0xff121212); +const Color smokeWhite = Color(0xffF5F5F5); - static ThemeData lightTheme = ThemeData( - colorScheme: ColorScheme.fromSwatch().copyWith( - secondary: lightBG, - brightness: Brightness.light, - ), - primaryColor: lightPrimary, - scaffoldBackgroundColor: lightBG, - navigationRailTheme: NavigationRailThemeData( - backgroundColor: smokeWhite, - ), - appBarTheme: AppBarTheme( - color: lightPrimary, - elevation: 0.0, - titleTextStyle: const TextStyle( - color: Colors.black, - fontSize: 20, - fontWeight: FontWeight.w800, - ), - iconTheme: const IconThemeData( - color: Colors.black, +final ThemeData lightTheme = ThemeData( + colorScheme: ColorScheme.fromSwatch().copyWith( + secondary: lightBG, + brightness: Brightness.light, + ), + primaryColor: lightPrimary, + scaffoldBackgroundColor: lightBG, + navigationRailTheme: const NavigationRailThemeData( + backgroundColor: smokeWhite, + ), + tabBarTheme: const TabBarTheme( + labelColor: Colors.black, + unselectedLabelColor: Colors.grey, + indicator: UnderlineTabIndicator( + borderSide: BorderSide( + color: lightAccent, + width: 2.0, ), ), - ); + ), + appBarTheme: const AppBarTheme( + color: lightPrimary, + elevation: 0.0, + titleTextStyle: TextStyle( + color: Colors.black, + fontSize: 20, + fontWeight: FontWeight.w800, + ), + iconTheme: IconThemeData(color: Colors.black), + ), +); - static ThemeData darkTheme = ThemeData( +final ThemeData darkTheme = ThemeData( + brightness: Brightness.dark, + colorScheme: ColorScheme.fromSwatch().copyWith( + secondary: darkBG, brightness: Brightness.dark, - colorScheme: ColorScheme.fromSwatch().copyWith( - secondary: darkBG, - brightness: Brightness.dark, - ), - primaryColor: darkPrimary, - scaffoldBackgroundColor: darkBG, - navigationRailTheme: NavigationRailThemeData( - backgroundColor: darkPrimary, - ), - appBarTheme: AppBarTheme( - color: darkPrimary, - elevation: 0.0, - titleTextStyle: const TextStyle( - color: Colors.white, - fontSize: 20, - fontWeight: FontWeight.w800, - ), - iconTheme: const IconThemeData( - color: Colors.white, + ), + primaryColor: darkPrimary, + scaffoldBackgroundColor: darkBG, + navigationRailTheme: const NavigationRailThemeData( + backgroundColor: darkPrimary, + ), + tabBarTheme: const TabBarTheme( + indicator: UnderlineTabIndicator( + borderSide: BorderSide( + color: lightAccent, + width: 2.0, ), ), - ); -} + ), + appBarTheme: const AppBarTheme( + color: darkPrimary, + elevation: 0.0, + titleTextStyle: TextStyle( + color: Colors.white, + fontSize: 20, + fontWeight: FontWeight.w800, + ), + iconTheme: IconThemeData(color: Colors.white), + ), +); diff --git a/lib/src/common/utils/riverpod_observer.dart b/lib/src/common/utils/riverpod_observer.dart new file mode 100644 index 00000000..6ea0e6f5 --- /dev/null +++ b/lib/src/common/utils/riverpod_observer.dart @@ -0,0 +1,45 @@ +import 'package:flutter_riverpod/flutter_riverpod.dart'; +import 'package:logman/logman.dart'; + +class RiverpodObserver extends ProviderObserver { + final logman = Logman.instance; + + @override + void didAddProvider( + ProviderBase provider, + Object? value, + ProviderContainer container, + ) { + logman.recordSimpleLog('Provider $provider was initialized with $value'); + } + + @override + void didDisposeProvider( + ProviderBase provider, + ProviderContainer container, + ) { + logman.recordSimpleLog('Provider $provider was disposed'); + } + + @override + void didUpdateProvider( + ProviderBase provider, + Object? previousValue, + Object? newValue, + ProviderContainer container, + ) { + logman.recordSimpleLog( + 'Provider $provider updated from $previousValue to $newValue', + ); + } + + @override + void providerDidFail( + ProviderBase provider, + Object error, + StackTrace stackTrace, + ProviderContainer container, + ) { + logman.recordSimpleLog('Provider $provider threw $error at $stackTrace'); + } +} diff --git a/lib/src/common/utils/utils.dart b/lib/src/common/utils/utils.dart new file mode 100644 index 00000000..7c721fae --- /dev/null +++ b/lib/src/common/utils/utils.dart @@ -0,0 +1 @@ +export 'riverpod_observer.dart';