Skip to content

Commit

Permalink
flutter: about: Add flutter version
Browse files Browse the repository at this point in the history
  • Loading branch information
calcitem committed May 27, 2021
1 parent 6c0d6b8 commit 247bd81
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/flutter.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 9 additions & 1 deletion flutter-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@
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

flutter pub get
flutter pub global activate intl_utils
flutter --no-color pub global run intl_utils:generate
flutter create --platforms=windows .
5 changes: 5 additions & 0 deletions flutter-windows-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

./flutter-init.sh

flutter create --platforms=windows .
4 changes: 4 additions & 0 deletions src/ui/flutter_app/lib/l10n/intl_de.arb
Original file line number Diff line number Diff line change
Expand Up @@ -927,5 +927,9 @@
"environmentVariables": "Umgebungsvariablen",
"@environmentVariables": {
"description": "Environment variables"
},
"more": "Mehr",
"@more": {
"description": "More"
}
}
4 changes: 4 additions & 0 deletions src/ui/flutter_app/lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -927,5 +927,9 @@
"environmentVariables": "Environment variables",
"@environmentVariables": {
"description": "Environment variables"
},
"more": "More",
"@more": {
"description": "More"
}
}
3 changes: 2 additions & 1 deletion src/ui/flutter_app/lib/l10n/intl_zh.arb
Original file line number Diff line number Diff line change
Expand Up @@ -231,5 +231,6 @@
"autoReplay": "自动回放",
"atEnd": "已经到底了",
"tapBackAgainToLeave": "再次按返回键退出应用",
"environmentVariables": "环境变量"
"environmentVariables": "环境变量",
"more": "更多"
}
43 changes: 41 additions & 2 deletions src/ui/flutter_app/lib/widgets/about_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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,
Expand All @@ -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),
Expand Down

0 comments on commit 247bd81

Please sign in to comment.