opt: settings page

This commit is contained in:
lollipopkit
2023-02-06 15:32:36 +08:00
parent 3feef3936c
commit e7b1773e5c
11 changed files with 213 additions and 180 deletions

View File

@@ -1,6 +1,6 @@
import 'dart:io';
import 'package:flutter/foundation.dart';
import 'package:flutter/services.dart';
import 'package:flutter/widgets.dart';
import 'package:share_plus/share_plus.dart';
@@ -23,15 +23,6 @@ Future<bool> shareFiles(BuildContext context, List<String> filePaths) async {
return filePaths.isNotEmpty;
}
bool get longPressEnabled {
switch (defaultTargetPlatform) {
case TargetPlatform.android:
case TargetPlatform.iOS:
return true;
case TargetPlatform.macOS:
case TargetPlatform.fuchsia:
case TargetPlatform.linux:
case TargetPlatform.windows:
return false;
}
void copy(String text) {
Clipboard.setData(ClipboardData(text: text));
}

View File

@@ -1,6 +1,6 @@
import 'package:flutter/material.dart';
import 'package:toolbox/data/res/terminal_color.dart';
import 'package:xterm/ui.dart';
import '../../res/terminal_color.dart';
class TerminalUITheme {
final Color cursor;

View File

@@ -2,9 +2,9 @@
class BuildData {
static const String name = "ServerBox";
static const int build = 214;
static const int build = 215;
static const String engine =
"Flutter 3.7.0 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision b06b8b2710 (10 days ago) • 2023-01-23 16:55:55 -0800\nEngine • revision b24591ed32\nTools • Dart 2.19.0 • DevTools 2.20.1\n";
static const String buildAt = "2023-02-03 12:48:35.264858";
static const int modifications = 12;
"Flutter 3.7.0 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision b06b8b2710 (13 days ago) • 2023-01-23 16:55:55 -0800\nEngine • revision b24591ed32\nTools • Dart 2.19.0 • DevTools 2.20.1\n";
static const String buildAt = "2023-02-05 22:11:13.992594";
static const int modifications = 9;
}

View File

@@ -27,5 +27,6 @@ class SettingStore extends PersistentStore {
property('termColorIdx', defaultValue: 0);
/// Max retry count when connect to server
StoreProperty<int> get maxRetryCount => property('maxRetryCount', defaultValue: 7);
StoreProperty<int> get maxRetryCount =>
property('maxRetryCount', defaultValue: 7);
}

View File

@@ -148,7 +148,7 @@ class MessageLookup extends MessageLookupByLibrary {
"loss": MessageLookupByLibrary.simpleMessage("丢包率"),
"madeWithLove": m8,
"max": MessageLookupByLibrary.simpleMessage("最大"),
"maxRetryCount": MessageLookupByLibrary.simpleMessage("连接服务器重试次数"),
"maxRetryCount": MessageLookupByLibrary.simpleMessage("服务器尝试重连次数"),
"maxRetryCountEqual0": MessageLookupByLibrary.simpleMessage("会无限重试"),
"min": MessageLookupByLibrary.simpleMessage("最小"),
"ms": MessageLookupByLibrary.simpleMessage("毫秒"),

View File

@@ -76,7 +76,7 @@
"loss": "丢包率",
"madeWithLove": "\n用❤制作 by {myGithub}",
"max": "最大",
"maxRetryCount": "连接服务器重试次数",
"maxRetryCount": "服务器尝试重连次数",
"maxRetryCountEqual0": "会无限重试",
"min": "最小",
"ms": "毫秒",

View File

@@ -1,8 +1,8 @@
import 'package:flutter/material.dart';
import 'package:flutter_material_color_picker/flutter_material_color_picker.dart';
import 'package:provider/provider.dart';
import 'package:toolbox/data/model/ssh/terminal_color.dart';
import '../../data/model/ssh/terminal_color.dart';
import '../../core/update.dart';
import '../../core/utils/ui.dart';
import '../../data/provider/app.dart';
@@ -60,20 +60,52 @@ class _SettingPageState extends State<SettingPage> {
title: Text(_s.setting),
),
body: ListView(
padding: const EdgeInsets.all(17),
padding: const EdgeInsets.symmetric(horizontal: 17),
children: [
_buildAppColorPreview(),
_buildUpdateInterval(),
_buildCheckUpdate(),
_buildLaunchPage(),
_buildDistLogoSwitch(),
_buildTermTheme(),
_buildMaxRetry(),
].map((e) => RoundRectCard(e)).toList(),
// App
_buildTitle('App'),
_buildApp(),
// Server
_buildTitle(_s.server),
_buildServer(),
],
),
);
}
Widget _buildTitle(String text) {
return Padding(
padding: const EdgeInsets.only(top: 23, bottom: 17),
child: Center(
child: Text(
text,
style: textSize13,
),
),
);
}
Widget _buildApp() {
return Column(
children: [
_buildAppColorPreview(),
_buildLaunchPage(),
_buildCheckUpdate(),
].map((e) => RoundRectCard(e)).toList(),
);
}
Widget _buildServer() {
return Column(
children: [
_buildDistLogoSwitch(),
_buildUpdateInterval(),
_buildTermTheme(),
_buildMaxRetry(),
].map((e) => RoundRectCard(e)).toList(),
);
}
Widget _buildDistLogoSwitch() {
return ListTile(
title: Text(
@@ -126,7 +158,10 @@ class _SettingPageState extends State<SettingPage> {
_s.willTakEeffectImmediately,
style: textSize13Grey,
),
trailing: Text('${_updateInterval.toInt()} ${_s.second}'),
trailing: Text(
'${_updateInterval.toInt()} ${_s.second}',
style: textSize13,
),
children: [
Slider(
thumbColor: primaryColor,
@@ -298,7 +333,10 @@ class _SettingPageState extends State<SettingPage> {
style: textSize13,
textAlign: TextAlign.start,
),
trailing: Text('${_maxRetryCount.toInt()} ${_s.times}'),
trailing: Text(
'${_maxRetryCount.toInt()} ${_s.times}',
style: textSize13,
),
children: [
Slider(
thumbColor: primaryColor,

View File

@@ -6,10 +6,11 @@ import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:provider/provider.dart';
import 'package:toolbox/data/model/ssh/terminal_color.dart';
import 'package:toolbox/generated/l10n.dart';
import 'package:xterm/xterm.dart';
import 'package:xterm/xterm.dart' hide TerminalColors;
import '../../data/model/ssh/terminal_color.dart';
import '../../generated/l10n.dart';
import '../../core/utils/misc.dart';
import '../../core/utils/ui.dart';
import '../../core/utils/server.dart';
import '../../data/model/server/server_private_info.dart';
@@ -132,7 +133,7 @@ class _SSHPageState extends State<SSHPage> {
theme: termTheme,
deleteDetection: Platform.isIOS,
onTapUp: _onTapUp,
autofocus: true,
autoFocus: true,
keyboardAppearance: _isDark ? Brightness.dark : Brightness.light,
),
);
@@ -249,7 +250,7 @@ class _SSHPageState extends State<SSHPage> {
_paste();
break;
case VirtualKeyFunc.copy:
_copy(terminalSelected);
copy(terminalSelected);
break;
}
}
@@ -270,10 +271,6 @@ class _SSHPageState extends State<SSHPage> {
return _terminal.buffer.getText(range);
}
void _copy(String text) {
Clipboard.setData(ClipboardData(text: text));
}
void _onTapUp(TapUpDetails details, CellOffset offset) {
{
if (_menuController.isShown) {
@@ -319,7 +316,7 @@ class _SSHPageState extends State<SSHPage> {
),
onPressed: () {
_terminalController.setSelection(null);
_copy(selected);
copy(selected);
_menuController.remove();
},
),