flutter: about: Add flutter version

This commit is contained in:
Calcitem 2021-05-28 00:27:11 +08:00
parent 6c0d6b8a7f
commit 247bd81280
8 changed files with 67 additions and 6 deletions

View File

@ -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

View File

@ -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
./flutter-windows-init.sh

View File

@ -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<String, String> 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 .

5
flutter-windows-init.sh Normal file
View File

@ -0,0 +1,5 @@
#!/bin/bash
./flutter-init.sh
flutter create --platforms=windows .

View File

@ -927,5 +927,9 @@
"environmentVariables": "Umgebungsvariablen",
"@environmentVariables": {
"description": "Environment variables"
},
"more": "Mehr",
"@more": {
"description": "More"
}
}

View File

@ -927,5 +927,9 @@
"environmentVariables": "Environment variables",
"@environmentVariables": {
"description": "Environment variables"
},
"more": "More",
"@more": {
"description": "More"
}
}

View File

@ -231,5 +231,6 @@
"autoReplay": "自动回放",
"atEnd": "已经到底了",
"tapBackAgainToLeave": "再次按返回键退出应用",
"environmentVariables": "环境变量"
"environmentVariables": "环境变量",
"more": "更多"
}

View File

@ -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<AboutPage> {
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<AboutPage> {
),
],
),
actions: <Widget>[
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: <Widget>[
Text(
"${flutterVersion.toString().replaceAll('{', '').replaceAll('}', '').replaceAll(', ', '\n')}",
),
],
),
actions: <Widget>[
TextButton(
child: Text(S.of(context).ok),