From 247bd81280c322fa5907f74759da5983d6cb8ea1 Mon Sep 17 00:00:00 2001 From: Calcitem Date: Fri, 28 May 2021 00:27:11 +0800 Subject: [PATCH] flutter: about: Add flutter version --- .github/workflows/flutter.yml | 2 +- clean.sh | 2 +- flutter-init.sh | 10 ++++- flutter-windows-init.sh | 5 +++ src/ui/flutter_app/lib/l10n/intl_de.arb | 4 ++ src/ui/flutter_app/lib/l10n/intl_en.arb | 4 ++ src/ui/flutter_app/lib/l10n/intl_zh.arb | 3 +- .../flutter_app/lib/widgets/about_page.dart | 43 ++++++++++++++++++- 8 files changed, 67 insertions(+), 6 deletions(-) create mode 100644 flutter-windows-init.sh diff --git a/.github/workflows/flutter.yml b/.github/workflows/flutter.yml index 0a9c1355..74d6e98d 100644 --- a/.github/workflows/flutter.yml +++ b/.github/workflows/flutter.yml @@ -39,7 +39,7 @@ jobs: run: flutter --version - name: Install dependencies - run: cd src/ui/flutter_app; flutter pub get; flutter pub global activate intl_utils; flutter --no-color pub global run intl_utils:generate + run: bash -x ./flutter-init.sh # Uncomment this step to verify the use of 'dart format' on each commit. # - name: Verify formatting diff --git a/clean.sh b/clean.sh index b7ff14ac..493dcbf0 100644 --- a/clean.sh +++ b/clean.sh @@ -8,4 +8,4 @@ git clean -fdx mv ../key.jks src/ui/flutter_app/android/ mv ../key.properties src/ui/flutter_app/android/ -./flutter-init.sh \ No newline at end of file +./flutter-windows-init.sh diff --git a/flutter-init.sh b/flutter-init.sh index ce4559e4..9e45785f 100644 --- a/flutter-init.sh +++ b/flutter-init.sh @@ -3,8 +3,17 @@ ENV_FILE_PATH=assets/files ENV_FILE=$ENV_FILE_PATH/environment_variables.txt +GEN_FILE_PATH=lib/generated +FLUTTER_VERSION_FILE=$GEN_FILE_PATH/flutter_version.dart + cd src/ui/flutter_app || exit +mkdir -p $GEN_FILE_PATH || true + +echo "const Map flutterVersion =" > $FLUTTER_VERSION_FILE +flutter --version --machine >> $FLUTTER_VERSION_FILE +echo ";" >> $FLUTTER_VERSION_FILE + mkdir -p $ENV_FILE_PATH || true touch $ENV_FILE export > $ENV_FILE @@ -12,4 +21,3 @@ export > $ENV_FILE flutter pub get flutter pub global activate intl_utils flutter --no-color pub global run intl_utils:generate -flutter create --platforms=windows . diff --git a/flutter-windows-init.sh b/flutter-windows-init.sh new file mode 100644 index 00000000..0eaac056 --- /dev/null +++ b/flutter-windows-init.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +./flutter-init.sh + +flutter create --platforms=windows . diff --git a/src/ui/flutter_app/lib/l10n/intl_de.arb b/src/ui/flutter_app/lib/l10n/intl_de.arb index adfc9b8c..24ad01dc 100644 --- a/src/ui/flutter_app/lib/l10n/intl_de.arb +++ b/src/ui/flutter_app/lib/l10n/intl_de.arb @@ -927,5 +927,9 @@ "environmentVariables": "Umgebungsvariablen", "@environmentVariables": { "description": "Environment variables" + }, + "more": "Mehr", + "@more": { + "description": "More" } } diff --git a/src/ui/flutter_app/lib/l10n/intl_en.arb b/src/ui/flutter_app/lib/l10n/intl_en.arb index 4155b9b6..b3f647b9 100644 --- a/src/ui/flutter_app/lib/l10n/intl_en.arb +++ b/src/ui/flutter_app/lib/l10n/intl_en.arb @@ -927,5 +927,9 @@ "environmentVariables": "Environment variables", "@environmentVariables": { "description": "Environment variables" + }, + "more": "More", + "@more": { + "description": "More" } } diff --git a/src/ui/flutter_app/lib/l10n/intl_zh.arb b/src/ui/flutter_app/lib/l10n/intl_zh.arb index c1fda2f4..a11ae0cd 100644 --- a/src/ui/flutter_app/lib/l10n/intl_zh.arb +++ b/src/ui/flutter_app/lib/l10n/intl_zh.arb @@ -231,5 +231,6 @@ "autoReplay": "自动回放", "atEnd": "已经到底了", "tapBackAgainToLeave": "再次按返回键退出应用", - "environmentVariables": "环境变量" + "environmentVariables": "环境变量", + "more": "更多" } \ No newline at end of file diff --git a/src/ui/flutter_app/lib/widgets/about_page.dart b/src/ui/flutter_app/lib/widgets/about_page.dart index ad5a0479..64416c46 100644 --- a/src/ui/flutter_app/lib/widgets/about_page.dart +++ b/src/ui/flutter_app/lib/widgets/about_page.dart @@ -22,6 +22,7 @@ import 'package:devicelocale/devicelocale.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:package_info_plus/package_info_plus.dart'; +import 'package:sanmill/generated/flutter_version.dart'; import 'package:sanmill/generated/l10n.dart'; import 'package:sanmill/style/app_theme.dart'; import 'package:sanmill/widgets/settings_list_tile.dart'; @@ -251,11 +252,11 @@ class _AboutPageState extends State { showDialog( context: context, barrierDismissible: true, - builder: (context) => alertDialog(context), + builder: (context) => versionDialog(context), ); } - AlertDialog alertDialog(BuildContext context) { + AlertDialog versionDialog(BuildContext context) { return AlertDialog( title: Text( S.of(context).appName, @@ -276,6 +277,44 @@ class _AboutPageState extends State { ), ], ), + actions: [ + TextButton( + child: Text(S.of(context).more), + onPressed: () => _showFlutterVersionInfo(), + ), + TextButton( + child: Text(S.of(context).ok), + onPressed: () => Navigator.of(context).pop(), + ), + ], + ); + } + + _showFlutterVersionInfo() { + Navigator.of(context).pop(); + + showDialog( + context: context, + barrierDismissible: true, + builder: (context) => flutterVersionDialog(context), + ); + } + + AlertDialog flutterVersionDialog(BuildContext context) { + return AlertDialog( + title: Text( + S.of(context).more, + style: TextStyle(color: AppTheme.dialogTitleColor), + ), + content: Column( + mainAxisSize: MainAxisSize.min, + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text( + "${flutterVersion.toString().replaceAll('{', '').replaceAll('}', '').replaceAll(', ', '\n')}", + ), + ], + ), actions: [ TextButton( child: Text(S.of(context).ok),