feat: auto locale
This commit is contained in:
@@ -5,6 +5,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:winui_n2n/edge_state.dart';
|
||||
import 'package:winui_n2n/saved_connection.dart';
|
||||
import 'package:winui_n2n/shared_pref_singleton.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
TextEditingController _supernodeController = TextEditingController();
|
||||
TextEditingController _communityController = TextEditingController();
|
||||
@@ -43,9 +44,9 @@ class _ControlPageState extends State<ControlPage> {
|
||||
width: 300,
|
||||
child: TextField(
|
||||
controller: _supernodeController,
|
||||
decoration: const InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: '主服务器',
|
||||
decoration: InputDecoration(
|
||||
border: const OutlineInputBorder(),
|
||||
labelText: AppLocalizations.of(context)!.n2nSuperNode,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -56,9 +57,9 @@ class _ControlPageState extends State<ControlPage> {
|
||||
width: 300,
|
||||
child: TextField(
|
||||
controller: _communityController,
|
||||
decoration: const InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: '网络社区',
|
||||
decoration: InputDecoration(
|
||||
border: const OutlineInputBorder(),
|
||||
labelText: AppLocalizations.of(context)!.n2nCommunity,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -70,9 +71,9 @@ class _ControlPageState extends State<ControlPage> {
|
||||
child: TextField(
|
||||
controller: _keyController,
|
||||
obscureText: true,
|
||||
decoration: const InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: '社区密码',
|
||||
decoration: InputDecoration(
|
||||
border: const OutlineInputBorder(),
|
||||
labelText: AppLocalizations.of(context)!.n2nCommunityKey,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -83,9 +84,9 @@ class _ControlPageState extends State<ControlPage> {
|
||||
width: 300,
|
||||
child: TextField(
|
||||
controller: _selfAddressController,
|
||||
decoration: const InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: '我的地址',
|
||||
decoration: InputDecoration(
|
||||
border: const OutlineInputBorder(),
|
||||
labelText: AppLocalizations.of(context)!.n2nSelfAddress,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -109,9 +110,10 @@ class _ControlPageState extends State<ControlPage> {
|
||||
width: 350,
|
||||
child: TextField(
|
||||
controller: _configNameController,
|
||||
decoration: const InputDecoration(
|
||||
border: OutlineInputBorder(),
|
||||
labelText: '给这个配置备注一个名字',
|
||||
decoration: InputDecoration(
|
||||
border: const OutlineInputBorder(),
|
||||
labelText: AppLocalizations.of(context)!
|
||||
.configNameComment,
|
||||
),
|
||||
),
|
||||
),
|
||||
@@ -147,13 +149,15 @@ class _ControlPageState extends State<ControlPage> {
|
||||
Navigator.pop(context);
|
||||
return;
|
||||
},
|
||||
child: const Text('保存')),
|
||||
child:
|
||||
Text(AppLocalizations.of(context)!.save)),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
return;
|
||||
},
|
||||
child: const Text('取消'),
|
||||
child:
|
||||
Text(AppLocalizations.of(context)!.cancel),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -162,7 +166,7 @@ class _ControlPageState extends State<ControlPage> {
|
||||
),
|
||||
),
|
||||
),
|
||||
child: const Text('保存配置'),
|
||||
child: Text(AppLocalizations.of(context)!.saveConfig),
|
||||
),
|
||||
ElevatedButton(
|
||||
onPressed: _edgeConnecting
|
||||
@@ -293,8 +297,8 @@ class _ControlPageState extends State<ControlPage> {
|
||||
}
|
||||
},
|
||||
child: EdgeState.instance.isRunning
|
||||
? const Text('断开连接')
|
||||
: const Text('开始连接'),
|
||||
? Text(AppLocalizations.of(context)!.disconnect)
|
||||
: Text(AppLocalizations.of(context)!.connect),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
@@ -365,7 +369,8 @@ class _ControlPageState extends State<ControlPage> {
|
||||
Navigator.pop(context);
|
||||
return;
|
||||
},
|
||||
child: const Text('使用'),
|
||||
child:
|
||||
Text(AppLocalizations.of(context)!.use),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
@@ -404,14 +409,16 @@ class _ControlPageState extends State<ControlPage> {
|
||||
return;
|
||||
});
|
||||
},
|
||||
child: const Text('删除'),
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.delete),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.pop(context);
|
||||
return;
|
||||
},
|
||||
child: const Text('取消'),
|
||||
child: Text(
|
||||
AppLocalizations.of(context)!.cancel),
|
||||
),
|
||||
],
|
||||
),
|
||||
@@ -421,7 +428,7 @@ class _ControlPageState extends State<ControlPage> {
|
||||
),
|
||||
);
|
||||
},
|
||||
child: const Text('使用配置')),
|
||||
child: Text(AppLocalizations.of(context)!.useConfig)),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@@ -4,6 +4,7 @@ import 'package:winui_n2n/about_page.dart';
|
||||
import 'package:winui_n2n/logger_page.dart';
|
||||
import 'package:winui_n2n/main.dart';
|
||||
import 'package:winui_n2n/setting_page.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
class HomePage extends StatefulWidget {
|
||||
const HomePage({super.key});
|
||||
@@ -62,26 +63,26 @@ class _HomePageState extends State<HomePage> {
|
||||
),
|
||||
),
|
||||
),
|
||||
destinations: const <NavigationRailDestination>[
|
||||
destinations: <NavigationRailDestination>[
|
||||
NavigationRailDestination(
|
||||
icon: Icon(Icons.favorite_border),
|
||||
selectedIcon: Icon(Icons.favorite),
|
||||
label: Text('主页'),
|
||||
icon: const Icon(Icons.favorite_border),
|
||||
selectedIcon: const Icon(Icons.favorite),
|
||||
label: Text(AppLocalizations.of(context)!.mainPage),
|
||||
),
|
||||
NavigationRailDestination(
|
||||
icon: Icon(Icons.bookmark_border),
|
||||
selectedIcon: Icon(Icons.book),
|
||||
label: Text('关于'),
|
||||
icon: const Icon(Icons.bookmark_border),
|
||||
selectedIcon: const Icon(Icons.book),
|
||||
label: Text(AppLocalizations.of(context)!.aboutPage),
|
||||
),
|
||||
NavigationRailDestination(
|
||||
icon: Icon(Icons.pause_circle_filled),
|
||||
selectedIcon: Icon(Icons.pause_circle),
|
||||
label: Text('日志'),
|
||||
icon: const Icon(Icons.pause_circle_filled),
|
||||
selectedIcon: const Icon(Icons.pause_circle),
|
||||
label: Text(AppLocalizations.of(context)!.logPage),
|
||||
),
|
||||
NavigationRailDestination(
|
||||
icon: Icon(Icons.star_border),
|
||||
selectedIcon: Icon(Icons.star),
|
||||
label: Text('设置'),
|
||||
icon: const Icon(Icons.star_border),
|
||||
selectedIcon: const Icon(Icons.star),
|
||||
label: Text(AppLocalizations.of(context)!.settingsPage),
|
||||
),
|
||||
],
|
||||
),
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:winui_n2n/shared_pref_singleton.dart';
|
||||
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
|
||||
|
||||
class SettingPage extends StatefulWidget {
|
||||
const SettingPage({super.key});
|
||||
@@ -17,7 +18,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
children: [
|
||||
const Text('自动设置防火墙'),
|
||||
Text(AppLocalizations.of(context)!.autoFirewall),
|
||||
Switch(
|
||||
value: SharedPrefSingleton().autoFirewall,
|
||||
onChanged: (value) {
|
||||
@@ -34,13 +35,13 @@ class _SettingPageState extends State<SettingPage> {
|
||||
ScaffoldMessenger.of(context)
|
||||
..removeCurrentSnackBar()
|
||||
..showSnackBar(
|
||||
const SnackBar(
|
||||
content: Text('功能暂未开发, 敬请期待~'),
|
||||
duration: Duration(seconds: 2),
|
||||
SnackBar(
|
||||
content: Text(AppLocalizations.of(context)!.notImplement),
|
||||
duration: const Duration(seconds: 2),
|
||||
),
|
||||
);
|
||||
},
|
||||
child: const Text('检查更新'),
|
||||
child: Text(AppLocalizations.of(context)!.checkUpdate),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
Reference in New Issue
Block a user