From c17bcc8dca5f3c3655888697a9a6e766ede22b8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beno=C3=AEt=20Harrault?= <benoit@harrault.fr> Date: Sat, 4 May 2024 14:29:18 +0200 Subject: [PATCH] Add "about" minimal page --- android/gradle.properties | 4 +- assets/translations/en.json | 7 +- assets/translations/fr.json | 7 +- .../metadata/android/en-US/changelogs/71.txt | 1 + .../metadata/android/fr-FR/changelogs/71.txt | 1 + lib/config/menu.dart | 9 +++ lib/cubit/nav_cubit.dart | 12 ++-- lib/ui/screens/about_page.dart | 41 ++++++++++++ lib/ui/widgets/global_app_bar.dart | 13 +++- pubspec.lock | 64 +++++++++++++++++++ pubspec.yaml | 3 +- 11 files changed, 150 insertions(+), 12 deletions(-) create mode 100644 fastlane/metadata/android/en-US/changelogs/71.txt create mode 100644 fastlane/metadata/android/fr-FR/changelogs/71.txt create mode 100644 lib/ui/screens/about_page.dart diff --git a/android/gradle.properties b/android/gradle.properties index 4f6eb84..de61e66 100644 --- a/android/gradle.properties +++ b/android/gradle.properties @@ -1,5 +1,5 @@ org.gradle.jvmargs=-Xmx1536M android.useAndroidX=true android.enableJetifier=true -app.versionName=0.1.21 -app.versionCode=70 +app.versionName=0.1.22 +app.versionCode=71 diff --git a/assets/translations/en.json b/assets/translations/en.json index 0047e08..fc87804 100644 --- a/assets/translations/en.json +++ b/assets/translations/en.json @@ -3,7 +3,12 @@ "bottom_nav_game": "Game", "bottom_nav_settings": "Settings", + "bottom_nav_about": "About", "settings_title": "Settings", - "settings_label_theme": "Theme mode" + "settings_label_theme": "Theme mode", + + "about_title": "About", + "about_content": "Simple Sudoku Game. Easy to play, easy to enjoy.", + "about_version": "Version: {version}" } diff --git a/assets/translations/fr.json b/assets/translations/fr.json index 80f4637..64b3b73 100644 --- a/assets/translations/fr.json +++ b/assets/translations/fr.json @@ -3,7 +3,12 @@ "bottom_nav_game": "Jeu", "bottom_nav_settings": "Réglages", + "bottom_nav_about": "Infos", "settings_title": "Réglages", - "settings_label_theme": "Thème de couleurs" + "settings_label_theme": "Thème de couleurs", + + "about_title": "Informations", + "about_content": "Jeu de Sudoku simple, facile à jouer, facile à apprécier.", + "about_version": "Version : {version}" } diff --git a/fastlane/metadata/android/en-US/changelogs/71.txt b/fastlane/metadata/android/en-US/changelogs/71.txt new file mode 100644 index 0000000..f11954c --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/71.txt @@ -0,0 +1 @@ +Add "about" minimal page. diff --git a/fastlane/metadata/android/fr-FR/changelogs/71.txt b/fastlane/metadata/android/fr-FR/changelogs/71.txt new file mode 100644 index 0000000..2e02a22 --- /dev/null +++ b/fastlane/metadata/android/fr-FR/changelogs/71.txt @@ -0,0 +1 @@ +Ajout d'une page "informations" minimale. diff --git a/lib/config/menu.dart b/lib/config/menu.dart index a21c528..c092272 100644 --- a/lib/config/menu.dart +++ b/lib/config/menu.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:unicons/unicons.dart'; +import 'package:sudoku/ui/screens/about_page.dart'; import 'package:sudoku/ui/screens/game_page.dart'; import 'package:sudoku/ui/screens/settings_page.dart'; @@ -31,9 +32,17 @@ class Menu { page: SettingsPage(), ); + static const indexAbout = 2; + static const menuItemAbout = MenuItem( + code: 'bottom_nav_about', + icon: Icon(UniconsLine.info_circle), + page: AboutPage(), + ); + static Map<int, MenuItem> items = { indexGame: menuItemGame, indexSettings: menuItemSettings, + indexAbout: menuItemAbout, }; static bool isIndexAllowed(int pageIndex) { diff --git a/lib/cubit/nav_cubit.dart b/lib/cubit/nav_cubit.dart index 845ecc2..dda1a09 100644 --- a/lib/cubit/nav_cubit.dart +++ b/lib/cubit/nav_cubit.dart @@ -17,12 +17,12 @@ class NavCubit extends HydratedCubit<int> { emit(Menu.indexGame); } - void switchToSettingsPage() { - if (state != Menu.indexSettings) { - emit(Menu.indexSettings); - } else { - goToGamePage(); - } + void goToSettingsPage() { + emit(Menu.indexSettings); + } + + void goToAboutPage() { + emit(Menu.indexAbout); } @override diff --git a/lib/ui/screens/about_page.dart b/lib/ui/screens/about_page.dart new file mode 100644 index 0000000..ca78fa0 --- /dev/null +++ b/lib/ui/screens/about_page.dart @@ -0,0 +1,41 @@ +import 'package:easy_localization/easy_localization.dart'; +import 'package:flutter/material.dart'; +import 'package:package_info_plus/package_info_plus.dart'; + +import 'package:sudoku/ui/widgets/header_app.dart'; + +class AboutPage extends StatelessWidget { + const AboutPage({super.key}); + + @override + Widget build(BuildContext context) { + return Padding( + padding: const EdgeInsets.symmetric(horizontal: 8), + child: Column( + mainAxisAlignment: MainAxisAlignment.start, + crossAxisAlignment: CrossAxisAlignment.start, + mainAxisSize: MainAxisSize.max, + children: <Widget>[ + const SizedBox(height: 8), + const AppHeader(text: 'about_title'), + const Text('about_content').tr(), + FutureBuilder<PackageInfo>( + future: PackageInfo.fromPlatform(), + builder: (context, snapshot) { + switch (snapshot.connectionState) { + case ConnectionState.done: + return const Text('about_version').tr( + namedArgs: { + 'version': snapshot.data!.version, + }, + ); + default: + return const SizedBox(); + } + }, + ), + ], + ), + ); + } +} diff --git a/lib/ui/widgets/global_app_bar.dart b/lib/ui/widgets/global_app_bar.dart index 22cccc1..7a4df12 100644 --- a/lib/ui/widgets/global_app_bar.dart +++ b/lib/ui/widgets/global_app_bar.dart @@ -106,13 +106,24 @@ class GlobalAppBar extends StatelessWidget implements PreferredSizeWidget { // go to Settings page menuActions.add(ElevatedButton( onPressed: () { - context.read<NavCubit>().switchToSettingsPage(); + context.read<NavCubit>().goToSettingsPage(); }, style: ElevatedButton.styleFrom( shape: const CircleBorder(), ), child: Menu.menuItemSettings.icon, )); + + // go to About page + menuActions.add(ElevatedButton( + onPressed: () { + context.read<NavCubit>().goToAboutPage(); + }, + style: ElevatedButton.styleFrom( + shape: const CircleBorder(), + ), + child: Menu.menuItemAbout.icon, + )); } else { // back to Home page menuActions.add(ElevatedButton( diff --git a/pubspec.lock b/pubspec.lock index b35bc75..5b7acc5 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -9,6 +9,14 @@ packages: url: "https://pub.dev" source: hosted version: "2.5.0" + async: + dependency: transitive + description: + name: async + sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c" + url: "https://pub.dev" + source: hosted + version: "2.11.0" badges: dependency: "direct main" description: @@ -136,6 +144,22 @@ packages: url: "https://pub.dev" source: hosted version: "2.2.3" + http: + dependency: transitive + description: + name: http + sha256: "761a297c042deedc1ffbb156d6e2af13886bb305c2a343a4d972504cd67dd938" + url: "https://pub.dev" + source: hosted + version: "1.2.1" + http_parser: + dependency: transitive + description: + name: http_parser + sha256: "2aa08ce0341cc9b354a498388e30986515406668dbcc4f7c950c3e715496693b" + url: "https://pub.dev" + source: hosted + version: "4.0.2" hydrated_bloc: dependency: "direct main" description: @@ -184,6 +208,22 @@ packages: url: "https://pub.dev" source: hosted version: "1.0.0" + package_info_plus: + dependency: "direct main" + description: + name: package_info_plus + sha256: b93d8b4d624b4ea19b0a5a208b2d6eff06004bc3ce74c06040b120eeadd00ce0 + url: "https://pub.dev" + source: hosted + version: "8.0.0" + package_info_plus_platform_interface: + dependency: transitive + description: + name: package_info_plus_platform_interface + sha256: f49918f3433a3146047372f9d4f1f847511f2acd5cd030e1f44fe5a50036b70e + url: "https://pub.dev" + source: hosted + version: "3.0.0" path: dependency: transitive description: @@ -325,6 +365,22 @@ packages: description: flutter source: sdk version: "0.0.99" + source_span: + dependency: transitive + description: + name: source_span + sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c" + url: "https://pub.dev" + source: hosted + version: "1.10.0" + string_scanner: + dependency: transitive + description: + name: string_scanner + sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde" + url: "https://pub.dev" + source: hosted + version: "1.2.0" synchronized: dependency: transitive description: @@ -333,6 +389,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.1.0+1" + term_glyph: + dependency: transitive + description: + name: term_glyph + sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84 + url: "https://pub.dev" + source: hosted + version: "1.2.1" typed_data: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index d71e600..e76a641 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -3,7 +3,7 @@ description: A sudoku game application. publish_to: "none" -version: 0.1.21+70 +version: 0.1.22+71 environment: sdk: "^3.0.0" @@ -18,6 +18,7 @@ dependencies: flutter_bloc: ^8.1.1 hive: ^2.2.3 hydrated_bloc: ^9.0.0 + package_info_plus: ^8.0.0 path_provider: ^2.0.11 unicons: ^2.1.1 -- GitLab