mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2026-01-31 13:25:10 +01:00
opt.: settings
This commit is contained in:
@@ -8,6 +8,13 @@ const _interactiveStates = <MaterialState>{
|
||||
};
|
||||
|
||||
extension ColorX on Color {
|
||||
String get toHex {
|
||||
final redStr = red.toRadixString(16).padLeft(2, '0');
|
||||
final greenStr = green.toRadixString(16).padLeft(2, '0');
|
||||
final blueStr = blue.toRadixString(16).padLeft(2, '0');
|
||||
return '#$redStr$greenStr$blueStr';
|
||||
}
|
||||
|
||||
bool get isBrightColor {
|
||||
return getBrightnessFromColor == Brightness.light;
|
||||
}
|
||||
|
||||
@@ -4,6 +4,16 @@ import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
extension StringX on String {
|
||||
/// Format: `#8b2252` or `8b2252`
|
||||
Color? get hexToColor {
|
||||
final hexCode = replaceAll('#', '');
|
||||
final val = int.tryParse('FF$hexCode', radix: 16);
|
||||
if (val == null) {
|
||||
return null;
|
||||
}
|
||||
return Color(val);
|
||||
}
|
||||
|
||||
int get i => int.parse(this);
|
||||
|
||||
Uri get uri {
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
class BuildData {
|
||||
static const String name = "ServerBox";
|
||||
static const int build = 472;
|
||||
static const int build = 473;
|
||||
static const String engine = "3.10.6";
|
||||
static const String buildAt = "2023-08-14 11:11:21.335805";
|
||||
static const String buildAt = "2023-08-15 23:06:31.430481";
|
||||
static const int modifications = 2;
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@
|
||||
"urlOrJson": "URL oder JSON",
|
||||
"user": "Benutzer",
|
||||
"versionHaveUpdate": "Gefunden: v1.0.{build}, klicke zum Aktualisieren",
|
||||
"versionUnknownUpdate": "Aktuell: v1.0.{build}",
|
||||
"versionUnknownUpdate": "Aktuell: v1.0.{build}. Klicken Sie hier, um nach Updates zu suchen",
|
||||
"versionUpdated": "v1.0.{build} ist bereits die neueste Version",
|
||||
"viewErr": "Fehler anzeigen",
|
||||
"virtKeyHelpClipboard": "In die Zwischenablage kopieren, wenn das ausgewählte Terminal nicht leer ist, andernfalls den Inhalt der Zwischenablage in das Terminal einfügen.",
|
||||
|
||||
@@ -208,7 +208,7 @@
|
||||
"urlOrJson": "URL or JSON",
|
||||
"user": "User",
|
||||
"versionHaveUpdate": "Found: v1.0.{build}, click to update",
|
||||
"versionUnknownUpdate": "Current: v1.0.{build}",
|
||||
"versionUnknownUpdate": "Current: v1.0.{build}, click to check updates",
|
||||
"versionUpdated": "Current: v1.0.{build}, is up to date",
|
||||
"viewErr": "See error",
|
||||
"virtKeyHelpClipboard": "Copy to the clipboard if terminal selected is not empty, otherwise paste the contents of the clipboard to the terminal.",
|
||||
|
||||
@@ -208,7 +208,7 @@
|
||||
"urlOrJson": "URL atau JSON",
|
||||
"user": "Username",
|
||||
"versionHaveUpdate": "Ditemukan: v1.0.{build}, klik untuk memperbarui",
|
||||
"versionUnknownUpdate": "Saat ini: v1.0.{build}",
|
||||
"versionUnknownUpdate": "Saat ini: v1.0.{build}. Klik untuk memeriksa pembaruan.",
|
||||
"versionUpdated": "Saat ini: v1.0.{build}, mutakhir",
|
||||
"viewErr": "Lihat kesalahan",
|
||||
"virtKeyHelpClipboard": "Salin ke clipboard jika terminal yang dipilih tidak kosong, jika tidak, tempel isi clipboard ke terminal.",
|
||||
|
||||
@@ -208,7 +208,7 @@
|
||||
"urlOrJson": "链接或JSON",
|
||||
"user": "用户",
|
||||
"versionHaveUpdate": "找到新版本:v1.0.{build}, 点击更新",
|
||||
"versionUnknownUpdate": "当前:v1.0.{build}",
|
||||
"versionUnknownUpdate": "当前:v1.0.{build},点击检查更新",
|
||||
"versionUpdated": "当前:v1.0.{build}, 已是最新版本",
|
||||
"viewErr": "查看错误",
|
||||
"virtKeyHelpClipboard": "如果终端有选中字符,则复制选中字符至剪切板,否则粘贴剪切板内容至终端。",
|
||||
|
||||
@@ -208,7 +208,7 @@
|
||||
"urlOrJson": "鏈接或JSON",
|
||||
"user": "用戶",
|
||||
"versionHaveUpdate": "找到新版本:v1.0.{build}, 點擊更新",
|
||||
"versionUnknownUpdate": "當前:v1.0.{build}",
|
||||
"versionUnknownUpdate": "當前:v1.0.{build},點擊檢查更新",
|
||||
"versionUpdated": "當前:v1.0.{build}, 已是最新版本",
|
||||
"viewErr": "查看錯誤",
|
||||
"virtKeyHelpClipboard": "如果終端有選中字符,則復製選中字符至剪切板,否則粘貼剪切板內容至終端。",
|
||||
|
||||
@@ -372,7 +372,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
SizedBox(
|
||||
width: width / 1.2,
|
||||
width: width,
|
||||
child: Text(
|
||||
device,
|
||||
style: textSize11,
|
||||
@@ -440,7 +440,7 @@ class _ServerDetailPageState extends State<ServerDetailPage>
|
||||
return RoundRectCard(Padding(
|
||||
padding: roundRectCardPadding,
|
||||
child: Column(children: children),
|
||||
));
|
||||
),);
|
||||
}
|
||||
|
||||
Widget _buildAnimatedText(Key key, String text, TextStyle style) {
|
||||
|
||||
@@ -4,14 +4,14 @@ import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:flutter_highlight/theme_map.dart';
|
||||
import 'package:flutter_material_color_picker/flutter_material_color_picker.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
import 'package:toolbox/core/extension/colorx.dart';
|
||||
import 'package:toolbox/core/extension/locale.dart';
|
||||
import 'package:toolbox/core/extension/navigator.dart';
|
||||
import 'package:toolbox/core/extension/stringx.dart';
|
||||
import 'package:toolbox/core/route.dart';
|
||||
import 'package:toolbox/data/model/app/net_view.dart';
|
||||
import 'package:toolbox/data/model/app/tab.dart';
|
||||
import 'package:toolbox/view/page/ssh/virt_key_setting.dart';
|
||||
import 'package:toolbox/view/widget/input_field.dart';
|
||||
import 'package:toolbox/view/widget/value_notifier.dart';
|
||||
@@ -41,7 +41,7 @@ class SettingPage extends StatefulWidget {
|
||||
|
||||
class _SettingPageState extends State<SettingPage> {
|
||||
final _themeKey = GlobalKey<PopupMenuButtonState<int>>();
|
||||
final _startPageKey = GlobalKey<PopupMenuButtonState<int>>();
|
||||
//final _startPageKey = GlobalKey<PopupMenuButtonState<int>>();
|
||||
final _updateIntervalKey = GlobalKey<PopupMenuButtonState<int>>();
|
||||
final _maxRetryKey = GlobalKey<PopupMenuButtonState<int>>();
|
||||
final _localeKey = GlobalKey<PopupMenuButtonState<String>>();
|
||||
@@ -53,7 +53,6 @@ class _SettingPageState extends State<SettingPage> {
|
||||
|
||||
late final SettingStore _setting;
|
||||
late final ServerProvider _serverProvider;
|
||||
late MediaQueryData _media;
|
||||
late S _s;
|
||||
late SharedPreferences _sp;
|
||||
|
||||
@@ -75,7 +74,6 @@ class _SettingPageState extends State<SettingPage> {
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
_media = MediaQuery.of(context);
|
||||
_s = S.of(context)!;
|
||||
_localeCode.value = _setting.locale.fetch() ?? _s.localeName;
|
||||
}
|
||||
@@ -141,8 +139,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
_buildLocale(),
|
||||
_buildThemeMode(),
|
||||
_buildAppColor(),
|
||||
_buildLaunchPage(),
|
||||
_buildAutoCheckAppUpdate(),
|
||||
//_buildLaunchPage(),
|
||||
_buildCheckUpdate(),
|
||||
];
|
||||
if (isIOS) {
|
||||
@@ -215,11 +212,10 @@ class _SettingPageState extends State<SettingPage> {
|
||||
display = _s.versionUnknownUpdate(BuildData.build);
|
||||
}
|
||||
return ListTile(
|
||||
trailing: const Icon(Icons.keyboard_arrow_right),
|
||||
title: Text(
|
||||
display,
|
||||
),
|
||||
title: Text(_s.autoCheckUpdate),
|
||||
subtitle: Text(display, style: grey),
|
||||
onTap: () => doUpdate(ctx, force: true),
|
||||
trailing: buildSwitch(context, _setting.autoCheckAppUpdate),
|
||||
);
|
||||
},
|
||||
);
|
||||
@@ -282,77 +278,73 @@ class _SettingPageState extends State<SettingPage> {
|
||||
_s.primaryColor,
|
||||
),
|
||||
onTap: () async {
|
||||
final ctrl = TextEditingController(text: primaryColor.toHex);
|
||||
await showRoundDialog(
|
||||
context: context,
|
||||
title: Text(_s.primaryColor),
|
||||
child: SizedBox(
|
||||
height: 211,
|
||||
child: Center(
|
||||
child: MaterialColorPicker(
|
||||
shrinkWrap: true,
|
||||
allowShades: true,
|
||||
onColorChange: (color) {
|
||||
_selectedColorValue.value = color.value;
|
||||
},
|
||||
selectedColor: primaryColor,
|
||||
),
|
||||
),
|
||||
child: Input(
|
||||
onSubmitted: _onSaveColor,
|
||||
controller: ctrl,
|
||||
hint: '#8b2252',
|
||||
icon: Icons.colorize,
|
||||
),
|
||||
actions: [
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
_setting.primaryColor.put(_selectedColorValue.value);
|
||||
Navigator.pop(context);
|
||||
_showRestartSnackbar();
|
||||
},
|
||||
child: Text(_s.ok),
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildLaunchPage() {
|
||||
final items = AppTab.values
|
||||
.map(
|
||||
(e) => PopupMenuItem(
|
||||
value: e.index,
|
||||
child: Text(tabTitleName(context, e)),
|
||||
),
|
||||
)
|
||||
.toList();
|
||||
|
||||
return ListTile(
|
||||
title: Text(
|
||||
_s.launchPage,
|
||||
),
|
||||
onTap: () {
|
||||
_startPageKey.currentState?.showButtonMenu();
|
||||
},
|
||||
trailing: ValueBuilder(
|
||||
listenable: _launchPageIdx,
|
||||
build: () => PopupMenuButton(
|
||||
key: _startPageKey,
|
||||
itemBuilder: (BuildContext context) => items,
|
||||
initialValue: _launchPageIdx.value,
|
||||
onSelected: (int idx) {
|
||||
_launchPageIdx.value = idx;
|
||||
_setting.launchPage.put(_launchPageIdx.value);
|
||||
},
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(maxWidth: _media.size.width * 0.35),
|
||||
child: Text(
|
||||
tabTitleName(context, AppTab.values[_launchPageIdx.value]),
|
||||
textAlign: TextAlign.right,
|
||||
style: textSize15,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
void _onSaveColor(String s) {
|
||||
final color = s.hexToColor;
|
||||
if (color == null) {
|
||||
showSnackBar(context, Text(_s.failed));
|
||||
return;
|
||||
}
|
||||
_selectedColorValue.value = color.value;
|
||||
_setting.primaryColor.put(_selectedColorValue.value);
|
||||
context.pop();
|
||||
_showRestartSnackbar();
|
||||
}
|
||||
|
||||
// Widget _buildLaunchPage() {
|
||||
// final items = AppTab.values
|
||||
// .map(
|
||||
// (e) => PopupMenuItem(
|
||||
// value: e.index,
|
||||
// child: Text(tabTitleName(context, e)),
|
||||
// ),
|
||||
// )
|
||||
// .toList();
|
||||
|
||||
// return ListTile(
|
||||
// title: Text(
|
||||
// _s.launchPage,
|
||||
// ),
|
||||
// onTap: () {
|
||||
// _startPageKey.currentState?.showButtonMenu();
|
||||
// },
|
||||
// trailing: ValueBuilder(
|
||||
// listenable: _launchPageIdx,
|
||||
// build: () => PopupMenuButton(
|
||||
// key: _startPageKey,
|
||||
// itemBuilder: (BuildContext context) => items,
|
||||
// initialValue: _launchPageIdx.value,
|
||||
// onSelected: (int idx) {
|
||||
// _launchPageIdx.value = idx;
|
||||
// _setting.launchPage.put(_launchPageIdx.value);
|
||||
// },
|
||||
// child: ConstrainedBox(
|
||||
// constraints: BoxConstraints(maxWidth: _media.size.width * 0.35),
|
||||
// child: Text(
|
||||
// tabTitleName(context, AppTab.values[_launchPageIdx.value]),
|
||||
// textAlign: TextAlign.right,
|
||||
// style: textSize15,
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// }
|
||||
|
||||
Widget _buildMaxRetry() {
|
||||
final items = List.generate(
|
||||
10,
|
||||
@@ -978,12 +970,4 @@ class _SettingPageState extends State<SettingPage> {
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildAutoCheckAppUpdate() {
|
||||
return ListTile(
|
||||
title: Text(_s.autoCheckUpdate),
|
||||
subtitle: Text(_s.whenOpenApp, style: grey),
|
||||
trailing: buildSwitch(context, _setting.autoCheckAppUpdate),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user