mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 15:24:35 +01:00
new: edit settings in json
This commit is contained in:
@@ -158,6 +158,12 @@ abstract class S {
|
|||||||
/// **'Alter url'**
|
/// **'Alter url'**
|
||||||
String get alterUrl;
|
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.
|
/// No description provided for @attention.
|
||||||
///
|
///
|
||||||
/// In en, this message translates to:
|
/// In en, this message translates to:
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ class SDe extends S {
|
|||||||
@override
|
@override
|
||||||
String get alterUrl => 'Url ändern';
|
String get alterUrl => 'Url ändern';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get atOwnRisk => 'Auf eigene Gefahr !';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get attention => 'Achtung';
|
String get attention => 'Achtung';
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ class SEn extends S {
|
|||||||
@override
|
@override
|
||||||
String get alterUrl => 'Alter url';
|
String get alterUrl => 'Alter url';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get atOwnRisk => 'At your own risk !';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get attention => 'Attention';
|
String get attention => 'Attention';
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ class SId extends S {
|
|||||||
@override
|
@override
|
||||||
String get alterUrl => 'Alter url';
|
String get alterUrl => 'Alter url';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get atOwnRisk => 'Dengan risiko Anda sendiri';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get attention => 'Perhatian';
|
String get attention => 'Perhatian';
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ class SZh extends S {
|
|||||||
@override
|
@override
|
||||||
String get alterUrl => '备选链接';
|
String get alterUrl => '备选链接';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get atOwnRisk => '如果了解不多,请不要继续!';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get attention => '注意';
|
String get attention => '注意';
|
||||||
|
|
||||||
@@ -754,6 +757,9 @@ class SZhTw extends SZh {
|
|||||||
@override
|
@override
|
||||||
String get alterUrl => '備選鏈接';
|
String get alterUrl => '備選鏈接';
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get atOwnRisk => '如果了解不多,請不要繼續!';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String get attention => '注意';
|
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 {
|
class NetViewData {
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
"all": "Alle",
|
"all": "Alle",
|
||||||
"alreadyLastDir": "Bereits im letzten Verzeichnis.",
|
"alreadyLastDir": "Bereits im letzten Verzeichnis.",
|
||||||
"alterUrl": "Url ändern",
|
"alterUrl": "Url ändern",
|
||||||
|
"atOwnRisk": "Auf eigene Gefahr !",
|
||||||
"attention": "Achtung",
|
"attention": "Achtung",
|
||||||
"auto": "System folgen",
|
"auto": "System folgen",
|
||||||
"autoCheckUpdate": "Aktualisierung automatisch prüfen",
|
"autoCheckUpdate": "Aktualisierung automatisch prüfen",
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
"all": "All",
|
"all": "All",
|
||||||
"alreadyLastDir": "Already in last directory.",
|
"alreadyLastDir": "Already in last directory.",
|
||||||
"alterUrl": "Alter url",
|
"alterUrl": "Alter url",
|
||||||
|
"atOwnRisk": "At your own risk !",
|
||||||
"attention": "Attention",
|
"attention": "Attention",
|
||||||
"auto": "Auto",
|
"auto": "Auto",
|
||||||
"autoCheckUpdate": "Auto check update",
|
"autoCheckUpdate": "Auto check update",
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
"all": "Semua",
|
"all": "Semua",
|
||||||
"alreadyLastDir": "Sudah di direktori terakhir.",
|
"alreadyLastDir": "Sudah di direktori terakhir.",
|
||||||
"alterUrl": "Alter url",
|
"alterUrl": "Alter url",
|
||||||
|
"atOwnRisk": "Dengan risiko Anda sendiri",
|
||||||
"attention": "Perhatian",
|
"attention": "Perhatian",
|
||||||
"auto": "Auto",
|
"auto": "Auto",
|
||||||
"autoCheckUpdate": "Periksa pembaruan otomatis",
|
"autoCheckUpdate": "Periksa pembaruan otomatis",
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
"all": "所有",
|
"all": "所有",
|
||||||
"alreadyLastDir": "已经是最上层目录了",
|
"alreadyLastDir": "已经是最上层目录了",
|
||||||
"alterUrl": "备选链接",
|
"alterUrl": "备选链接",
|
||||||
|
"atOwnRisk": "如果了解不多,请不要继续!",
|
||||||
"attention": "注意",
|
"attention": "注意",
|
||||||
"auto": "自动",
|
"auto": "自动",
|
||||||
"autoCheckUpdate": "自动检查更新",
|
"autoCheckUpdate": "自动检查更新",
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
"all": "所有",
|
"all": "所有",
|
||||||
"alreadyLastDir": "已經是最上層目錄了",
|
"alreadyLastDir": "已經是最上層目錄了",
|
||||||
"alterUrl": "備選鏈接",
|
"alterUrl": "備選鏈接",
|
||||||
|
"atOwnRisk": "如果了解不多,請不要繼續!",
|
||||||
"attention": "注意",
|
"attention": "注意",
|
||||||
"auto": "自動",
|
"auto": "自動",
|
||||||
"autoCheckUpdate": "自動檢查更新",
|
"autoCheckUpdate": "自動檢查更新",
|
||||||
|
|||||||
@@ -233,36 +233,7 @@ class _HomePageState extends State<HomePage>
|
|||||||
leading: const Icon(Icons.settings),
|
leading: const Icon(Icons.settings),
|
||||||
title: Text(_s.setting),
|
title: Text(_s.setting),
|
||||||
onTap: () => AppRoute.setting().go(context),
|
onTap: () => AppRoute.setting().go(context),
|
||||||
onLongPress: () async {
|
onLongPress: _onLongPressSetting,
|
||||||
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>);
|
|
||||||
},
|
|
||||||
),
|
),
|
||||||
ListTile(
|
ListTile(
|
||||||
leading: const Icon(Icons.vpn_key),
|
leading: const Icon(Icons.vpn_key),
|
||||||
@@ -383,4 +354,36 @@ class _HomePageState extends State<HomePage>
|
|||||||
homeWidgetChannel.invokeMethod('update');
|
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(),
|
_buildFont(),
|
||||||
_buildTermFontSize(),
|
_buildTermFontSize(),
|
||||||
_buildSSHVirtualKeyAutoOff(),
|
_buildSSHVirtualKeyAutoOff(),
|
||||||
_buildKeyboardType(),
|
// Use hardware keyboard on desktop, so there is no need to set it
|
||||||
|
if (isMobile) _buildKeyboardType(),
|
||||||
_buildSSHVirtKeys(),
|
_buildSSHVirtKeys(),
|
||||||
_buildSftpRmrfDir(),
|
_buildSftpRmrfDir(),
|
||||||
].map((e) => RoundRectCard(e)).toList(),
|
].map((e) => RoundRectCard(e)).toList(),
|
||||||
|
|||||||
Reference in New Issue
Block a user