flutter: dev_mode: Add Environment Variables Page

This commit is contained in:
Calcitem 2021-05-27 23:35:37 +08:00
parent 4e1b2e51d6
commit 6c0d6b8a7f
7 changed files with 93 additions and 2 deletions

View File

@ -1,6 +1,14 @@
#!/bin/bash
ENV_FILE_PATH=assets/files
ENV_FILE=$ENV_FILE_PATH/environment_variables.txt
cd src/ui/flutter_app || exit
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

View File

@ -923,5 +923,9 @@
"tapBackAgainToLeave": "Nochmal drücken um zu Beenden.",
"@tapBackAgainToLeave": {
"description": "Tap back again to leave."
},
"environmentVariables": "Umgebungsvariablen",
"@environmentVariables": {
"description": "Environment variables"
}
}

View File

@ -923,5 +923,9 @@
"tapBackAgainToLeave": "Tap back again to leave.",
"@tapBackAgainToLeave": {
"description": "Tap back again to leave."
},
"environmentVariables": "Environment variables",
"@environmentVariables": {
"description": "Environment variables"
}
}

View File

@ -230,5 +230,6 @@
"aiIsNotThinking": "电脑并非正在思考中",
"autoReplay": "自动回放",
"atEnd": "已经到底了",
"tapBackAgainToLeave": "再次按返回键退出应用"
"tapBackAgainToLeave": "再次按返回键退出应用",
"environmentVariables": "环境变量"
}

View File

@ -0,0 +1,59 @@
/*
This file is part of Sanmill.
Copyright (C) 2019-2021 The Sanmill developers (see AUTHORS file)
Sanmill is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Sanmill is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import 'package:flutter/material.dart';
import 'package:flutter/services.dart' show rootBundle;
import 'package:sanmill/generated/l10n.dart';
class EnvironmentVariablesPage extends StatefulWidget {
@override
_EnvironmentVariablesPageState createState() => _EnvironmentVariablesPageState();
}
class _EnvironmentVariablesPageState extends State<EnvironmentVariablesPage> {
String _data = "";
Future<void> _loadData() async {
final _loadedData =
await rootBundle.loadString('assets/files/environment_variables.txt');
setState(() {
_data = _loadedData;
});
}
@override
Widget build(BuildContext context) {
_loadData();
return Scaffold(
appBar: AppBar(title: Text(S.of(context).environmentVariables), centerTitle: true),
body: ListView(
children: <Widget>[
Container(
padding: const EdgeInsets.only(
top: 16, left: 16, right: 16, bottom: 16),
child: Text(
_data != "" ? _data : 'Nothing to show',
style: TextStyle(fontFamily: 'Monospace', fontSize: 12),
textAlign: TextAlign.left,
))
],
),
);
}
}

View File

@ -29,6 +29,7 @@ import 'package:sanmill/widgets/settings_list_tile.dart';
import 'package:sanmill/widgets/settings_switch_list_tile.dart';
import 'dialog.dart';
import 'env_page.dart';
import 'list_item_divider.dart';
class Developer {
@ -264,7 +265,20 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
value: Config.isAutoRestart,
onChanged: setIsAutoRestart,
titleString: S.of(context).isAutoRestart,
)
),
ListItemDivider(),
SettingsListTile(
context: context,
titleString: S.of(context).environmentVariables,
onTap: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => EnvironmentVariablesPage(),
),
);
},
),
],
)
: SizedBox(height: 1),

View File

@ -37,6 +37,7 @@ flutter:
assets:
- assets/licenses/GPL-3.0.txt
- assets/files/environment_variables.txt
- assets/audios/draw.mp3
- assets/audios/fly.mp3
- assets/audios/go.mp3