Compare commits

...

19 Commits

Author SHA1 Message Date
lollipopkit
e5ef28415b opt.: ssh tab 2024-06-08 21:39:42 +08:00
lollipopkit
46b98df153 Merge branch 'dev' 2024-06-08 20:58:41 +08:00
lollipopkit
9f34021c90 fix: docker ps parse if id/name is too long 2024-06-08 20:57:56 +08:00
lollipopkit
8121eef839 opt.: RNode 2024-06-08 15:35:19 +08:00
lollipopkit
da48d1f66c opt.: IME popup after opening drawer if ssh term is focusing 2024-06-08 13:53:23 +08:00
lollipopkit
b167287c5b opt.: ssh tab page's tab bar 2024-06-07 23:53:13 +08:00
lollipopkit
41f9da6bf8 fix: ssh tab PageView animteToPage 2024-06-07 21:51:00 +08:00
lollipopkit
e7c7fc8186 fix: ssh tab name generaton 2024-06-07 21:43:38 +08:00
lollipopkit
b950dd2d68 fix: ssh tab 2024-06-07 21:09:17 +08:00
lollipopkit
6d34de14d3 Merge branch 'dev' 2024-06-06 21:26:03 +08:00
lollipopkit
a5a84c0cdd fix: podman log 2024-06-06 18:52:20 +08:00
lollipopkit
701b1b811f feat: beta program 2024-06-06 16:18:10 +08:00
lollipopkit
97267cdfbf fix: docker container status (#374) 2024-06-05 21:58:19 +08:00
lollipopkit
40ce37d230 opt.: sftp del dir 2024-06-05 18:48:44 +08:00
lollipopkit
8a9ade355c fix: update check 2024-06-05 18:26:02 +08:00
lollipopkit
9bffec64b5 fix: wol cfg (#373) 2024-06-05 18:16:17 +08:00
lollipopkit
a03ee2ae0e fix: term help 2024-06-05 11:12:43 +08:00
PaperCube
ee889235fe Fixed UI representation of server reorder page (#372) 2024-06-04 18:57:57 +01:00
lollipopkit
94d6d80497 chore: README 2024-06-04 23:17:32 +08:00
40 changed files with 438 additions and 215 deletions

3
.gitignore vendored
View File

@@ -57,9 +57,10 @@ test.dart
# Linux release # Linux release
linux.AppDir linux.AppDir
ServerBox-x86_64.AppImage **/*.AppImage
untranlated.json untranlated.json
.vscode/settings.json .vscode/settings.json
more_build_data.json more_build_data.json
trans.txt

View File

@@ -17,7 +17,9 @@ Especially thanks to <a href="https://github.com/TerminalStudio/dartssh2">dartss
## ⬇️ Download ## ⬇️ Download
🎉 **The `Android / Linux / Windows` version are now built via GitHub Actions** 🎉 **The `Android / Linux / Windows` version are now built via GitHub Actions**
[iOS & macOS](https://apps.apple.com/app/id6476033062) / [Android & Linux & Windows](https://github.com/lollipopkit/flutter_gpt_box/releases) [iOS & macOS](https://apps.apple.com/app/id1586449703) / [Android & Linux & Windows](https://github.com/lollipopkit/flutter_server_box/releases)
All deprecated versions before `v930` can be found in [here](https://cdn.lolli.tech/serverbox/?sort=time&order=desc&layout=grid).
## 🔖 Feature ## 🔖 Feature

View File

@@ -18,7 +18,9 @@
## ⬇️ Download ## ⬇️ Download
🎉 **现在 `Android / Linux / Windows` 版本使用 GitHub Actions 构建** 🎉 **现在 `Android / Linux / Windows` 版本使用 GitHub Actions 构建**
[iOS & macOS](https://apps.apple.com/app/id1586449703) / [Android & Linux & Windows](https://github.com/lollipopkit/flutter_gpt_box/releases) [iOS & macOS](https://apps.apple.com/app/id1586449703) / [Android & Linux & Windows](https://github.com/lollipopkit/flutter_server_box/releases)
所有 `v930` 之前的版本可以在 [这里](https://cdn.lolli.tech/serverbox/?sort=time&order=desc&layout=grid) 找到。
## 🔖 特点 ## 🔖 特点

View File

@@ -690,7 +690,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 923; CURRENT_PROJECT_VERSION = 948;
DEVELOPMENT_TEAM = BA88US33G6; DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
@@ -700,7 +700,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 1.0.923; MARKETING_VERSION = 1.0.948;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
@@ -826,7 +826,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 923; CURRENT_PROJECT_VERSION = 948;
DEVELOPMENT_TEAM = BA88US33G6; DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
@@ -836,7 +836,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 1.0.923; MARKETING_VERSION = 1.0.948;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
@@ -854,7 +854,7 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES; CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements; CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CURRENT_PROJECT_VERSION = 923; CURRENT_PROJECT_VERSION = 948;
DEVELOPMENT_TEAM = BA88US33G6; DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_BITCODE = NO; ENABLE_BITCODE = NO;
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist"; INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
@@ -864,7 +864,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 1.0.923; MARKETING_VERSION = 1.0.948;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h"; SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
@@ -885,7 +885,7 @@
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 923; CURRENT_PROJECT_VERSION = 948;
DEVELOPMENT_TEAM = BA88US33G6; DEVELOPMENT_TEAM = BA88US33G6;
GCC_C_LANGUAGE_STANDARD = gnu11; GCC_C_LANGUAGE_STANDARD = gnu11;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
@@ -898,7 +898,7 @@
"@executable_path/Frameworks", "@executable_path/Frameworks",
"@executable_path/../../Frameworks", "@executable_path/../../Frameworks",
); );
MARKETING_VERSION = 1.0.923; MARKETING_VERSION = 1.0.948;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES; MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget;
@@ -924,7 +924,7 @@
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 923; CURRENT_PROJECT_VERSION = 948;
DEVELOPMENT_TEAM = BA88US33G6; DEVELOPMENT_TEAM = BA88US33G6;
GCC_C_LANGUAGE_STANDARD = gnu11; GCC_C_LANGUAGE_STANDARD = gnu11;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
@@ -937,7 +937,7 @@
"@executable_path/Frameworks", "@executable_path/Frameworks",
"@executable_path/../../Frameworks", "@executable_path/../../Frameworks",
); );
MARKETING_VERSION = 1.0.923; MARKETING_VERSION = 1.0.948;
MTL_FAST_MATH = YES; MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
@@ -960,7 +960,7 @@
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 923; CURRENT_PROJECT_VERSION = 948;
DEVELOPMENT_TEAM = BA88US33G6; DEVELOPMENT_TEAM = BA88US33G6;
GCC_C_LANGUAGE_STANDARD = gnu11; GCC_C_LANGUAGE_STANDARD = gnu11;
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
@@ -973,7 +973,7 @@
"@executable_path/Frameworks", "@executable_path/Frameworks",
"@executable_path/../../Frameworks", "@executable_path/../../Frameworks",
); );
MARKETING_VERSION = 1.0.923; MARKETING_VERSION = 1.0.948;
MTL_FAST_MATH = YES; MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.StatusWidget;
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
@@ -996,7 +996,7 @@
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 923; CURRENT_PROJECT_VERSION = 948;
DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = BA88US33G6; DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;
@@ -1008,7 +1008,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 1.0.923; MARKETING_VERSION = 1.0.948;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES; MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd;
@@ -1037,7 +1037,7 @@
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 923; CURRENT_PROJECT_VERSION = 948;
DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = BA88US33G6; DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;
@@ -1049,7 +1049,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 1.0.923; MARKETING_VERSION = 1.0.948;
MTL_FAST_MATH = YES; MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd;
PRODUCT_NAME = ServerBox; PRODUCT_NAME = ServerBox;
@@ -1075,7 +1075,7 @@
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 923; CURRENT_PROJECT_VERSION = 948;
DEVELOPMENT_ASSET_PATHS = ""; DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = BA88US33G6; DEVELOPMENT_TEAM = BA88US33G6;
ENABLE_PREVIEWS = YES; ENABLE_PREVIEWS = YES;
@@ -1087,7 +1087,7 @@
"$(inherited)", "$(inherited)",
"@executable_path/Frameworks", "@executable_path/Frameworks",
); );
MARKETING_VERSION = 1.0.923; MARKETING_VERSION = 1.0.948;
MTL_FAST_MATH = YES; MTL_FAST_MATH = YES;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox.WatchEnd;
PRODUCT_NAME = ServerBox; PRODUCT_NAME = ServerBox;

View File

@@ -15,7 +15,7 @@ class MyApp extends StatelessWidget {
Widget build(BuildContext context) { Widget build(BuildContext context) {
_setup(context); _setup(context);
return ListenableBuilder( return ListenableBuilder(
listenable: RebuildNodes.app, listenable: RNodes.app,
builder: (context, _) { builder: (context, _) {
if (!Stores.setting.useSystemPrimaryColor.fetch()) { if (!Stores.setting.useSystemPrimaryColor.fetch()) {
UIs.colorSeed = Color(Stores.setting.primaryColor.fetch()); UIs.colorSeed = Color(Stores.setting.primaryColor.fetch());

View File

@@ -170,7 +170,7 @@ class Backup {
} }
Pros.reload(); Pros.reload();
RebuildNodes.app.rebuild(); RNodes.app.build();
_logger.info('Restore success'); _logger.info('Restore success');
} }

View File

@@ -1,5 +0,0 @@
typedef GhId = String;
extension GhIdX on GhId {
String get url => 'https://github.com/$this';
}

View File

@@ -1,23 +0,0 @@
import 'package:flutter/foundation.dart';
class RebuildNode implements Listenable {
final List<VoidCallback> _listeners = [];
RebuildNode();
@override
void addListener(VoidCallback listener) {
_listeners.add(listener);
}
@override
void removeListener(VoidCallback listener) {
_listeners.remove(listener);
}
void rebuild() {
for (var listener in _listeners) {
listener();
}
}
}

View File

@@ -3,8 +3,9 @@ import 'dart:convert';
import 'package:fl_lib/fl_lib.dart'; import 'package:fl_lib/fl_lib.dart';
import 'package:toolbox/core/extension/context/locale.dart'; import 'package:toolbox/core/extension/context/locale.dart';
import 'package:toolbox/data/model/container/type.dart'; import 'package:toolbox/data/model/container/type.dart';
import 'package:toolbox/data/res/misc.dart';
abstract final class ContainerPs { sealed class ContainerPs {
final String? id = null; final String? id = null;
final String? image = null; final String? image = null;
String? get name; String? get name;
@@ -140,7 +141,10 @@ final class DockerPs implements ContainerPs {
String? get cmd => null; String? get cmd => null;
@override @override
bool get running => state?.contains('Up ') ?? false; bool get running {
if (state?.contains('Exited') == true) return false;
return true;
}
@override @override
void parseStats(String s) { void parseStats(String s) {
@@ -154,12 +158,12 @@ final class DockerPs implements ContainerPs {
/// CONTAINER ID NAMES IMAGE STATUS /// CONTAINER ID NAMES IMAGE STATUS
/// a049d689e7a1 aria2-pro p3terx/aria2-pro Up 3 weeks /// a049d689e7a1 aria2-pro p3terx/aria2-pro Up 3 weeks
factory DockerPs.parse(String raw) { factory DockerPs.parse(String raw) {
final parts = raw.split(RegExp(r'\s{2,}')); final parts = raw.split(Miscs.multiBlankreg);
return DockerPs( return DockerPs(
id: parts[0], id: parts[0],
names: parts[1], state: parts[1],
image: parts[2], names: parts[2],
state: parts[3], image: parts[3].trim(),
); );
} }
} }

View File

@@ -276,9 +276,13 @@ enum ContainerCmdType {
return switch (this) { return switch (this) {
ContainerCmdType.version => '$prefix version $_jsonFmt', ContainerCmdType.version => '$prefix version $_jsonFmt',
ContainerCmdType.ps => switch (type) { ContainerCmdType.ps => switch (type) {
/// TODO: Rollback to json format when permformance recovers.
/// Use [_jsonFmt] in Docker will cause the operation to slow down. /// Use [_jsonFmt] in Docker will cause the operation to slow down.
ContainerType.docker => '$prefix ps -a --format "table ' ContainerType.docker => '$prefix ps -a --format "table {{printf \\"'
'{{printf \\"${"%-30.30s " * 4}\\" .ID .Names .Image .Status}}"', '%-15.15s '
'%-30.30s '
'${"%-50.50s " * 2}\\"'
' .ID .Status .Names .Image}}"',
ContainerType.podman => '$prefix ps -a $_jsonFmt', ContainerType.podman => '$prefix ps -a $_jsonFmt',
}, },
ContainerCmdType.stats => ContainerCmdType.stats =>

View File

@@ -2,9 +2,9 @@
class BuildData { class BuildData {
static const String name = "ServerBox"; static const String name = "ServerBox";
static const int build = 923; static const int build = 948;
static const String engine = "3.22.1"; static const String engine = "3.22.1";
static const String buildAt = "2024-06-01 22:31:14"; static const String buildAt = "2024-06-08 21:21:36";
static const int modifications = 4; static const int modifications = 3;
static const int script = 48; static const int script = 48;
} }

View File

@@ -1,5 +1,3 @@
import 'package:toolbox/data/model/app/github_id.dart';
abstract final class GithubIds { abstract final class GithubIds {
// Thanks // Thanks
// If you want to change your Github ID, please open an issue. // If you want to change your Github ID, please open an issue.
@@ -75,3 +73,9 @@ abstract final class GithubIds {
'Jasonzhu1207', 'Jasonzhu1207',
}; };
} }
typedef GhId = String;
extension GhIdX on GhId {
String get url => 'https://github.com/$this';
}

View File

@@ -2,6 +2,7 @@ import 'dart:convert';
abstract final class Miscs { abstract final class Miscs {
static final blankReg = RegExp(r'\s+'); static final blankReg = RegExp(r'\s+');
static final multiBlankreg = RegExp(r'\s{2,}');
/// RegExp for password request /// RegExp for password request
static final pwdRequestWithUserReg = RegExp(r'\[sudo\] password for (.+):'); static final pwdRequestWithUserReg = RegExp(r'\[sudo\] password for (.+):');

View File

@@ -1,5 +1,6 @@
import 'package:toolbox/data/model/app/rebuild.dart'; import 'package:fl_lib/fl_lib.dart';
abstract final class RebuildNodes { abstract final class RNodes {
static final app = RebuildNode(); static final app = RNode();
static final dark = false.vn;
} }

View File

@@ -1,6 +1,6 @@
abstract final class Urls { abstract final class Urls {
static const cdnBase = 'https://cdn.lolli.tech/serverbox'; static const cdnBase = 'https://cdn.lolli.tech/serverbox';
static const updateCfg = '$cdnBase/update.json'; static const updateCfg = '$cdnBase/update2.json';
static const myGithub = 'https://github.com/lollipopkit'; static const myGithub = 'https://github.com/lollipopkit';
static const appHelp = '$myGithub/flutter_server_box#-help'; static const appHelp = '$myGithub/flutter_server_box#-help';
static const appWiki = '$myGithub/flutter_server_box/wiki'; static const appWiki = '$myGithub/flutter_server_box/wiki';

View File

@@ -276,6 +276,8 @@ class SettingStore extends PersistentStore {
/// fmt: https://example.com/{DIST}-{BRIGHT}.png /// fmt: https://example.com/{DIST}-{BRIGHT}.png
late final serverLogoUrl = property('serverLogoUrl', ''); late final serverLogoUrl = property('serverLogoUrl', '');
late final betaTest = property('betaTest', false);
// Never show these settings for users // Never show these settings for users
// //
// ------BEGIN------ // ------BEGIN------

View File

@@ -2,6 +2,7 @@
"@@locale": "de", "@@locale": "de",
"about": "Über", "about": "Über",
"aboutThanks": "Vielen Dank an die folgenden Personen, die daran teilgenommen haben.\n", "aboutThanks": "Vielen Dank an die folgenden Personen, die daran teilgenommen haben.\n",
"acceptBeta": "Akzeptieren Sie Testversion-Updates",
"add": "Neu", "add": "Neu",
"addAServer": "Server hinzufügen", "addAServer": "Server hinzufügen",
"addPrivateKey": "Private key hinzufügen", "addPrivateKey": "Private key hinzufügen",

View File

@@ -2,6 +2,7 @@
"@@locale": "en", "@@locale": "en",
"about": "About", "about": "About",
"aboutThanks": "Thanks to the following people who participated in.", "aboutThanks": "Thanks to the following people who participated in.",
"acceptBeta": "Accept test version updates",
"add": "Add", "add": "Add",
"addAServer": "add a server", "addAServer": "add a server",
"addPrivateKey": "Add private key", "addPrivateKey": "Add private key",

View File

@@ -2,6 +2,7 @@
"@@locale": "es", "@@locale": "es",
"about": "Acerca de", "about": "Acerca de",
"aboutThanks": "Gracias a los siguientes participantes.", "aboutThanks": "Gracias a los siguientes participantes.",
"acceptBeta": "Aceptar actualizaciones de la versión de prueba",
"add": "Añadir", "add": "Añadir",
"addAServer": "Agregar un servidor", "addAServer": "Agregar un servidor",
"addPrivateKey": "Agregar una llave privada", "addPrivateKey": "Agregar una llave privada",

View File

@@ -2,6 +2,7 @@
"@@locale": "fr", "@@locale": "fr",
"about": "À propos", "about": "À propos",
"aboutThanks": "Merci aux personnes suivantes qui ont participé.", "aboutThanks": "Merci aux personnes suivantes qui ont participé.",
"acceptBeta": "Accepter les mises à jour de la version de test",
"add": "Ajouter", "add": "Ajouter",
"addAServer": "Ajouter un serveur", "addAServer": "Ajouter un serveur",
"addPrivateKey": "Ajouter une clé privée", "addPrivateKey": "Ajouter une clé privée",

View File

@@ -2,6 +2,7 @@
"@@locale": "id", "@@locale": "id",
"about": "Tentang", "about": "Tentang",
"aboutThanks": "Terima kasih kepada orang -orang berikut yang berpartisipasi.", "aboutThanks": "Terima kasih kepada orang -orang berikut yang berpartisipasi.",
"acceptBeta": "Terima pembaruan versi uji coba",
"add": "Menambahkan", "add": "Menambahkan",
"addAServer": "tambahkan server", "addAServer": "tambahkan server",
"addPrivateKey": "Tambahkan kunci pribadi", "addPrivateKey": "Tambahkan kunci pribadi",

View File

@@ -2,6 +2,7 @@
"@@locale": "ja", "@@locale": "ja",
"about": "約", "about": "約",
"aboutThanks": "以下の参加者に感謝します。", "aboutThanks": "以下の参加者に感謝します。",
"acceptBeta": "テストバージョンの更新を受け入れる",
"add": "追加", "add": "追加",
"addAServer": "サーバーを追加する", "addAServer": "サーバーを追加する",
"addPrivateKey": "プライベートキーを追加", "addPrivateKey": "プライベートキーを追加",

View File

@@ -2,6 +2,7 @@
"@@locale": "nl", "@@locale": "nl",
"about": "Over", "about": "Over",
"aboutThanks": "Met dank aan de volgende mensen die hebben deelgenomen aan.", "aboutThanks": "Met dank aan de volgende mensen die hebben deelgenomen aan.",
"acceptBeta": "Accepteer testversie-updates",
"add": "Toevoegen", "add": "Toevoegen",
"addAServer": "een server toevoegen", "addAServer": "een server toevoegen",
"addPrivateKey": "Privésleutel toevoegen", "addPrivateKey": "Privésleutel toevoegen",

View File

@@ -2,6 +2,7 @@
"@@locale": "pt", "@@locale": "pt",
"about": "Sobre", "about": "Sobre",
"aboutThanks": "Agradecimentos a todos os participantes.", "aboutThanks": "Agradecimentos a todos os participantes.",
"acceptBeta": "Aceitar atualizações da versão de teste",
"add": "Adicionar", "add": "Adicionar",
"addAServer": "Adicionar um servidor", "addAServer": "Adicionar um servidor",
"addPrivateKey": "Adicionar uma chave privada", "addPrivateKey": "Adicionar uma chave privada",

View File

@@ -2,6 +2,7 @@
"@@locale": "ru", "@@locale": "ru",
"about": "о", "about": "о",
"aboutThanks": "Благодарности всем участникам.", "aboutThanks": "Благодарности всем участникам.",
"acceptBeta": "Принять обновления тестовой версии",
"add": "добавить", "add": "добавить",
"addAServer": "добавить сервер", "addAServer": "добавить сервер",
"addPrivateKey": "добавить приватный ключ", "addPrivateKey": "добавить приватный ключ",

View File

@@ -2,6 +2,7 @@
"@@locale": "zh", "@@locale": "zh",
"about": "关于", "about": "关于",
"aboutThanks": "感谢以下参与的各位。", "aboutThanks": "感谢以下参与的各位。",
"acceptBeta": "接受测试版更新推送",
"add": "新增", "add": "新增",
"addAServer": "添加服务器", "addAServer": "添加服务器",
"addPrivateKey": "添加一个私钥", "addPrivateKey": "添加一个私钥",

View File

@@ -2,6 +2,7 @@
"@@locale": "zh_TW", "@@locale": "zh_TW",
"about": "關於", "about": "關於",
"aboutThanks": "感謝以下參與的各位。", "aboutThanks": "感謝以下參與的各位。",
"acceptBeta": "接受測試版更新推送",
"add": "新增", "add": "新增",
"addAServer": "新增服務器", "addAServer": "新增服務器",
"addPrivateKey": "新增一個私鑰", "addPrivateKey": "新增一個私鑰",

View File

@@ -20,6 +20,7 @@ import 'package:toolbox/data/model/server/custom.dart';
import 'package:toolbox/data/model/server/private_key_info.dart'; import 'package:toolbox/data/model/server/private_key_info.dart';
import 'package:toolbox/data/model/server/server_private_info.dart'; import 'package:toolbox/data/model/server/server_private_info.dart';
import 'package:toolbox/data/model/server/snippet.dart'; import 'package:toolbox/data/model/server/snippet.dart';
import 'package:toolbox/data/model/server/wol_cfg.dart';
import 'package:toolbox/data/model/ssh/virtual_key.dart'; import 'package:toolbox/data/model/ssh/virtual_key.dart';
import 'package:toolbox/data/res/build_data.dart'; import 'package:toolbox/data/res/build_data.dart';
import 'package:toolbox/data/res/misc.dart'; import 'package:toolbox/data/res/misc.dart';
@@ -87,6 +88,7 @@ Future<void> _initData() async {
Hive.registerAdapter(NetViewTypeAdapter()); // 5 Hive.registerAdapter(NetViewTypeAdapter()); // 5
Hive.registerAdapter(ServerFuncBtnAdapter()); // 6 Hive.registerAdapter(ServerFuncBtnAdapter()); // 6
Hive.registerAdapter(ServerCustomAdapter()); // 7 Hive.registerAdapter(ServerCustomAdapter()); // 7
Hive.registerAdapter(WakeOnLanCfgAdapter()); // 8
await Stores.setting.init(); await Stores.setting.init();
await Stores.server.init(); await Stores.server.init();
@@ -98,6 +100,8 @@ Future<void> _initData() async {
Pros.snippet.load(); Pros.snippet.load();
Pros.key.load(); Pros.key.load();
await Pros.app.init(); await Pros.app.init();
if (Stores.setting.betaTest.fetch()) AppUpdate.chan = AppUpdateChan.beta;
} }
void _setupDebug() { void _setupDebug() {

View File

@@ -206,7 +206,10 @@ class _ContainerPageState extends State<ContainerPage> {
], ],
), ),
Text( Text(
'${item.image ?? l10n.unknown} - ${item.running ? l10n.running : l10n.stopped}', '${item.image ?? l10n.unknown} - ${switch (item) {
final PodmanPs ps => ps.running ? l10n.running : l10n.stopped,
final DockerPs ps => ps.state,
}}',
style: UIs.text13Grey, style: UIs.text13Grey,
), ),
_buildPsItemStats(item), _buildPsItemStats(item),
@@ -550,7 +553,10 @@ class _ContainerPageState extends State<ContainerPage> {
case ContainerMenu.logs: case ContainerMenu.logs:
AppRoutes.ssh( AppRoutes.ssh(
spi: widget.spi, spi: widget.spi,
initCmd: 'docker logs -f --tail 100 ${dItem.id}', initCmd: '${switch (_container.type) {
ContainerType.podman => 'podman',
ContainerType.docker => 'docker',
}} logs -f --tail 100 ${dItem.id}',
).go(context); ).go(context);
break; break;
case ContainerMenu.terminal: case ContainerMenu.terminal:

View File

@@ -9,7 +9,6 @@ import 'package:toolbox/core/channel/home_widget.dart';
import 'package:toolbox/core/extension/build.dart'; import 'package:toolbox/core/extension/build.dart';
import 'package:toolbox/core/extension/context/locale.dart'; import 'package:toolbox/core/extension/context/locale.dart';
import 'package:toolbox/core/route.dart'; import 'package:toolbox/core/route.dart';
import 'package:toolbox/data/model/app/github_id.dart';
import 'package:toolbox/data/model/app/tab.dart'; import 'package:toolbox/data/model/app/tab.dart';
import 'package:toolbox/data/res/build_data.dart'; import 'package:toolbox/data/res/build_data.dart';
import 'package:toolbox/data/res/github_id.dart'; import 'package:toolbox/data/res/github_id.dart';
@@ -17,6 +16,7 @@ import 'package:toolbox/data/res/misc.dart';
import 'package:toolbox/data/res/provider.dart'; import 'package:toolbox/data/res/provider.dart';
import 'package:toolbox/data/res/store.dart'; import 'package:toolbox/data/res/store.dart';
import 'package:toolbox/data/res/url.dart'; import 'package:toolbox/data/res/url.dart';
import 'package:toolbox/view/page/ssh/page.dart';
import 'package:wakelock_plus/wakelock_plus.dart'; import 'package:wakelock_plus/wakelock_plus.dart';
part 'appbar.dart'; part 'appbar.dart';
@@ -151,6 +151,7 @@ class _HomePageState extends State<HomePage>
physics: const NeverScrollableScrollPhysics(), physics: const NeverScrollableScrollPhysics(),
itemBuilder: (_, index) => AppTab.values[index].page, itemBuilder: (_, index) => AppTab.values[index].page,
onPageChanged: (value) { onPageChanged: (value) {
SSHPage.focusNode.unfocus();
if (!_switchingPage) { if (!_switchingPage) {
_selectIndex.value = value; _selectIndex.value = value;
} }
@@ -341,7 +342,7 @@ ${GithubIds.participants.map((e) => '[$e](${e.url})').join(' ')}
if (Stores.setting.autoCheckAppUpdate.fetch()) { if (Stores.setting.autoCheckAppUpdate.fetch()) {
AppUpdateIface.doUpdate( AppUpdateIface.doUpdate(
build: BuildData.build, build: BuildData.build,
url: '${Urls.cdnBase}/update.json', url: Urls.updateCfg,
context: context, context: context,
); );
} }

View File

@@ -94,7 +94,7 @@ final class _WearHomeState extends State<WearHome> with AfterLayoutMixin {
if (Stores.setting.autoCheckAppUpdate.fetch()) { if (Stores.setting.autoCheckAppUpdate.fetch()) {
AppUpdateIface.doUpdate( AppUpdateIface.doUpdate(
build: BuildData.build, build: BuildData.build,
url: '${Urls.cdnBase}/update.json', url: Urls.updateCfg,
context: context, context: context,
); );
} }

View File

@@ -305,7 +305,7 @@ class _SettingPageState extends State<SettingPage> {
_setting.primaryColor.put(color.value); _setting.primaryColor.put(color.value);
context.pop(); context.pop();
context.pop(); context.pop();
RebuildNodes.app.rebuild(); RNodes.app.build();
} }
// Widget _buildLaunchPage() { // Widget _buildLaunchPage() {
@@ -393,7 +393,7 @@ class _SettingPageState extends State<SettingPage> {
); );
if (selected != null) { if (selected != null) {
_setting.themeMode.put(selected); _setting.themeMode.put(selected);
RebuildNodes.app.rebuild(); RNodes.app.build();
} }
}, },
trailing: ValBuilder( trailing: ValBuilder(
@@ -442,7 +442,7 @@ class _SettingPageState extends State<SettingPage> {
onPressed: () { onPressed: () {
_setting.fontPath.delete(); _setting.fontPath.delete();
context.pop(); context.pop();
RebuildNodes.app.rebuild(); RNodes.app.build();
}, },
child: Text(l10n.clear), child: Text(l10n.clear),
) )
@@ -466,7 +466,7 @@ class _SettingPageState extends State<SettingPage> {
} }
context.pop(); context.pop();
RebuildNodes.app.rebuild(); RNodes.app.build();
} }
Widget _buildTermFontSize() { Widget _buildTermFontSize() {
@@ -536,7 +536,7 @@ class _SettingPageState extends State<SettingPage> {
if (selected != null) { if (selected != null) {
_setting.locale.put(selected.code); _setting.locale.put(selected.code);
context.pop(); context.pop();
RebuildNodes.app.rebuild(); RNodes.app.build();
} }
}, },
trailing: ListenBuilder( trailing: ListenBuilder(
@@ -609,7 +609,7 @@ class _SettingPageState extends State<SettingPage> {
subtitle: Text(l10n.fullScreenTip, style: UIs.textGrey), subtitle: Text(l10n.fullScreenTip, style: UIs.textGrey),
trailing: StoreSwitch( trailing: StoreSwitch(
prop: _setting.fullScreen, prop: _setting.fullScreen,
callback: (_) => RebuildNodes.app.rebuild(), callback: (_) => RNodes.app.build(),
), ),
); );
} }
@@ -820,7 +820,7 @@ class _SettingPageState extends State<SettingPage> {
return; return;
} }
_setting.textFactor.put(val); _setting.textFactor.put(val);
RebuildNodes.app.rebuild(); RNodes.app.build();
context.pop(); context.pop();
} }
@@ -1066,6 +1066,7 @@ class _SettingPageState extends State<SettingPage> {
leading: const Icon(MingCute.more_3_fill), leading: const Icon(MingCute.more_3_fill),
title: Text(l10n.more), title: Text(l10n.more),
children: [ children: [
_buildBeta(),
_buildWakeLock(), _buildWakeLock(),
if (isAndroid || isIOS) _buildCollectUsage(), if (isAndroid || isIOS) _buildCollectUsage(),
_buildCollapseUI(), _buildCollapseUI(),
@@ -1195,4 +1196,12 @@ class _SettingPageState extends State<SettingPage> {
}, },
); );
} }
Widget _buildBeta() {
return ListTile(
title: const Text('Beta Program'),
subtitle: Text(l10n.acceptBeta, style: UIs.textGrey),
trailing: StoreSwitch(prop: _setting.betaTest),
);
}
} }

View File

@@ -1,3 +1,4 @@
import 'dart:ui';
import 'package:fl_lib/fl_lib.dart'; import 'package:fl_lib/fl_lib.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:toolbox/core/extension/context/locale.dart'; import 'package:toolbox/core/extension/context/locale.dart';
@@ -22,6 +23,29 @@ class _ServerOrderPageState extends State<ServerOrderPage> {
); );
} }
Widget _proxyDecorator(Widget child, int index, Animation<double> animation) {
return AnimatedBuilder(
animation: animation,
builder: (BuildContext context, Widget? child) {
final double animValue = Curves.easeInOut.transform(animation.value);
final double elevation = lerpDouble(1, 6, animValue)!;
final double scale = lerpDouble(1, 1.02, animValue)!;
return Transform.scale(
scale: scale,
// Create a Card based on the color and the content of the dragged one
// and set its elevation to the animated value.
child: Card(
elevation: elevation,
// color: cards[index].color,
// child: cards[index].child,
child: _buildCardTile(index),
),
);
},
// child: child,
);
}
Widget _buildBody() { Widget _buildBody() {
if (Pros.server.serverOrder.isEmpty) { if (Pros.server.serverOrder.isEmpty) {
return Center(child: Text(l10n.noServerAvailable)); return Center(child: Text(l10n.noServerAvailable));
@@ -37,28 +61,36 @@ class _ServerOrderPageState extends State<ServerOrderPage> {
}), }),
padding: const EdgeInsets.symmetric(horizontal: 7, vertical: 3), padding: const EdgeInsets.symmetric(horizontal: 7, vertical: 3),
buildDefaultDragHandles: false, buildDefaultDragHandles: false,
itemBuilder: (_, idx) => _buildItem(idx, Pros.server.serverOrder[idx]), itemBuilder: (_, idx) => _buildItem(idx),
itemCount: Pros.server.serverOrder.length, itemCount: Pros.server.serverOrder.length,
proxyDecorator: _proxyDecorator,
); );
} }
Widget _buildItem(int index, String id) { Widget _buildItem(int index) {
return ReorderableDelayedDragStartListener(
key: ValueKey('$index'),
index: index,
child: CardX(child: _buildCardTile(index)),
);
}
Widget _buildCardTile(int index) {
final id = Pros.server.serverOrder[index];
final spi = Pros.server.pick(id: id)?.spi; final spi = Pros.server.pick(id: id)?.spi;
if (spi == null) { if (spi == null) {
return const SizedBox(); return const SizedBox();
} }
return ReorderableDelayedDragStartListener(
key: ValueKey('$index'), return ListTile(
index: index, title: Text(spi.name),
child: CardX( subtitle: Text(spi.id, style: UIs.textGrey),
child: ListTile( leading: CircleAvatar(
title: Text(spi.name), child: Text(spi.name[0]),
subtitle: Text(spi.id, style: UIs.textGrey), ),
leading: CircleAvatar( trailing: ReorderableDragStartListener(
child: Text(spi.name[0]), index: index,
), child: const Icon(Icons.drag_handle),
trailing: const Icon(Icons.drag_handle),
),
), ),
); );
} }

View File

@@ -1,6 +1,7 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'package:after_layout/after_layout.dart';
import 'package:dartssh2/dartssh2.dart'; import 'package:dartssh2/dartssh2.dart';
import 'package:fl_lib/fl_lib.dart'; import 'package:fl_lib/fl_lib.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
@@ -41,13 +42,16 @@ class SSHPage extends StatefulWidget {
this.terminalKey, this.terminalKey,
}); });
static final focusNode = FocusNode();
@override @override
State<SSHPage> createState() => _SSHPageState(); State<SSHPage> createState() => SSHPageState();
} }
const _horizonPadding = 7.0; const _horizonPadding = 7.0;
class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin { class SSHPageState extends State<SSHPage>
with AutomaticKeepAliveClientMixin, AfterLayoutMixin {
final _keyboard = VirtKeyProvider(); final _keyboard = VirtKeyProvider();
late final _terminal = Terminal(inputHandler: _keyboard); late final _terminal = Terminal(inputHandler: _keyboard);
final TerminalController _terminalController = TerminalController(); final TerminalController _terminalController = TerminalController();
@@ -71,13 +75,6 @@ class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
super.initState(); super.initState();
_initStoredCfg(); _initStoredCfg();
_initVirtKeys(); _initVirtKeys();
Future.delayed(const Duration(milliseconds: 77), () async {
_showHelp();
await _initTerminal();
if (Stores.setting.sshWakeLock.fetch()) WakelockPlus.enable();
});
} }
@override @override
@@ -151,7 +148,7 @@ class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
textStyle: _terminalStyle, textStyle: _terminalStyle,
theme: _terminalTheme, theme: _terminalTheme,
deleteDetection: isMobile, deleteDetection: isMobile,
autofocus: true, autofocus: false,
keyboardAppearance: _isDark ? Brightness.dark : Brightness.light, keyboardAppearance: _isDark ? Brightness.dark : Brightness.light,
showToolbar: isMobile, showToolbar: isMobile,
viewOffset: Offset( viewOffset: Offset(
@@ -159,6 +156,7 @@ class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
CustomAppBar.barHeight ?? _media.padding.top, CustomAppBar.barHeight ?? _media.padding.top,
), ),
hideScrollBar: false, hideScrollBar: false,
focusNode: SSHPage.focusNode,
), ),
), ),
); );
@@ -429,6 +427,8 @@ class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
} }
} }
SSHPage.focusNode.requestFocus();
await session.done; await session.done;
if (mounted && widget.notFromTab) { if (mounted && widget.notFromTab) {
context.pop(); context.pop();
@@ -516,21 +516,29 @@ class _SSHPageState extends State<SSHPage> with AutomaticKeepAliveClientMixin {
} }
Future<void> _showHelp() async { Future<void> _showHelp() async {
if (!Stores.setting.sshTermHelpShown.fetch()) { if (Stores.setting.sshTermHelpShown.fetch()) return;
await context.showRoundDialog(
title: l10n.doc, return await context.showRoundDialog(
child: Text(l10n.sshTermHelp), title: l10n.doc,
actions: [ child: Text(l10n.sshTermHelp),
TextButton( actions: [
onPressed: () { TextButton(
Stores.setting.sshTermHelpShown.put(true); onPressed: () {
context.pop(); Stores.setting.sshTermHelpShown.put(true);
}, context.pop();
child: Text(l10n.noPromptAgain), },
), child: Text(l10n.noPromptAgain),
], ),
); ],
} );
}
@override
FutureOr<void> afterFirstLayout(BuildContext context) async {
await _showHelp();
await _initTerminal();
if (Stores.setting.sshWakeLock.fetch()) WakelockPlus.enable();
} }
} }

View File

@@ -1,5 +1,6 @@
import 'package:fl_lib/fl_lib.dart'; import 'package:fl_lib/fl_lib.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
import 'package:icons_plus/icons_plus.dart';
import 'package:provider/provider.dart'; import 'package:provider/provider.dart';
import 'package:toolbox/core/extension/context/locale.dart'; import 'package:toolbox/core/extension/context/locale.dart';
import 'package:toolbox/core/route.dart'; import 'package:toolbox/core/route.dart';
@@ -15,37 +16,37 @@ class SSHTabPage extends StatefulWidget {
State<SSHTabPage> createState() => _SSHTabPageState(); State<SSHTabPage> createState() => _SSHTabPageState();
} }
typedef _TabMap = Map<String, ({Widget page, GlobalKey<SSHPageState>? key})>;
class _SSHTabPageState extends State<SSHTabPage> class _SSHTabPageState extends State<SSHTabPage>
with TickerProviderStateMixin, AutomaticKeepAliveClientMixin { with TickerProviderStateMixin, AutomaticKeepAliveClientMixin {
late final _tabMap = <String, ({Widget page})>{ late final _TabMap _tabMap = {
l10n.add: (page: _buildAddPage()), l10n.add: (page: _buildAddPage(), key: null),
}; };
late var _tabController = TabController( final _pageCtrl = PageController();
length: _tabMap.length, final _fabVN = 0.vn;
vsync: this, final _tabRN = RNode();
);
final _fabRN = ValueNotifier(0);
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
super.build(context); super.build(context);
return Scaffold( return Scaffold(
appBar: TabBar( appBar: PreferredSizeListenBuilder(
controller: _tabController, listenable: _tabRN,
tabs: _tabMap.keys.map(_buildTabItem).toList(), builder: () {
isScrollable: true, return _TabBar(
tabAlignment: TabAlignment.start, idxVN: _fabVN,
dividerColor: Colors.transparent, map: _tabMap,
onTap: (value) { onTap: _onTapTab,
_fabRN.value = value; onClose: _onTapClose,
FocusScope.of(context).unfocus(); );
}, },
), ),
body: _buildBody(), body: _buildBody(),
floatingActionButton: ListenableBuilder( floatingActionButton: ValBuilder(
listenable: _fabRN, listenable: _fabVN,
builder: (_, __) { builder: (idx) {
if (_fabRN.value != 0) return const SizedBox(); if (idx != 0) return const SizedBox();
return FloatingActionButton( return FloatingActionButton(
heroTag: 'sshAddServer', heroTag: 'sshAddServer',
onPressed: () => AppRoutes.serverEdit().go(context), onPressed: () => AppRoutes.serverEdit().go(context),
@@ -57,49 +58,40 @@ class _SSHTabPageState extends State<SSHTabPage>
); );
} }
Widget _buildTabItem(String e) { void _onTapTab(int idx) async {
if (e == l10n.add) { await _toPage(idx);
return Tab(child: Text(e)); SSHPage.focusNode.unfocus();
} }
return Tab(
child: Row( void _onTapClose(String name) async {
children: [ SSHPage.focusNode.unfocus();
Text(e),
UIs.width7, final confirm = await showDialog<bool>(
IconBtn( context: context,
icon: Icons.close, builder: (context) {
onTap: () async { return AlertDialog(
final confirm = await showDialog<bool>( title: Text(l10n.attention),
context: context, content: Text('${l10n.close} SSH ${l10n.conn}($name) ?'),
builder: (context) { actions: [
return AlertDialog( TextButton(
title: Text(l10n.attention), onPressed: () => context.pop(true),
content: Text('${l10n.close} SSH ${l10n.conn}($e) ?'), child: Text(l10n.ok, style: UIs.textRed),
actions: [ ),
TextButton( TextButton(
onPressed: () => context.pop(true), onPressed: () => context.pop(false),
child: Text(l10n.ok, style: UIs.textRed), child: Text(l10n.cancel),
), ),
TextButton( ],
onPressed: () => context.pop(false), );
child: Text(l10n.cancel), },
),
],
);
},
);
Future.delayed(const Duration(milliseconds: 50),
FocusScope.of(context).unfocus);
if (confirm != true) {
return;
}
_tabMap.remove(e);
_refreshTabs();
},
),
],
),
); );
Future.delayed(Durations.short1, FocusScope.of(context).unfocus);
if (confirm != true) return;
_tabMap.remove(name);
_tabRN.build();
_pageCtrl.previousPage(
duration: Durations.medium1, curve: Curves.fastEaseInToSlowEaseOut);
} }
Widget _buildAddPage() { Widget _buildAddPage() {
@@ -134,44 +126,157 @@ class _SSHTabPageState extends State<SSHTabPage>
} }
Widget _buildBody() { Widget _buildBody() {
return TabBarView( return ListenBuilder(
physics: const NeverScrollableScrollPhysics(), listenable: _tabRN,
controller: _tabController, builder: () {
children: _tabMap.values.map((e) => e.page).toList(), return PageView.builder(
physics: const NeverScrollableScrollPhysics(),
controller: _pageCtrl,
itemCount: _tabMap.length,
itemBuilder: (_, idx) {
final name = _tabMap.keys.elementAt(idx);
return _tabMap[name]?.page ?? UIs.placeholder;
},
onPageChanged: (value) => _fabVN.value = value,
);
},
); );
} }
void _onTapInitCard(ServerPrivateInfo spi) { void _onTapInitCard(ServerPrivateInfo spi) async {
final name = () { final name = () {
if (_tabMap.containsKey(spi.name)) { final reg = RegExp('${spi.name}\\((\\d+)\\)');
return '${spi.name}(${_tabMap.length + 1})'; final idxs = _tabMap.keys
.map((e) => reg.firstMatch(e))
.map((e) => e?.group(1))
.where((e) => e != null);
if (idxs.isEmpty) {
return _tabMap.keys.contains(spi.name) ? '${spi.name}(1)' : spi.name;
}
final biggest = idxs.reduce((a, b) => a!.length > b!.length ? a : b);
final biggestInt = int.tryParse(biggest ?? '0');
if (biggestInt != null && biggestInt > 0) {
return '${spi.name}(${biggestInt + 1})';
} }
return spi.name; return spi.name;
}(); }();
final key = GlobalKey<SSHPageState>();
_tabMap[name] = ( _tabMap[name] = (
page: SSHPage( page: SSHPage(
// Keep it, or the Flutter will works unexpectedly
key: key,
spi: spi, spi: spi,
notFromTab: false, notFromTab: false,
onSessionEnd: () { onSessionEnd: () {
_tabMap.remove(name); _tabMap.remove(name);
_refreshTabs();
}, },
), ),
key: key,
); );
_refreshTabs(); _tabRN.build();
final idx = _tabMap.length - 1; // Wait for the page to be built
_tabController.animateTo(idx); await Future.delayed(Durations.short3);
_fabRN.value = idx; final idx = _tabMap.keys.toList().indexOf(name);
await _toPage(idx);
} }
void _refreshTabs() { Future<void> _toPage(int idx) => _pageCtrl.animateToPage(idx,
_tabController = TabController( duration: Durations.short3, curve: Curves.fastEaseInToSlowEaseOut);
length: _tabMap.length,
vsync: this,
);
setState(() {});
}
@override @override
bool get wantKeepAlive => true; bool get wantKeepAlive => true;
} }
final class _TabBar extends StatelessWidget implements PreferredSizeWidget {
const _TabBar({
required this.idxVN,
required this.map,
required this.onTap,
required this.onClose,
});
final ValueNotifier<int> idxVN;
final _TabMap map;
final void Function(int idx) onTap;
final void Function(String name) onClose;
List<String> get names => map.keys.toList();
@override
Size get preferredSize => const Size.fromHeight(48);
@override
Widget build(BuildContext context) {
return ListenBuilder(
listenable: idxVN,
builder: () {
return ListView.separated(
scrollDirection: Axis.horizontal,
padding: const EdgeInsets.symmetric(horizontal: 11, vertical: 5),
itemCount: names.length,
itemBuilder: (_, idx) => _buillItem(idx),
separatorBuilder: (_, __) => Padding(
padding: const EdgeInsets.symmetric(vertical: 17),
child: Container(
color: const Color.fromARGB(61, 158, 158, 158),
width: 3,
),
),
);
},
);
}
Widget _buillItem(int idx) {
final name = names[idx];
final selected = idxVN.value == idx;
final color = selected ? null : Colors.grey;
final Widget child;
if (idx == 0) {
child = Padding(
padding: const EdgeInsets.symmetric(horizontal: 13),
child: Icon(MingCute.add_circle_fill, size: 17, color: color),
);
} else {
final text = Text(
name,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: TextStyle(color: color),
softWrap: false,
textAlign: TextAlign.center,
textWidthBasis: TextWidthBasis.parent,
);
child = AnimatedContainer(
width: selected ? 90 : 50,
duration: Durations.medium3,
curve: Curves.fastEaseInToSlowEaseOut,
child: switch (selected) {
true => Row(
mainAxisSize: MainAxisSize.min,
mainAxisAlignment: MainAxisAlignment.start,
children: [
SizedBox(width: 55, child: text),
if (selected)
FadeIn(
child: IconBtn(
icon: MingCute.close_circle_fill,
color: color,
onTap: () => onClose(name),
),
),
],
),
false => Center(child: text),
},
).paddingOnly(left: 3, right: 3);
}
return InkWell(
borderRadius: BorderRadius.circular(13),
onTap: () => onTap(idx),
child: child,
).paddingSymmetric(horizontal: 13);
}
}

View File

@@ -472,19 +472,41 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
void _delete(SftpName file) { void _delete(SftpName file) {
context.pop(); context.pop();
final isDir = file.attr.isDirectory; final isDir = file.attr.isDirectory;
final useRmr = Stores.setting.sftpRmrDir.fetch(); var useRmr = Stores.setting.sftpRmrDir.fetch();
final text = () { final text = () {
if (isDir && !useRmr) { if (isDir && !useRmr) {
return l10n.askContinue( return l10n.askContinue('${l10n.delete} ${file.filename}');
'${l10n.dirEmpty}\n${l10n.delete} '
'${file.filename}',
);
} }
return l10n.askContinue('${l10n.delete} ${file.filename}'); return l10n.askContinue('${l10n.delete} ${file.filename}');
}(); }();
// Most users don't know that SFTP can't delete a directory which is not
// empty, so we provide a checkbox to let user choose to use `rm -r` or not
context.showRoundDialog( context.showRoundDialog(
child: Text(text),
title: l10n.attention, title: l10n.attention,
child: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
ListTile(
title: Text(text),
),
if (!useRmr)
StatefulBuilder(
builder: (_, setState) {
return CheckboxListTile(
title: Text(l10n.sftpRmrDirSummary),
value: useRmr,
onChanged: (val) {
setState(() {
useRmr = val ?? false;
});
},
);
},
),
],
),
actions: [ actions: [
TextButton( TextButton(
onPressed: () => context.pop(), onPressed: () => context.pop(),

View File

@@ -471,7 +471,7 @@
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 923; CURRENT_PROJECT_VERSION = 948;
DEVELOPMENT_TEAM = BA88US33G6; DEVELOPMENT_TEAM = BA88US33G6;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Server Box"; INFOPLIST_KEY_CFBundleDisplayName = "Server Box";
@@ -481,7 +481,7 @@
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 10.15; MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 1.0.923; MARKETING_VERSION = 1.0.948;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "Server Box"; PRODUCT_NAME = "Server Box";
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
@@ -608,7 +608,7 @@
CODE_SIGN_IDENTITY = "Apple Development"; CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic; CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 923; CURRENT_PROJECT_VERSION = 948;
DEVELOPMENT_TEAM = BA88US33G6; DEVELOPMENT_TEAM = BA88US33G6;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "Server Box"; INFOPLIST_KEY_CFBundleDisplayName = "Server Box";
@@ -618,7 +618,7 @@
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 10.15; MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 1.0.923; MARKETING_VERSION = 1.0.948;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "Server Box"; PRODUCT_NAME = "Server Box";
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";
@@ -638,7 +638,7 @@
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "3rd Party Mac Developer Application"; "CODE_SIGN_IDENTITY[sdk=macosx*]" = "3rd Party Mac Developer Application";
CODE_SIGN_STYLE = Manual; CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES; COMBINE_HIDPI_IMAGES = YES;
CURRENT_PROJECT_VERSION = 923; CURRENT_PROJECT_VERSION = 948;
DEVELOPMENT_TEAM = ""; DEVELOPMENT_TEAM = "";
"DEVELOPMENT_TEAM[sdk=macosx*]" = BA88US33G6; "DEVELOPMENT_TEAM[sdk=macosx*]" = BA88US33G6;
INFOPLIST_FILE = Runner/Info.plist; INFOPLIST_FILE = Runner/Info.plist;
@@ -649,7 +649,7 @@
"@executable_path/../Frameworks", "@executable_path/../Frameworks",
); );
MACOSX_DEPLOYMENT_TARGET = 10.15; MACOSX_DEPLOYMENT_TARGET = 10.15;
MARKETING_VERSION = 1.0.923; MARKETING_VERSION = 1.0.948;
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox; PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
PRODUCT_NAME = "Server Box"; PRODUCT_NAME = "Server Box";
PROVISIONING_PROFILE_SPECIFIER = ""; PROVISIONING_PROFILE_SPECIFIER = "";

View File

@@ -401,8 +401,8 @@ packages:
dependency: "direct main" dependency: "direct main"
description: description:
path: "." path: "."
ref: "v1.0.31" ref: "v1.0.39"
resolved-ref: f6322c5c2fad5230d1a882e79d52d1a0d246b8f4 resolved-ref: "49fc10b39e390f4ecc3ee4f16f0926460b77adac"
url: "https://github.com/lppcg/fl_lib" url: "https://github.com/lppcg/fl_lib"
source: git source: git
version: "0.0.1" version: "0.0.1"

View File

@@ -53,7 +53,7 @@ dependencies:
fl_lib: fl_lib:
git: git:
url: https://github.com/lppcg/fl_lib url: https://github.com/lppcg/fl_lib
ref: v1.0.31 ref: v1.0.39
dependency_overrides: dependency_overrides:
# dartssh2: # dartssh2:

32
test/container_test.dart Normal file
View File

@@ -0,0 +1,32 @@
import 'package:flutter_test/flutter_test.dart';
import 'package:toolbox/data/model/container/ps.dart';
void main() {
test('docker ps parse', () {
const raw = '''
CONTAINER ID STATUS NAMES IMAGE
0e9e2ef860d2 Up 2 hours hbbs rustdesk/rustdesk-server:latest
9a4df3ed340c Up 41 minutes hbbr rustdesk/rustdesk-server:latest
fa1215b4be74 Up 12 hours firefly uusec/firefly:latest
''';
final lines = raw.split('\n');
const ids = ['0e9e2ef860d2', '9a4df3ed340c', 'fa1215b4be74'];
const names = ['hbbs', 'hbbr', 'firefly'];
const images = [
'rustdesk/rustdesk-server:latest',
'rustdesk/rustdesk-server:latest',
'uusec/firefly:latest'
];
const states = ['Up 2 hours', 'Up 41 minutes', 'Up 12 hours'];
for (var idx = 1; idx < lines.length; idx++) {
final raw = lines[idx];
if (raw.isEmpty) continue;
final ps = DockerPs.parse(raw);
expect(ps.id, ids[idx - 1]);
expect(ps.names, names[idx - 1]);
expect(ps.image, images[idx - 1]);
expect(ps.state, states[idx - 1]);
expect(ps.running, true);
}
});
}