diff --git a/fastlane/metadata/android/en-US/changelogs/23.txt b/fastlane/metadata/android/en-US/changelogs/23.txt new file mode 100644 index 0000000000000000000000000000000000000000..32ed6eeabc096d0bf9648887a8525fd6364bb098 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/23.txt @@ -0,0 +1 @@ +Use ApplicationSettings widgets from flutter_custom_toolbox. diff --git a/fastlane/metadata/android/fr-FR/changelogs/23.txt b/fastlane/metadata/android/fr-FR/changelogs/23.txt new file mode 100644 index 0000000000000000000000000000000000000000..6d5f7c8162c433e10549ee49e010d90c58ffdbc3 --- /dev/null +++ b/fastlane/metadata/android/fr-FR/changelogs/23.txt @@ -0,0 +1 @@ +Utilisation des widgets ApplicationSettings depuis flutter_custom_toolbox. diff --git a/lib/cubit/theme_cubit.dart b/lib/cubit/theme_cubit.dart deleted file mode 100644 index 1ecab6014c67a0393eabbf704b8b85c9e988705e..0000000000000000000000000000000000000000 --- a/lib/cubit/theme_cubit.dart +++ /dev/null @@ -1,30 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_custom_toolbox/flutter_toolbox.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 03454dfd0cc7ebcc4a573ee469aefc8030f5a6b0..4a18a15d9cb90d7ee02432492f445dcd82442d3b 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -8,7 +8,6 @@ import 'package:plotter/cubit/activity_cubit.dart'; import 'package:plotter/cubit/nav_cubit_pages.dart'; import 'package:plotter/cubit/nav_cubit_screens.dart'; import 'package:plotter/cubit/settings_global_cubit.dart'; -import 'package:plotter/cubit/theme_cubit.dart'; import 'package:plotter/ui/skeleton.dart'; void main() async { @@ -43,12 +42,13 @@ class MyApp extends StatelessWidget { providers: [ BlocProvider<NavCubitPage>(create: (context) => NavCubitPage()), BlocProvider<NavCubitScreen>(create: (context) => NavCubitScreen()), - BlocProvider<ThemeCubit>(create: (context) => ThemeCubit()), + BlocProvider<ApplicationThemeModeCubit>( + create: (context) => ApplicationThemeModeCubit()), BlocProvider<ActivityCubit>(create: (context) => ActivityCubit()), BlocProvider<GlobalSettingsCubit>(create: (context) => GlobalSettingsCubit()), ], - child: BlocBuilder<ThemeCubit, ThemeModeState>( - builder: (BuildContext context, ThemeModeState state) { + child: BlocBuilder<ApplicationThemeModeCubit, ApplicationThemeModeState>( + builder: (BuildContext context, ApplicationThemeModeState state) { return MaterialApp( title: 'Stepper plotter assistant', home: const SkeletonScreen(), diff --git a/lib/ui/screens/settings.dart b/lib/ui/screens/settings.dart index 418308758e47a0ceb1d46133861f658e5f2ad05f..7981b1c6becc4f5b925c3058b05423750d80f62e 100644 --- a/lib/ui/screens/settings.dart +++ b/lib/ui/screens/settings.dart @@ -1,8 +1,6 @@ import 'package:flutter/material.dart'; import 'package:flutter_custom_toolbox/flutter_toolbox.dart'; -import 'package:plotter/ui/settings/settings_form.dart'; - class ScreenSettings extends StatelessWidget { const ScreenSettings({super.key}); @@ -18,7 +16,7 @@ class ScreenSettings extends StatelessWidget { SizedBox(height: 8), AppTitle(text: 'settings_title'), SizedBox(height: 8), - SettingsForm(), + ApplicationSettingsForm(), ], ), ); diff --git a/lib/ui/settings/settings_form.dart b/lib/ui/settings/settings_form.dart deleted file mode 100644 index 90863b3ac9da9019f43251c8889370f22000ba8b..0000000000000000000000000000000000000000 --- a/lib/ui/settings/settings_form.dart +++ /dev/null @@ -1,98 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_custom_toolbox/flutter_toolbox.dart'; - -import 'package:plotter/cubit/settings_global_cubit.dart'; -import 'package:plotter/ui/settings/theme_card.dart'; - -class SettingsForm extends StatefulWidget { - const SettingsForm({super.key}); - - @override - State<SettingsForm> createState() => _SettingsFormState(); -} - -class _SettingsFormState extends State<SettingsForm> { - final apiHostFieldController = TextEditingController(); - - @override - void didChangeDependencies() { - GlobalSettingsCubit settings = BlocProvider.of<GlobalSettingsCubit>(context); - - apiHostFieldController.text = settings.getParameterValue('apiHost'); - - super.didChangeDependencies(); - } - - @override - void dispose() { - apiHostFieldController.dispose(); - - super.dispose(); - } - - @override - Widget build(BuildContext context) { - void saveSettings() { - BlocProvider.of<GlobalSettingsCubit>(context).setValues( - apiHost: apiHostFieldController.text, - ); - } - - return Column( - mainAxisAlignment: MainAxisAlignment.start, - crossAxisAlignment: CrossAxisAlignment.start, - mainAxisSize: MainAxisSize.max, - children: <Widget>[ - // Light/dark theme - Row( - mainAxisAlignment: MainAxisAlignment.spaceBetween, - crossAxisAlignment: CrossAxisAlignment.center, - children: <Widget>[ - const Text('settings_label_theme').tr(), - const Row( - mainAxisAlignment: MainAxisAlignment.end, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - ThemeCard( - mode: ThemeMode.system, - icon: UniconsLine.cog, - ), - ThemeCard( - mode: ThemeMode.light, - icon: UniconsLine.sun, - ), - ThemeCard( - mode: ThemeMode.dark, - icon: UniconsLine.moon, - ) - ], - ), - ], - ), - const SizedBox(height: 16), - - // Api settings - const Text('settings_label_api_host').tr(), - TextFormField( - controller: apiHostFieldController, - decoration: InputDecoration( - border: const UnderlineInputBorder(), - suffixIcon: ElevatedButton( - style: ElevatedButton.styleFrom( - shape: RoundedRectangleBorder( - borderRadius: BorderRadius.circular(6.0), - ), - ), - child: const Icon(UniconsLine.save), - onPressed: () { - saveSettings(); - }, - ), - ), - ), - - const SizedBox(height: 16), - ], - ); - } -} diff --git a/lib/ui/settings/theme_card.dart b/lib/ui/settings/theme_card.dart deleted file mode 100644 index c7f38c7d206f2aa439407dfea478a17e29450c83..0000000000000000000000000000000000000000 --- a/lib/ui/settings/theme_card.dart +++ /dev/null @@ -1,47 +0,0 @@ -import 'package:flutter/material.dart'; -import 'package:flutter_custom_toolbox/flutter_toolbox.dart'; - -import 'package:plotter/cubit/theme_cubit.dart'; - -class ThemeCard extends StatelessWidget { - const ThemeCard({ - super.key, - required this.mode, - required this.icon, - }); - - final IconData icon; - final ThemeMode mode; - - @override - Widget build(BuildContext context) { - return BlocBuilder<ThemeCubit, ThemeModeState>( - builder: (BuildContext context, ThemeModeState state) { - return Card( - elevation: 2, - shadowColor: Theme.of(context).colorScheme.shadow, - color: state.themeMode == mode - ? Theme.of(context).colorScheme.primary - : Theme.of(context).colorScheme.surface, - shape: const RoundedRectangleBorder( - borderRadius: BorderRadius.all(Radius.circular(12)), - ), - margin: const EdgeInsets.all(5), - child: InkWell( - onTap: () => BlocProvider.of<ThemeCubit>(context).getTheme( - ThemeModeState(themeMode: mode), - ), - borderRadius: const BorderRadius.all(Radius.circular(12)), - child: Icon( - icon, - size: 32, - color: state.themeMode != mode - ? Theme.of(context).colorScheme.primary - : Colors.white, - ), - ), - ); - }, - ); - } -} diff --git a/pubspec.lock b/pubspec.lock index 613b6b170e51779624177fae826f71164c5817a6..1ec777c6e784a3a794efde27a31bf135ef379ab6 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -122,11 +122,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 2cf89e1e260ffea7cb290868d81933904569942a..bb9ac3368f15e5231eb74bfd4250e358986a638e 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: A plotter helper application. publish_to: "none" -version: 0.2.0+22 +version: 0.2.1+23 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 http: ^1.1.0