diff --git a/lib/cubit/theme_cubit.dart b/lib/cubit/theme_cubit.dart deleted file mode 100644 index f6c84b04056c5e98352f08ddfe3c069857556ed6..0000000000000000000000000000000000000000 --- a/lib/cubit/theme_cubit.dart +++ /dev/null @@ -1,30 +0,0 @@ -import 'package:flutter_custom_toolbox/flutter_toolbox.dart'; -import 'package:flutter/material.dart'; - -part 'theme_state.dart'; - -class ThemeCubit extends HydratedCubit<ThemeModeState> { - ThemeCubit() : super(const ThemeModeState()); - - void getTheme(ThemeModeState state) { - emit(state); - } - - @override - ThemeModeState? fromJson(Map<String, dynamic> json) { - switch (json['themeMode']) { - case 'ThemeMode.dark': - return const ThemeModeState(themeMode: ThemeMode.dark); - case 'ThemeMode.light': - return const ThemeModeState(themeMode: ThemeMode.light); - case 'ThemeMode.system': - default: - return const ThemeModeState(themeMode: ThemeMode.system); - } - } - - @override - Map<String, String>? toJson(ThemeModeState state) { - return <String, String>{'themeMode': state.themeMode.toString()}; - } -} diff --git a/lib/cubit/theme_state.dart b/lib/cubit/theme_state.dart deleted file mode 100644 index e479a50f12fe72a35a1fd1722ff72afbb692a136..0000000000000000000000000000000000000000 --- a/lib/cubit/theme_state.dart +++ /dev/null @@ -1,15 +0,0 @@ -part of 'theme_cubit.dart'; - -@immutable -class ThemeModeState extends Equatable { - const ThemeModeState({ - this.themeMode, - }); - - final ThemeMode? themeMode; - - @override - List<Object?> get props => <Object?>[ - themeMode, - ]; -} diff --git a/lib/main.dart b/lib/main.dart index b774645e53b8c1ad5dd9fc9681efa91cdbaf39e6..1437a56c2ea93b567899a20e816c2318ed2edfc2 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -8,7 +8,6 @@ import 'package:random/cubit/bottom_nav_cubit.dart'; import 'package:random/cubit/data_cubit.dart'; import 'package:random/cubit/game_cubit.dart'; import 'package:random/cubit/settings_cubit.dart'; -import 'package:random/cubit/theme_cubit.dart'; import 'package:random/repository/api.dart'; import 'package:random/network/api.dart'; import 'package:random/ui/skeleton.dart'; @@ -55,10 +54,11 @@ class MyApp extends StatelessWidget { BlocProvider<DataCubit>(create: (context) => DataCubit()), BlocProvider<GameCubit>(create: (context) => GameCubit()), BlocProvider<SettingsCubit>(create: (context) => SettingsCubit()), - BlocProvider<ThemeCubit>(create: (context) => ThemeCubit()), + BlocProvider<ApplicationThemeModeCubit>( + create: (context) => ApplicationThemeModeCubit()), ], - child: BlocBuilder<ThemeCubit, ThemeModeState>( - builder: (BuildContext context, ThemeModeState state) { + child: BlocBuilder<ApplicationThemeModeCubit, ApplicationThemeModeState>( + builder: (BuildContext context, ApplicationThemeModeState state) { return MaterialApp( title: 'Random application', theme: lightTheme, diff --git a/lib/ui/widgets/theme_card.dart b/lib/ui/widgets/theme_card.dart index fefb525722d3a2541c48cd25f2f45e4875c99e77..18fffe0ed4e34cfa7483b618b317ebed67cfc13d 100644 --- a/lib/ui/widgets/theme_card.dart +++ b/lib/ui/widgets/theme_card.dart @@ -1,8 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_custom_toolbox/flutter_toolbox.dart'; -import 'package:random/cubit/theme_cubit.dart'; - class ThemeCard extends StatelessWidget { const ThemeCard({ super.key, @@ -15,8 +13,8 @@ class ThemeCard extends StatelessWidget { @override Widget build(BuildContext context) { - return BlocBuilder<ThemeCubit, ThemeModeState>( - builder: (BuildContext context, ThemeModeState state) { + return BlocBuilder<ApplicationThemeModeCubit, ApplicationThemeModeState>( + builder: (BuildContext context, ApplicationThemeModeState state) { return Card( elevation: 2, shadowColor: Theme.of(context).colorScheme.shadow, @@ -28,8 +26,8 @@ class ThemeCard extends StatelessWidget { ), margin: const EdgeInsets.all(5), child: InkWell( - onTap: () => BlocProvider.of<ThemeCubit>(context).getTheme( - ThemeModeState(themeMode: mode), + onTap: () => BlocProvider.of<ApplicationThemeModeCubit>(context).getTheme( + ApplicationThemeModeState(themeMode: mode), ), borderRadius: const BorderRadius.all(Radius.circular(12)), child: Icon( diff --git a/pubspec.lock b/pubspec.lock index 077816ab2c214f75366e8ed75668be42288b48b5..f45210bcb4e5951d0ad8a9f45603671510c22f7d 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -194,11 +194,11 @@ packages: dependency: "direct main" description: path: "." - ref: "0.1.1" - resolved-ref: ba7137ca9edec7e503ed3dbfe7f6ede7e9cfbf4d + ref: "0.2.0" + resolved-ref: bbf0abd5457d42678882384216af9e83c38549bc url: "https://git.harrault.fr/android/flutter-toolbox.git" source: git - version: "0.1.1" + version: "0.2.0" flutter_lints: dependency: "direct dev" description: diff --git a/pubspec.yaml b/pubspec.yaml index b76981b40e4df47f85e6a0fc0756e0e50007d4b0..e7063fcd9238540b54b8bea895ab4c0c2aa15fe9 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: A random application, for testing purpose only. publish_to: "none" -version: 1.2.0+69 +version: 1.2.1+70 environment: sdk: "^3.0.0" @@ -16,7 +16,7 @@ dependencies: flutter_custom_toolbox: git: url: https://git.harrault.fr/android/flutter-toolbox.git - ref: 0.1.1 + ref: 0.2.0 # specific camera: ^0.11.0+2