mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
new: edit settings in json
This commit is contained in:
@@ -158,6 +158,12 @@ abstract class S {
|
||||
/// **'Alter url'**
|
||||
String get alterUrl;
|
||||
|
||||
/// No description provided for @atOwnRisk.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'At your own risk !'**
|
||||
String get atOwnRisk;
|
||||
|
||||
/// No description provided for @attention.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
|
||||
@@ -34,6 +34,9 @@ class SDe extends S {
|
||||
@override
|
||||
String get alterUrl => 'Url ändern';
|
||||
|
||||
@override
|
||||
String get atOwnRisk => 'Auf eigene Gefahr !';
|
||||
|
||||
@override
|
||||
String get attention => 'Achtung';
|
||||
|
||||
|
||||
@@ -34,6 +34,9 @@ class SEn extends S {
|
||||
@override
|
||||
String get alterUrl => 'Alter url';
|
||||
|
||||
@override
|
||||
String get atOwnRisk => 'At your own risk !';
|
||||
|
||||
@override
|
||||
String get attention => 'Attention';
|
||||
|
||||
|
||||
@@ -34,6 +34,9 @@ class SId extends S {
|
||||
@override
|
||||
String get alterUrl => 'Alter url';
|
||||
|
||||
@override
|
||||
String get atOwnRisk => 'Dengan risiko Anda sendiri';
|
||||
|
||||
@override
|
||||
String get attention => 'Perhatian';
|
||||
|
||||
|
||||
@@ -34,6 +34,9 @@ class SZh extends S {
|
||||
@override
|
||||
String get alterUrl => '备选链接';
|
||||
|
||||
@override
|
||||
String get atOwnRisk => '如果了解不多,请不要继续!';
|
||||
|
||||
@override
|
||||
String get attention => '注意';
|
||||
|
||||
@@ -754,6 +757,9 @@ class SZhTw extends SZh {
|
||||
@override
|
||||
String get alterUrl => '備選鏈接';
|
||||
|
||||
@override
|
||||
String get atOwnRisk => '如果了解不多,請不要繼續!';
|
||||
|
||||
@override
|
||||
String get attention => '注意';
|
||||
|
||||
|
||||
@@ -43,6 +43,28 @@ enum NetViewType {
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
int toJson() {
|
||||
switch (this) {
|
||||
case NetViewType.conn:
|
||||
return 0;
|
||||
case NetViewType.speed:
|
||||
return 1;
|
||||
case NetViewType.traffic:
|
||||
return 2;
|
||||
}
|
||||
}
|
||||
|
||||
static NetViewType fromJson(int json) {
|
||||
switch (json) {
|
||||
case 0:
|
||||
return NetViewType.conn;
|
||||
case 2:
|
||||
return NetViewType.traffic;
|
||||
default:
|
||||
return NetViewType.speed;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class NetViewData {
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"all": "Alle",
|
||||
"alreadyLastDir": "Bereits im letzten Verzeichnis.",
|
||||
"alterUrl": "Url ändern",
|
||||
"atOwnRisk": "Auf eigene Gefahr !",
|
||||
"attention": "Achtung",
|
||||
"auto": "System folgen",
|
||||
"autoCheckUpdate": "Aktualisierung automatisch prüfen",
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"all": "All",
|
||||
"alreadyLastDir": "Already in last directory.",
|
||||
"alterUrl": "Alter url",
|
||||
"atOwnRisk": "At your own risk !",
|
||||
"attention": "Attention",
|
||||
"auto": "Auto",
|
||||
"autoCheckUpdate": "Auto check update",
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"all": "Semua",
|
||||
"alreadyLastDir": "Sudah di direktori terakhir.",
|
||||
"alterUrl": "Alter url",
|
||||
"atOwnRisk": "Dengan risiko Anda sendiri",
|
||||
"attention": "Perhatian",
|
||||
"auto": "Auto",
|
||||
"autoCheckUpdate": "Periksa pembaruan otomatis",
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"all": "所有",
|
||||
"alreadyLastDir": "已经是最上层目录了",
|
||||
"alterUrl": "备选链接",
|
||||
"atOwnRisk": "如果了解不多,请不要继续!",
|
||||
"attention": "注意",
|
||||
"auto": "自动",
|
||||
"autoCheckUpdate": "自动检查更新",
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
"all": "所有",
|
||||
"alreadyLastDir": "已經是最上層目錄了",
|
||||
"alterUrl": "備選鏈接",
|
||||
"atOwnRisk": "如果了解不多,請不要繼續!",
|
||||
"attention": "注意",
|
||||
"auto": "自動",
|
||||
"autoCheckUpdate": "自動檢查更新",
|
||||
|
||||
@@ -233,36 +233,7 @@ class _HomePageState extends State<HomePage>
|
||||
leading: const Icon(Icons.settings),
|
||||
title: Text(_s.setting),
|
||||
onTap: () => AppRoute.setting().go(context),
|
||||
onLongPress: () async {
|
||||
final map = _setting.toJson();
|
||||
final go = await showRoundDialog(
|
||||
context: context,
|
||||
child: Text(_s.attention),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => context.pop(true),
|
||||
child: Text(
|
||||
_s.ok,
|
||||
style: const TextStyle(color: Colors.red),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
if (go != true) {
|
||||
return;
|
||||
}
|
||||
|
||||
/// Encode [map] to String with indent `\t`
|
||||
final text = const JsonEncoder.withIndent('\t').convert(map);
|
||||
final result = await AppRoute.editor(
|
||||
text: text,
|
||||
langCode: 'json',
|
||||
).go(context);
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
_setting.box.putAll(json.decode(result) as Map<String, dynamic>);
|
||||
},
|
||||
onLongPress: _onLongPressSetting,
|
||||
),
|
||||
ListTile(
|
||||
leading: const Icon(Icons.vpn_key),
|
||||
@@ -383,4 +354,36 @@ class _HomePageState extends State<HomePage>
|
||||
homeWidgetChannel.invokeMethod('update');
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _onLongPressSetting() async {
|
||||
final go = await showRoundDialog(
|
||||
context: context,
|
||||
title: Text(_s.attention),
|
||||
child: Text(_s.atOwnRisk),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () => context.pop(true),
|
||||
child: Text(
|
||||
_s.ok,
|
||||
style: const TextStyle(color: Colors.red),
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
if (go != true) {
|
||||
return;
|
||||
}
|
||||
|
||||
/// Encode [map] to String with indent `\t`
|
||||
final map = _setting.toJson();
|
||||
final text = jsonEncoder.convert(map);
|
||||
final result = await AppRoute.editor(
|
||||
text: text,
|
||||
langCode: 'json',
|
||||
).go(context);
|
||||
if (result == null) {
|
||||
return;
|
||||
}
|
||||
_setting.box.putAll(json.decode(result) as Map<String, dynamic>);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +194,8 @@ class _SettingPageState extends State<SettingPage> {
|
||||
_buildFont(),
|
||||
_buildTermFontSize(),
|
||||
_buildSSHVirtualKeyAutoOff(),
|
||||
_buildKeyboardType(),
|
||||
// Use hardware keyboard on desktop, so there is no need to set it
|
||||
if (isMobile) _buildKeyboardType(),
|
||||
_buildSSHVirtKeys(),
|
||||
_buildSftpRmrfDir(),
|
||||
].map((e) => RoundRectCard(e)).toList(),
|
||||
|
||||
Reference in New Issue
Block a user