mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2026-02-15 04:34:34 +01:00
Compare commits
26 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9cdfd86f70 | ||
|
|
e709262477 | ||
|
|
20d2817c8d | ||
|
|
a7269ee68a | ||
|
|
552e2738cd | ||
|
|
216d64e3eb | ||
|
|
f903a1da55 | ||
|
|
f2b1158eda | ||
|
|
1d797f8d16 | ||
|
|
9e503e4901 | ||
|
|
bf22309fe5 | ||
|
|
a3537a67c2 | ||
|
|
8ba888a5b3 | ||
|
|
fd2d59b1e0 | ||
|
|
5c2cc5e5e4 | ||
|
|
fe7ea04011 | ||
|
|
19baff5dde | ||
|
|
0ac6984576 | ||
|
|
de0eedb2cb | ||
|
|
30dddf462e | ||
|
|
abee470afc | ||
|
|
42d8505504 | ||
|
|
3c481cf61c | ||
|
|
55c96031f7 | ||
|
|
2ea061d324 | ||
|
|
2747df64dd |
@@ -159,10 +159,16 @@ abstract class S {
|
||||
/// **'Backup'**
|
||||
String get backup;
|
||||
|
||||
/// No description provided for @backupAndRestore.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Backup and Restore'**
|
||||
String get backupAndRestore;
|
||||
|
||||
/// No description provided for @backupTip.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'The exported data is simply encrypted. \nPlease keep it safe.\nRestoring will not overwrite existing data (except setting).'**
|
||||
/// **'The exported data is simply encrypted. \nPlease keep it safe.'**
|
||||
String get backupTip;
|
||||
|
||||
/// No description provided for @backupVersionNotMatch.
|
||||
@@ -171,6 +177,12 @@ abstract class S {
|
||||
/// **'Backup version is not match.'**
|
||||
String get backupVersionNotMatch;
|
||||
|
||||
/// No description provided for @bgRun.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Run in backgroud'**
|
||||
String get bgRun;
|
||||
|
||||
/// No description provided for @cancel.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
@@ -507,12 +519,6 @@ abstract class S {
|
||||
/// **'Import'**
|
||||
String get import;
|
||||
|
||||
/// No description provided for @importAndExport.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Import and Export'**
|
||||
String get importAndExport;
|
||||
|
||||
/// No description provided for @inputDomainHere.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
@@ -606,7 +612,7 @@ abstract class S {
|
||||
/// No description provided for @madeWithLove.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'\nMade with ❤️ by {myGithub}'**
|
||||
/// **'Made with ❤️ by {myGithub}'**
|
||||
String madeWithLove(Object myGithub);
|
||||
|
||||
/// No description provided for @max.
|
||||
@@ -735,6 +741,12 @@ abstract class S {
|
||||
/// **'Open'**
|
||||
String get open;
|
||||
|
||||
/// No description provided for @paste.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Paste'**
|
||||
String get paste;
|
||||
|
||||
/// No description provided for @path.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
@@ -999,6 +1011,12 @@ abstract class S {
|
||||
/// **'Are you sure to delete [{name}]?'**
|
||||
String sureDelete(Object name);
|
||||
|
||||
/// No description provided for @sureDirEmpty.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Make sure dir is empty.'**
|
||||
String get sureDirEmpty;
|
||||
|
||||
/// No description provided for @sureNoPwd.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
|
||||
@@ -38,11 +38,17 @@ class SEn extends S {
|
||||
String get backup => 'Backup';
|
||||
|
||||
@override
|
||||
String get backupTip => 'The exported data is simply encrypted. \nPlease keep it safe.\nRestoring will not overwrite existing data (except setting).';
|
||||
String get backupAndRestore => 'Backup and Restore';
|
||||
|
||||
@override
|
||||
String get backupTip => 'The exported data is simply encrypted. \nPlease keep it safe.';
|
||||
|
||||
@override
|
||||
String get backupVersionNotMatch => 'Backup version is not match.';
|
||||
|
||||
@override
|
||||
String get bgRun => 'Run in backgroud';
|
||||
|
||||
@override
|
||||
String get cancel => 'Cancel';
|
||||
|
||||
@@ -229,9 +235,6 @@ class SEn extends S {
|
||||
@override
|
||||
String get import => 'Import';
|
||||
|
||||
@override
|
||||
String get importAndExport => 'Import and Export';
|
||||
|
||||
@override
|
||||
String get inputDomainHere => 'Input Domain here';
|
||||
|
||||
@@ -281,7 +284,7 @@ class SEn extends S {
|
||||
|
||||
@override
|
||||
String madeWithLove(Object myGithub) {
|
||||
return '\nMade with ❤️ by $myGithub';
|
||||
return 'Made with ❤️ by $myGithub';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -347,6 +350,9 @@ class SEn extends S {
|
||||
@override
|
||||
String get open => 'Open';
|
||||
|
||||
@override
|
||||
String get paste => 'Paste';
|
||||
|
||||
@override
|
||||
String get path => 'Path';
|
||||
|
||||
@@ -489,6 +495,9 @@ class SEn extends S {
|
||||
return 'Are you sure to delete [$name]?';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sureDirEmpty => 'Make sure dir is empty.';
|
||||
|
||||
@override
|
||||
String get sureNoPwd => 'Are you sure to use no password?';
|
||||
|
||||
|
||||
@@ -38,11 +38,17 @@ class SZh extends S {
|
||||
String get backup => '备份';
|
||||
|
||||
@override
|
||||
String get backupTip => '导出的数据仅进行了简单加密,请妥善保管。\n除了设置项,恢复的数据不会覆盖现有数据。';
|
||||
String get backupAndRestore => '备份和恢复';
|
||||
|
||||
@override
|
||||
String get backupTip => '导出的数据仅进行了简单加密,请妥善保管。';
|
||||
|
||||
@override
|
||||
String get backupVersionNotMatch => '备份版本不匹配,无法恢复';
|
||||
|
||||
@override
|
||||
String get bgRun => '后台运行';
|
||||
|
||||
@override
|
||||
String get cancel => '取消';
|
||||
|
||||
@@ -229,9 +235,6 @@ class SZh extends S {
|
||||
@override
|
||||
String get import => '导入';
|
||||
|
||||
@override
|
||||
String get importAndExport => '导入或导出';
|
||||
|
||||
@override
|
||||
String get inputDomainHere => '在这里输入域名';
|
||||
|
||||
@@ -281,7 +284,7 @@ class SZh extends S {
|
||||
|
||||
@override
|
||||
String madeWithLove(Object myGithub) {
|
||||
return '\n用❤️制作 by $myGithub';
|
||||
return '用❤️制作 by $myGithub';
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -347,6 +350,9 @@ class SZh extends S {
|
||||
@override
|
||||
String get open => '打开';
|
||||
|
||||
@override
|
||||
String get paste => '粘贴';
|
||||
|
||||
@override
|
||||
String get path => '路径';
|
||||
|
||||
@@ -489,6 +495,9 @@ class SZh extends S {
|
||||
return '确定删除[$name]?';
|
||||
}
|
||||
|
||||
@override
|
||||
String get sureDirEmpty => '请确保文件夹为空';
|
||||
|
||||
@override
|
||||
String get sureNoPwd => '确认使用无密码?';
|
||||
|
||||
|
||||
18
README.md
18
README.md
@@ -34,14 +34,18 @@ Especially thanks to <a href="https://github.com/TerminalStudio/dartssh2">dartss
|
||||
- [x] Status charts
|
||||
- [x] `Ping` and etc.
|
||||
- [x] i18n (English, Chinese)
|
||||
- **Welcome contribution** :)
|
||||
- [How to contribute?](#l10n-guide)
|
||||
- Welcome contribution :), [How to contribute?](#l10n-guide)
|
||||
- [x] Desktop support
|
||||
|
||||
|
||||
## 📩 Push
|
||||
You need to install [ServerBoxMonitor](https://github.com/lollipopkit/server_box_monitor) on your servers.
|
||||
And config iOS / Webhook to push server status to your portable device without using ServerBox app.
|
||||
You need to install [ServerBoxMonitor](https://github.com/lollipopkit/server_box_monitor) on your servers.
|
||||
And config `iOS / Webhook / ServerChan` to push server status to your portable device without using ServerBox app.
|
||||
|
||||
|
||||
## 🆘 Help
|
||||
If you have any question or feature request, please open a [discussion](https://github.com/lollipopkit/flutter_server_box/discussions/new/choose).
|
||||
If ServerBox app has any bug, please open an [issue](https://github.com/lollipopkit/flutter_server_box/issues/new).
|
||||
|
||||
|
||||
## 📱 ScreenShots
|
||||
@@ -82,12 +86,12 @@ And config iOS / Webhook to push server status to your portable device without u
|
||||
## 🖥 Platform
|
||||
Status|Platform
|
||||
--- | ---
|
||||
Full Support|Android/iOS
|
||||
Support, but not tested|macOS/Windows/Linux
|
||||
Full Support| Android / iOS / macOS
|
||||
Support, but not tested| Windows / Linux
|
||||
|
||||
|
||||
## l10n guide
|
||||
1. Fork this repo and clone it to your local machine.
|
||||
1. Fork this repo and clone forked repo to your local machine.
|
||||
2. Create `arb` file in `lib/l10n/` directory
|
||||
- File name should be `intl_XX.arb`, where `XX` is the language code. Such as `intl_en.arb` for English and `intl_zh.arb` for Chinese.
|
||||
3. Add content to the file. You can refer to `intl_en.arb` and `intl_zh.arb` for the format.
|
||||
|
||||
19
README_zh.md
19
README_zh.md
@@ -33,15 +33,20 @@
|
||||
- [x] `Docker & 包` 管理器
|
||||
- [x] 状态图表
|
||||
- [x] `Ping` 和 更多
|
||||
- [x] 本地化 (英语, 中文)
|
||||
- **欢迎贡献** :)
|
||||
- [怎么贡献?](#l10n)
|
||||
- [x] 本地化 ( 英语, 中文 )
|
||||
- 欢迎贡献 :),[怎么贡献?](#l10n)
|
||||
- [x] 桌面端支持
|
||||
|
||||
|
||||
## 📩 推送
|
||||
你需要在你的服务器上安装 [ServerBoxMonitor](https://github.com/lollipopkit/server_box_monitor)。
|
||||
并且配置 iOS / Webhook 推送服务,这样,你可以在不使用 ServerBox app 时获取服务器状态。
|
||||
你需要在你的服务器上安装 [ServerBoxMonitor](https://github.com/lollipopkit/server_box_monitor)。
|
||||
并且配置 `iOS / Webhook / Server酱` 推送服务,这样,你可以在不使用 ServerBox app 时获取服务器状态。
|
||||
|
||||
|
||||
## 🆘 帮助
|
||||
如果你有任何问题或者功能请求,请在 [讨论](https://github.com/lollipopkit/flutter_server_box/discussions/new/choose) 中交流。
|
||||
如果 ServerBox app 有任何 bug,请在 [问题](https://github.com/lollipopkit/flutter_server_box/issues/new) 中反馈。
|
||||
|
||||
|
||||
## 📱 截屏
|
||||
<table>
|
||||
@@ -81,8 +86,8 @@
|
||||
## 🖥 平台
|
||||
状态|平台
|
||||
--- | ---
|
||||
完整支持|Android/iOS
|
||||
可能支持,未测试|macOS/Windows/Linux
|
||||
完整支持 | Android / iOS / macOS
|
||||
可能支持,未测试 | Windows / Linux
|
||||
|
||||
|
||||
## l10n
|
||||
|
||||
@@ -1,6 +1,23 @@
|
||||
package tech.lolli.toolbox
|
||||
|
||||
import io.flutter.embedding.android.FlutterActivity
|
||||
import io.flutter.embedding.engine.FlutterEngine
|
||||
import io.flutter.plugin.common.MethodChannel
|
||||
|
||||
class MainActivity: FlutterActivity() {
|
||||
class MainActivity : FlutterActivity() {
|
||||
override fun configureFlutterEngine(flutterEngine: FlutterEngine) {
|
||||
super.configureFlutterEngine(flutterEngine)
|
||||
val binaryMessenger = flutterEngine.dartExecutor.binaryMessenger
|
||||
|
||||
MethodChannel(binaryMessenger, "tech.lolli.toolbox/app_retain").apply {
|
||||
setMethodCallHandler { method, result ->
|
||||
if (method.method == "sendToBackground") {
|
||||
moveTaskToBack(true)
|
||||
result.success(null)
|
||||
} else {
|
||||
result.notImplemented()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
1
apk.sksl.json
Normal file
1
apk.sksl.json
Normal file
File diff suppressed because one or more lines are too long
@@ -359,15 +359,15 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||
CURRENT_PROJECT_VERSION = 243;
|
||||
CURRENT_PROJECT_VERSION = 269;
|
||||
DEVELOPMENT_TEAM = BA88US33G6;
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0.243;
|
||||
MARKETING_VERSION = 1.0.269;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
@@ -490,15 +490,15 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||
CURRENT_PROJECT_VERSION = 243;
|
||||
CURRENT_PROJECT_VERSION = 269;
|
||||
DEVELOPMENT_TEAM = BA88US33G6;
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0.243;
|
||||
MARKETING_VERSION = 1.0.269;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
@@ -515,15 +515,15 @@
|
||||
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
|
||||
CLANG_ENABLE_MODULES = YES;
|
||||
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
|
||||
CURRENT_PROJECT_VERSION = 243;
|
||||
CURRENT_PROJECT_VERSION = 269;
|
||||
DEVELOPMENT_TEAM = BA88US33G6;
|
||||
ENABLE_BITCODE = NO;
|
||||
INFOPLIST_FILE = Runner/Info.plist;
|
||||
INFOPLIST_FILE = "Runner/Info-$(CONFIGURATION).plist";
|
||||
LD_RUNPATH_SEARCH_PATHS = (
|
||||
"$(inherited)",
|
||||
"@executable_path/Frameworks",
|
||||
);
|
||||
MARKETING_VERSION = 1.0.243;
|
||||
MARKETING_VERSION = 1.0.269;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.lollipopkit.toolbox;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
SWIFT_OBJC_BRIDGING_HEADER = "Runner/Runner-Bridging-Header.h";
|
||||
|
||||
68
ios/Runner/Info-Debug.plist
Normal file
68
ios/Runner/Info-Debug.plist
Normal file
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CADisableMinimumFrameDurationOnPhone</key>
|
||||
<true/>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleLocalizations</key>
|
||||
<array>
|
||||
<string>en</string>
|
||||
<string>zh</string>
|
||||
</array>
|
||||
<key>CFBundleName</key>
|
||||
<string>ServerBox</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>$(MARKETING_VERSION)</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||
<key>ITSAppUsesNonExemptEncryption</key>
|
||||
<false/>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>LSSupportsOpeningDocumentsInPlace</key>
|
||||
<true/>
|
||||
<key>UIApplicationSupportsIndirectInputEvents</key>
|
||||
<true/>
|
||||
<key>UIBackgroundModes</key>
|
||||
<array>
|
||||
<string>fetch</string>
|
||||
</array>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UIMainStoryboardFile</key>
|
||||
<string>Main</string>
|
||||
<key>UIStatusBarHidden</key>
|
||||
<false/>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||
<false/>
|
||||
<key>NSBonjourServices</key>
|
||||
<array>
|
||||
<string>_dartobservatory._tcp</string>
|
||||
</array>
|
||||
<key>NSLocalNetworkUsageDescription</key>
|
||||
<string>ServerBox needs to access your local network to discover and connect to your server.</string>
|
||||
</dict>
|
||||
</plist>
|
||||
68
ios/Runner/Info-Profile.plist
Normal file
68
ios/Runner/Info-Profile.plist
Normal file
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CADisableMinimumFrameDurationOnPhone</key>
|
||||
<true/>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>$(DEVELOPMENT_LANGUAGE)</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>$(EXECUTABLE_NAME)</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundleLocalizations</key>
|
||||
<array>
|
||||
<string>en</string>
|
||||
<string>zh</string>
|
||||
</array>
|
||||
<key>CFBundleName</key>
|
||||
<string>ServerBox</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>$(MARKETING_VERSION)</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>$(CURRENT_PROJECT_VERSION)</string>
|
||||
<key>ITSAppUsesNonExemptEncryption</key>
|
||||
<false/>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>LSSupportsOpeningDocumentsInPlace</key>
|
||||
<true/>
|
||||
<key>UIApplicationSupportsIndirectInputEvents</key>
|
||||
<true/>
|
||||
<key>UIBackgroundModes</key>
|
||||
<array>
|
||||
<string>fetch</string>
|
||||
</array>
|
||||
<key>UILaunchStoryboardName</key>
|
||||
<string>LaunchScreen</string>
|
||||
<key>UIMainStoryboardFile</key>
|
||||
<string>Main</string>
|
||||
<key>UIStatusBarHidden</key>
|
||||
<false/>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
</array>
|
||||
<key>UISupportedInterfaceOrientations~ipad</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationPortrait</string>
|
||||
<string>UIInterfaceOrientationPortraitUpsideDown</string>
|
||||
<string>UIInterfaceOrientationLandscapeLeft</string>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
</array>
|
||||
<key>UIViewControllerBasedStatusBarAppearance</key>
|
||||
<false/>
|
||||
<key>NSBonjourServices</key>
|
||||
<array>
|
||||
<string>_dartobservatory._tcp</string>
|
||||
</array>
|
||||
<key>NSLocalNetworkUsageDescription</key>
|
||||
<string>ServerBox needs to access your local network to discover and connect to your server.</string>
|
||||
</dict>
|
||||
</plist>
|
||||
1
ipa.sksl.json
Normal file
1
ipa.sksl.json
Normal file
File diff suppressed because one or more lines are too long
@@ -1,6 +1,5 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:toolbox/core/utils/misc.dart';
|
||||
|
||||
import '/core/extension/colorx.dart';
|
||||
import 'core/utils/ui.dart';
|
||||
@@ -18,7 +17,6 @@ class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
setTransparentNavigationBar(context);
|
||||
final fontName = getFileName(_setting.fontPath.fetch());
|
||||
primaryColor = Color(_setting.primaryColor.fetch()!);
|
||||
|
||||
final textStyle = TextStyle(color: primaryColor);
|
||||
@@ -51,7 +49,6 @@ class MyApp extends StatelessWidget {
|
||||
|
||||
final theme = ThemeData(
|
||||
useMaterial3: false,
|
||||
fontFamily: fontName,
|
||||
primaryColor: primaryColor,
|
||||
primarySwatch: primarySwatch,
|
||||
appBarTheme: appBarTheme,
|
||||
@@ -64,7 +61,6 @@ class MyApp extends StatelessWidget {
|
||||
);
|
||||
final darkTheme = ThemeData(
|
||||
useMaterial3: false,
|
||||
fontFamily: fontName,
|
||||
primaryColor: primaryColor,
|
||||
primarySwatch: primarySwatch,
|
||||
floatingActionButtonTheme: fabTheme,
|
||||
|
||||
@@ -3,8 +3,8 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:r_upgrade/r_upgrade.dart';
|
||||
import 'package:toolbox/core/utils/navigator.dart';
|
||||
|
||||
import '../data/model/app/update.dart';
|
||||
import '../data/provider/app.dart';
|
||||
import '../data/res/build_data.dart';
|
||||
import '../data/service/app.dart';
|
||||
@@ -27,18 +27,13 @@ Future<bool> isFileAvailable(String url) async {
|
||||
Future<void> doUpdate(BuildContext context, {bool force = false}) async {
|
||||
final update = await locator<AppService>().getUpdate();
|
||||
|
||||
locator<AppProvider>().setNewestBuild(update.newest);
|
||||
final newest = update.build.last.current;
|
||||
if (newest == null) {
|
||||
_logger.warning('Update not available on $platform');
|
||||
return;
|
||||
}
|
||||
|
||||
final newest = () {
|
||||
if (isAndroid) {
|
||||
return update.androidbuild;
|
||||
} else if (isIOS) {
|
||||
return update.iosbuild;
|
||||
} else if (isMacOS) {
|
||||
return update.macbuild;
|
||||
}
|
||||
return update.newest;
|
||||
}();
|
||||
locator<AppProvider>().setNewestBuild(newest);
|
||||
|
||||
if (!force && newest <= BuildData.build) {
|
||||
_logger.info('Update ignored due to current: ${BuildData.build}, '
|
||||
@@ -47,21 +42,23 @@ Future<void> doUpdate(BuildContext context, {bool force = false}) async {
|
||||
}
|
||||
_logger.info('Update available: $newest');
|
||||
|
||||
if (isAndroid && !await isFileAvailable(update.android)) {
|
||||
final url = update.url.current!;
|
||||
|
||||
if (isAndroid && !await isFileAvailable(url)) {
|
||||
_logger.warning('Android update file not available');
|
||||
return;
|
||||
}
|
||||
|
||||
final s = S.of(context)!;
|
||||
|
||||
if (update.min > BuildData.build) {
|
||||
if (update.build.min.current! > BuildData.build) {
|
||||
showRoundDialog(
|
||||
context,
|
||||
s.attention,
|
||||
Text(s.updateTipTooLow(newest)),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => _doUpdate(update, context, s),
|
||||
onPressed: () => _doUpdate(url, context, s),
|
||||
child: Text(s.ok),
|
||||
)
|
||||
],
|
||||
@@ -71,17 +68,17 @@ Future<void> doUpdate(BuildContext context, {bool force = false}) async {
|
||||
|
||||
showSnackBarWithAction(
|
||||
context,
|
||||
'${s.updateTip(newest)} \n${update.changelog}',
|
||||
'${s.updateTip(newest)} \n${update.changelog.current}',
|
||||
s.update,
|
||||
() => _doUpdate(update, context, s),
|
||||
() => _doUpdate(url, context, s),
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _doUpdate(AppUpdate update, BuildContext context, S s) async {
|
||||
Future<void> _doUpdate(String url, BuildContext context, S s) async {
|
||||
if (isAndroid) {
|
||||
await RUpgrade.upgrade(
|
||||
update.android,
|
||||
fileName: update.android.split('/').last,
|
||||
url,
|
||||
fileName: url.split('/').last,
|
||||
isAutoRequestInstall: true,
|
||||
);
|
||||
} else if (isIOS) {
|
||||
@@ -89,7 +86,7 @@ Future<void> _doUpdate(AppUpdate update, BuildContext context, S s) async {
|
||||
} else {
|
||||
showRoundDialog(context, s.attention, Text(s.platformNotSupportUpdate), [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(s.ok),
|
||||
)
|
||||
]);
|
||||
|
||||
@@ -7,9 +7,13 @@ import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:plain_notification_token/plain_notification_token.dart';
|
||||
import 'package:share_plus/share_plus.dart';
|
||||
|
||||
import '../../data/provider/app.dart';
|
||||
import '../../locator.dart';
|
||||
import '../../view/widget/rebuild.dart';
|
||||
import 'platform.dart';
|
||||
|
||||
final _app = locator<AppProvider>();
|
||||
|
||||
Future<bool> shareFiles(BuildContext context, List<String> filePaths) async {
|
||||
for (final filePath in filePaths) {
|
||||
if (!await File(filePath).exists()) {
|
||||
@@ -22,8 +26,10 @@ Future<bool> shareFiles(BuildContext context, List<String> filePaths) async {
|
||||
} else {
|
||||
text = '${filePaths.length} ${S.of(context)!.files}';
|
||||
}
|
||||
final xfiles = filePaths.map((e) => XFile(e)).toList();
|
||||
await Share.shareXFiles(xfiles, text: 'ServerBox -> $text');
|
||||
_app.setMoveBg(false);
|
||||
// ignore: deprecated_member_use
|
||||
await Share.shareFiles(filePaths, text: 'ServerBox -> $text');
|
||||
_app.setMoveBg(true);
|
||||
return filePaths.isNotEmpty;
|
||||
}
|
||||
|
||||
@@ -32,7 +38,9 @@ void copy(String text) {
|
||||
}
|
||||
|
||||
Future<String?> pickOneFile() async {
|
||||
_app.setMoveBg(false);
|
||||
final result = await FilePicker.platform.pickFiles(type: FileType.any);
|
||||
_app.setMoveBg(true);
|
||||
return result?.files.single.path;
|
||||
}
|
||||
|
||||
|
||||
7
lib/core/utils/navigator.dart
Normal file
7
lib/core/utils/navigator.dart
Normal file
@@ -0,0 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
extension ContextX on BuildContext {
|
||||
void pop<T>([T? result]) {
|
||||
Navigator.of(this).pop(T);
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ enum PlatformType {
|
||||
macos,
|
||||
windows,
|
||||
web,
|
||||
unknown,
|
||||
}
|
||||
|
||||
final _p = () {
|
||||
@@ -30,7 +31,7 @@ final _p = () {
|
||||
if (Platform.isWindows) {
|
||||
return PlatformType.windows;
|
||||
}
|
||||
return PlatformType.web;
|
||||
return PlatformType.unknown;
|
||||
}();
|
||||
|
||||
PlatformType get platform => _p;
|
||||
@@ -41,3 +42,8 @@ bool get isLinux => _p == PlatformType.linux;
|
||||
bool get isMacOS => _p == PlatformType.macos;
|
||||
bool get isWindows => _p == PlatformType.windows;
|
||||
bool get isWeb => _p == PlatformType.web;
|
||||
bool get isMobile => _p == PlatformType.ios || _p == PlatformType.android;
|
||||
bool get isDesktop =>
|
||||
_p == PlatformType.linux ||
|
||||
_p == PlatformType.macos ||
|
||||
_p == PlatformType.windows;
|
||||
|
||||
@@ -9,7 +9,7 @@ import '../../locator.dart';
|
||||
|
||||
/// Must put this func out of any Class.
|
||||
///
|
||||
/// Because of this function is called by [compute] in [ServerProvider.genClient].
|
||||
/// Because of this function is called by [compute].
|
||||
///
|
||||
/// https://stackoverflow.com/questions/51998995/invalid-arguments-illegal-argument-in-isolate-message-object-is-a-closure
|
||||
List<SSHKeyPair> loadIndentity(String key) {
|
||||
|
||||
@@ -3,11 +3,18 @@ import 'dart:io';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:toolbox/core/utils/misc.dart';
|
||||
import 'package:toolbox/core/utils/navigator.dart';
|
||||
import 'package:url_launcher/url_launcher.dart';
|
||||
|
||||
import '../../data/model/server/snippet.dart';
|
||||
import '../../data/provider/snippet.dart';
|
||||
import '../../locator.dart';
|
||||
import '../../view/page/snippet/edit.dart';
|
||||
import '../../view/widget/card_dialog.dart';
|
||||
import '../../view/widget/picker.dart';
|
||||
import '../persistant_store.dart';
|
||||
import '../route.dart';
|
||||
import 'misc.dart';
|
||||
import 'platform.dart';
|
||||
import '../extension/stringx.dart';
|
||||
import '../extension/uint8list.dart';
|
||||
@@ -107,8 +114,54 @@ String tabTitleName(BuildContext context, int i) {
|
||||
|
||||
Future<void> loadFontFile(String? localPath) async {
|
||||
if (localPath == null) return;
|
||||
final name = getFileName(localPath)!;
|
||||
final name = getFileName(localPath);
|
||||
if (name == null) return;
|
||||
var fontLoader = FontLoader(name);
|
||||
fontLoader.addFont(File(localPath).readAsBytes().byteData);
|
||||
await fontLoader.load();
|
||||
}
|
||||
|
||||
void showSnippetDialog(
|
||||
BuildContext context, S s, Function(Snippet s) onSelected) {
|
||||
final provider = locator<SnippetProvider>();
|
||||
if (provider.snippets.isEmpty) {
|
||||
showRoundDialog(
|
||||
context,
|
||||
s.attention,
|
||||
Text(s.noSavedSnippet),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: Text(s.ok),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
context.pop();
|
||||
AppRoute(const SnippetEditPage(), 'edit snippet').go(context);
|
||||
},
|
||||
child: Text(s.addOne),
|
||||
)
|
||||
],
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
var snippet = provider.snippets.first;
|
||||
showRoundDialog(
|
||||
context,
|
||||
s.choose,
|
||||
buildPicker(
|
||||
provider.snippets.map((e) => Text(e.name)).toList(),
|
||||
(idx) => snippet = provider.snippets[idx],
|
||||
),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
context.pop();
|
||||
onSelected(snippet);
|
||||
},
|
||||
child: Text(s.ok),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,9 +9,7 @@ class Backup {
|
||||
final List<ServerPrivateInfo> spis;
|
||||
final List<Snippet> snippets;
|
||||
final List<PrivateKeyInfo> keys;
|
||||
final int primaryColor;
|
||||
final int serverStatusUpdateInterval;
|
||||
final int launchPage;
|
||||
final Map<String, String> dockerHosts;
|
||||
|
||||
Backup(
|
||||
this.version,
|
||||
@@ -19,9 +17,7 @@ class Backup {
|
||||
this.spis,
|
||||
this.snippets,
|
||||
this.keys,
|
||||
this.primaryColor,
|
||||
this.serverStatusUpdateInterval,
|
||||
this.launchPage,
|
||||
this.dockerHosts,
|
||||
);
|
||||
|
||||
Backup.fromJson(Map<String, dynamic> json)
|
||||
@@ -35,9 +31,7 @@ class Backup {
|
||||
keys = (json['keys'] as List)
|
||||
.map((e) => PrivateKeyInfo.fromJson(e))
|
||||
.toList(),
|
||||
primaryColor = json['primaryColor'],
|
||||
serverStatusUpdateInterval = json['serverStatusUpdateInterval'],
|
||||
launchPage = json['launchPage'];
|
||||
dockerHosts = json['dockerHosts'] ?? {};
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
'version': version,
|
||||
@@ -45,8 +39,5 @@ class Backup {
|
||||
'spis': spis,
|
||||
'snippets': snippets,
|
||||
'keys': keys,
|
||||
'primaryColor': primaryColor,
|
||||
'serverStatusUpdateInterval': serverStatusUpdateInterval,
|
||||
'launchPage': launchPage,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,54 +1,126 @@
|
||||
///
|
||||
/// Code generated by jsonToDartModel https://ashamp.github.io/jsonToDartModel/
|
||||
///
|
||||
class AppUpdate {
|
||||
/*
|
||||
{
|
||||
"newest": 33,
|
||||
"android": "https://v2.custed.lolli.tech/res/tiku/apk/33.apk",
|
||||
"ios": "https://",
|
||||
"min": 30,
|
||||
"changelog": ""
|
||||
}
|
||||
"changelog": {
|
||||
"mac": "xxx",
|
||||
"ios": "xxx",
|
||||
"android": ""
|
||||
},
|
||||
"build": {
|
||||
"min": {
|
||||
"mac": 1,
|
||||
"ios": 1,
|
||||
"android": 1
|
||||
},
|
||||
"last": {
|
||||
"mac": 1,
|
||||
"ios": 1,
|
||||
"android": 1
|
||||
}
|
||||
},
|
||||
"url": {
|
||||
"mac": "https://apps.apple.com/app/id1586449703",
|
||||
"ios": "https://apps.apple.com/app/id1586449703",
|
||||
"android": "https://cdn3.cust.app/uploads/ServerBox_262_Arm64.apk"
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
late int newest;
|
||||
late int iosbuild;
|
||||
late int androidbuild;
|
||||
late int macbuild;
|
||||
late String android;
|
||||
late String ios;
|
||||
late String mac;
|
||||
late int min;
|
||||
late String changelog;
|
||||
import 'dart:convert';
|
||||
|
||||
import '/core/utils/platform.dart';
|
||||
|
||||
class AppUpdate {
|
||||
AppUpdate({
|
||||
required this.newest,
|
||||
required this.android,
|
||||
required this.ios,
|
||||
required this.min,
|
||||
required this.changelog,
|
||||
required this.build,
|
||||
required this.url,
|
||||
});
|
||||
AppUpdate.fromJson(Map<String, dynamic> json) {
|
||||
newest = json["newest"]?.toInt();
|
||||
macbuild = json["macbuild"]?.toInt();
|
||||
iosbuild = json["iosbuild"]?.toInt();
|
||||
androidbuild = json["androidbuild"]?.toInt();
|
||||
android = json["android"].toString();
|
||||
ios = json["ios"].toString();
|
||||
min = json["min"].toInt();
|
||||
changelog = json["changelog"].toString();
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
final Map<String, dynamic> data = <String, dynamic>{};
|
||||
data["newest"] = newest;
|
||||
data["macbuild"] = macbuild;
|
||||
data["iosbuild"] = iosbuild;
|
||||
data["androidbuild"] = androidbuild;
|
||||
data["android"] = android;
|
||||
data["ios"] = ios;
|
||||
data["min"] = min;
|
||||
data["changelog"] = changelog;
|
||||
return data;
|
||||
|
||||
final AppUpdatePlatformSpecific<String> changelog;
|
||||
final Build build;
|
||||
final AppUpdatePlatformSpecific<String> url;
|
||||
|
||||
factory AppUpdate.fromRawJson(String str) =>
|
||||
AppUpdate.fromJson(json.decode(str));
|
||||
|
||||
String toRawJson() => json.encode(toJson());
|
||||
|
||||
factory AppUpdate.fromJson(Map<String, dynamic> json) => AppUpdate(
|
||||
changelog: AppUpdatePlatformSpecific.fromJson(json["changelog"]),
|
||||
build: Build.fromJson(json["build"]),
|
||||
url: AppUpdatePlatformSpecific.fromJson(json["url"]),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"changelog": changelog.toJson(),
|
||||
"build": build.toJson(),
|
||||
"url": url.toJson(),
|
||||
};
|
||||
}
|
||||
|
||||
class Build {
|
||||
Build({
|
||||
required this.min,
|
||||
required this.last,
|
||||
});
|
||||
|
||||
final AppUpdatePlatformSpecific<int> min;
|
||||
final AppUpdatePlatformSpecific<int> last;
|
||||
|
||||
factory Build.fromRawJson(String str) => Build.fromJson(json.decode(str));
|
||||
|
||||
String toRawJson() => json.encode(toJson());
|
||||
|
||||
factory Build.fromJson(Map<String, dynamic> json) => Build(
|
||||
min: AppUpdatePlatformSpecific.fromJson(json["min"]),
|
||||
last: AppUpdatePlatformSpecific.fromJson(json["last"]),
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"min": min.toJson(),
|
||||
"last": last.toJson(),
|
||||
};
|
||||
}
|
||||
|
||||
class AppUpdatePlatformSpecific<T> {
|
||||
AppUpdatePlatformSpecific({
|
||||
required this.mac,
|
||||
required this.ios,
|
||||
required this.android,
|
||||
});
|
||||
|
||||
final T mac;
|
||||
final T ios;
|
||||
final T android;
|
||||
|
||||
factory AppUpdatePlatformSpecific.fromRawJson(String str) =>
|
||||
AppUpdatePlatformSpecific.fromJson(json.decode(str));
|
||||
|
||||
String toRawJson() => json.encode(toJson());
|
||||
|
||||
factory AppUpdatePlatformSpecific.fromJson(Map<String, dynamic> json) =>
|
||||
AppUpdatePlatformSpecific(
|
||||
mac: json["mac"],
|
||||
ios: json["ios"],
|
||||
android: json["android"],
|
||||
);
|
||||
|
||||
Map<String, dynamic> toJson() => {
|
||||
"mac": mac,
|
||||
"ios": ios,
|
||||
"android": android,
|
||||
};
|
||||
|
||||
T? get current {
|
||||
switch (platform) {
|
||||
case PlatformType.macos:
|
||||
return mac;
|
||||
case PlatformType.ios:
|
||||
return ios;
|
||||
case PlatformType.android:
|
||||
return android;
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -114,10 +114,8 @@ List<OneTimeCpuStatus> parseCPU(String raw) {
|
||||
|
||||
final cpuTempReg = RegExp(r'(x86_pkg_temp|cpu_thermal)');
|
||||
|
||||
String parseCPUTemp(List<String> segments) {
|
||||
String parseCPUTemp(String type, String value) {
|
||||
const noMatch = "/sys/class/thermal/thermal_zone*/type";
|
||||
final type = segments[0];
|
||||
final value = segments[1];
|
||||
// Not support to get CPU temperature
|
||||
if (value.contains(noMatch) ||
|
||||
type.contains(noMatch) ||
|
||||
|
||||
@@ -6,9 +6,9 @@ class Server {
|
||||
ServerPrivateInfo spi;
|
||||
ServerStatus status;
|
||||
SSHClient? client;
|
||||
ServerState cs;
|
||||
ServerState state;
|
||||
|
||||
Server(this.spi, this.status, this.client, this.cs);
|
||||
Server(this.spi, this.status, this.client, this.state);
|
||||
}
|
||||
|
||||
enum ServerState {
|
||||
|
||||
@@ -12,4 +12,4 @@ class VirtualKey {
|
||||
{this.key, this.toggleable = false, this.icon, this.func});
|
||||
}
|
||||
|
||||
enum VirtualKeyFunc { toggleIME, backspace, copy, paste }
|
||||
enum VirtualKeyFunc { toggleIME, backspace, copy, paste, snippet }
|
||||
|
||||
@@ -4,8 +4,15 @@ class AppProvider extends BusyProvider {
|
||||
int? _newestBuild;
|
||||
int? get newestBuild => _newestBuild;
|
||||
|
||||
bool _moveBg = true;
|
||||
bool get moveBg => _moveBg;
|
||||
|
||||
void setNewestBuild(int build) {
|
||||
_newestBuild = build;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
void setMoveBg(bool moveBg) {
|
||||
_moveBg = moveBg;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'dart:async';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:toolbox/data/model/server/server_status.dart';
|
||||
|
||||
import '../../core/extension/uint8list.dart';
|
||||
import '../../core/provider_base.dart';
|
||||
@@ -49,7 +50,7 @@ class ServerProvider extends BusyProvider {
|
||||
}
|
||||
await Future.wait(_servers.map((s) async {
|
||||
if (onlyFailed) {
|
||||
if (s.cs != ServerState.failed) return;
|
||||
if (s.state != ServerState.failed) return;
|
||||
_limiter.resetTryTimes(s.spi.id);
|
||||
}
|
||||
await _getData(s.spi);
|
||||
@@ -75,7 +76,7 @@ class ServerProvider extends BusyProvider {
|
||||
|
||||
void setDisconnected() {
|
||||
for (var i = 0; i < _servers.length; i++) {
|
||||
_servers[i].cs = ServerState.disconnected;
|
||||
_servers[i].state = ServerState.disconnected;
|
||||
}
|
||||
_limiter.clear();
|
||||
notifyListeners();
|
||||
@@ -135,14 +136,14 @@ class ServerProvider extends BusyProvider {
|
||||
Future<void> _getData(ServerPrivateInfo spi) async {
|
||||
final sid = spi.id;
|
||||
final s = getServer(sid);
|
||||
final state = s.cs;
|
||||
final state = s.state;
|
||||
if (state.shouldConnect) {
|
||||
if (!_limiter.shouldTry(sid)) {
|
||||
s.cs = ServerState.failed;
|
||||
s.state = ServerState.failed;
|
||||
notifyListeners();
|
||||
return;
|
||||
}
|
||||
s.cs = ServerState.connecting;
|
||||
s.state = ServerState.connecting;
|
||||
notifyListeners();
|
||||
|
||||
try {
|
||||
@@ -154,7 +155,7 @@ class ServerProvider extends BusyProvider {
|
||||
_logger.info('Connected to [$sid] in $spentTime ms.');
|
||||
|
||||
// after connected
|
||||
s.cs = ServerState.connected;
|
||||
s.state = ServerState.connected;
|
||||
final writeResult = await s.client!.run(installShellCmd).string;
|
||||
|
||||
// if write failed
|
||||
@@ -163,8 +164,8 @@ class ServerProvider extends BusyProvider {
|
||||
}
|
||||
_limiter.resetTryTimes(sid);
|
||||
} catch (e) {
|
||||
s.cs = ServerState.failed;
|
||||
s.status.failedInfo = '$e';
|
||||
s.state = ServerState.failed;
|
||||
s.status.failedInfo = e.toString();
|
||||
_logger.warning(e);
|
||||
} finally {
|
||||
notifyListeners();
|
||||
@@ -176,7 +177,7 @@ class ServerProvider extends BusyProvider {
|
||||
final raw = await s.client!.run("sh $shellPath").string;
|
||||
final segments = raw.split(seperator).map((e) => e.trim()).toList();
|
||||
if (raw.isEmpty || segments.length == 1) {
|
||||
s.cs = ServerState.failed;
|
||||
s.state = ServerState.failed;
|
||||
if (s.status.failedInfo == null || s.status.failedInfo!.isEmpty) {
|
||||
s.status.failedInfo = 'Seperate segments failed, raw:\n$raw';
|
||||
}
|
||||
@@ -184,18 +185,14 @@ class ServerProvider extends BusyProvider {
|
||||
return;
|
||||
}
|
||||
// remove first empty segment
|
||||
// for `export xxx` in shell script
|
||||
segments.removeAt(0);
|
||||
|
||||
try {
|
||||
_getCPU(sid, segments[2], segments[7], segments[8]);
|
||||
_getMem(sid, segments[6]);
|
||||
_getSysVer(sid, segments[1]);
|
||||
_getUpTime(sid, segments[3]);
|
||||
_getDisk(sid, segments[5]);
|
||||
_getTcp(sid, segments[4]);
|
||||
_getNetSpeed(sid, segments[0]);
|
||||
final req = ServerStatusUpdateReq(s.status, segments);
|
||||
s.status = await compute(_getStatus, req);
|
||||
} catch (e) {
|
||||
s.cs = ServerState.failed;
|
||||
s.state = ServerState.failed;
|
||||
s.status.failedInfo = e.toString();
|
||||
_logger.warning(e);
|
||||
rethrow;
|
||||
@@ -204,50 +201,6 @@ class ServerProvider extends BusyProvider {
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _getNetSpeed(String id, String raw) async {
|
||||
final net = await compute(parseNetSpeed, raw);
|
||||
getServer(id).status.netSpeed.update(net);
|
||||
}
|
||||
|
||||
void _getSysVer(String id, String raw) {
|
||||
final s = raw.split('=');
|
||||
if (s.length == 2) {
|
||||
final ver = s[1].replaceAll('"', '').replaceFirst('\n', '');
|
||||
getServer(id).status.sysVer = ver;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _getCPU(
|
||||
String id, String raw, String tempType, String tempValue) async {
|
||||
final cpus = await compute(parseCPU, raw);
|
||||
final temp = await compute(parseCPUTemp, [tempType, tempValue]);
|
||||
|
||||
if (cpus.isNotEmpty) {
|
||||
getServer(id).status.cpu.update(cpus, temp);
|
||||
}
|
||||
}
|
||||
|
||||
void _getUpTime(String id, String raw) {
|
||||
getServer(id).status.uptime = raw.split('up ')[1].split(', ')[0];
|
||||
}
|
||||
|
||||
Future<void> _getTcp(String id, String raw) async {
|
||||
final status = await compute(parseTcp, raw);
|
||||
if (status != null) {
|
||||
getServer(id).status.tcp = status;
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> _getDisk(String id, String raw) async {
|
||||
getServer(id).status.disk = await compute(parseDisk, raw);
|
||||
}
|
||||
|
||||
Future<void> _getMem(String id, String raw) async {
|
||||
final s = getServer(id);
|
||||
s.status.mem = await compute(parseMem, raw);
|
||||
s.status.swap = await compute(parseSwap, raw);
|
||||
}
|
||||
|
||||
Future<String?> runSnippet(String id, Snippet snippet) async {
|
||||
final client = getServer(id).client;
|
||||
if (client == null) {
|
||||
@@ -281,3 +234,55 @@ class _TryLimiter {
|
||||
_triedTimes.clear();
|
||||
}
|
||||
}
|
||||
|
||||
class ServerStatusUpdateReq {
|
||||
final ServerStatus ss;
|
||||
final List<String> segments;
|
||||
|
||||
const ServerStatusUpdateReq(this.ss, this.segments);
|
||||
}
|
||||
|
||||
Future<ServerStatus> _getStatus(ServerStatusUpdateReq req) async {
|
||||
final net = parseNetSpeed(req.segments[0]);
|
||||
req.ss.netSpeed.update(net);
|
||||
final sys = parseSysVer(req.segments[1]);
|
||||
if (sys != null) {
|
||||
req.ss.sysVer = sys;
|
||||
}
|
||||
final cpus = parseCPU(req.segments[2]);
|
||||
final cpuTemp = parseCPUTemp(req.segments[7], req.segments[8]);
|
||||
req.ss.cpu.update(cpus, cpuTemp);
|
||||
final tcp = parseTcp(req.segments[4]);
|
||||
if (tcp != null) {
|
||||
req.ss.tcp = tcp;
|
||||
}
|
||||
req.ss.disk = parseDisk(req.segments[5]);
|
||||
req.ss.mem = parseMem(req.segments[6]);
|
||||
final uptime = parseUpTime(req.segments[3]);
|
||||
if (uptime != null) {
|
||||
req.ss.uptime = uptime;
|
||||
}
|
||||
req.ss.swap = parseSwap(req.segments[6]);
|
||||
return req.ss;
|
||||
}
|
||||
|
||||
// raw:
|
||||
// 19:39:15 up 61 days, 18:16, 1 user, load average: 0.00, 0.00, 0.00
|
||||
String? parseUpTime(String raw) {
|
||||
final splitedUp = raw.split('up ');
|
||||
if (splitedUp.length == 2) {
|
||||
final splitedComma = splitedUp[1].split(', ');
|
||||
if (splitedComma.length >= 2) {
|
||||
return splitedComma[0];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
String? parseSysVer(String raw) {
|
||||
final s = raw.split('=');
|
||||
if (s.length == 2) {
|
||||
return s[1].replaceAll('"', '').replaceFirst('\n', '');
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
class BuildData {
|
||||
static const String name = "ServerBox";
|
||||
static const int build = 243;
|
||||
static const String engine = "Flutter 3.7.7 • channel stable • https://github.com/flutter/flutter.git\nFramework • revision 2ad6cd72c0 (13 days ago) • 2023-03-08 09:41:59 -0800\nEngine • revision 1837b5be5f\nTools • Dart 2.19.4 • DevTools 2.20.1\n";
|
||||
static const String buildAt = "2023-03-21 15:18:42.802605";
|
||||
static const int modifications = 5;
|
||||
static const int build = 269;
|
||||
static const String engine = "3.7.11";
|
||||
static const String buildAt = "2023-04-19 20:53:37.738261";
|
||||
static const int modifications = 15;
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import 'package:flutter/services.dart';
|
||||
|
||||
/// RegExp for number
|
||||
final numReg = RegExp(r'\s{1,}');
|
||||
|
||||
@@ -6,3 +8,7 @@ const privateKeyMaxSize = 20 * 1024;
|
||||
|
||||
/// Max debug log lines
|
||||
const maxDebugLogLines = 100;
|
||||
|
||||
/// Method Channels
|
||||
const pkgName = 'tech.lolli.toolbox';
|
||||
const bgRunChannel = MethodChannel('$pkgName/app_retain');
|
||||
|
||||
@@ -1,10 +1,20 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:path_provider/path_provider.dart';
|
||||
import 'package:toolbox/core/utils/platform.dart';
|
||||
|
||||
Future<Directory> get docDir async => await getApplicationDocumentsDirectory();
|
||||
Future<Directory> get docDir async {
|
||||
if (isAndroid) {
|
||||
final dir = await getExternalStorageDirectory();
|
||||
if (dir != null) {
|
||||
return dir;
|
||||
}
|
||||
// fallthrough to getApplicationDocumentsDirectory
|
||||
}
|
||||
return await getApplicationDocumentsDirectory();
|
||||
}
|
||||
|
||||
Future<Directory> get sftpDownloadDir async {
|
||||
Future<Directory> get sftpDir async {
|
||||
final dir = Directory('${(await docDir).path}/sftp');
|
||||
return dir.create(recursive: true);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
const backendUrl = 'https://res.lolli.tech';
|
||||
const baseUrl = '$backendUrl/toolbox';
|
||||
const baseUrl = '$backendUrl/serverbox';
|
||||
const joinQQGroupUrl = 'https://jq.qq.com/?_wv=1027&k=G0hUmPAq';
|
||||
const myGithub = 'https://github.com/lollipopkit';
|
||||
const issueUrl = '$myGithub/flutter_server_box/issues';
|
||||
@@ -11,4 +11,5 @@ const thanksMap = {
|
||||
'Tao173': 'https://github.com/Tao173',
|
||||
'QingAnLe': 'https://github.com/QingAnLe',
|
||||
'wxdjs': 'https://github.com/wxdjs',
|
||||
'Aeorq': 'https://github.com/Aeorq',
|
||||
};
|
||||
|
||||
@@ -3,22 +3,24 @@ import 'package:xterm/core.dart';
|
||||
|
||||
import '../model/ssh/virtual_key.dart';
|
||||
|
||||
var virtualKeys = [
|
||||
final virtualKeys = [
|
||||
VirtualKey('Esc', key: TerminalKey.escape),
|
||||
VirtualKey('Alt', key: TerminalKey.alt, toggleable: true),
|
||||
VirtualKey('Home', key: TerminalKey.home),
|
||||
VirtualKey('Up', key: TerminalKey.arrowUp, icon: Icons.arrow_upward),
|
||||
VirtualKey('End', key: TerminalKey.end),
|
||||
// VirtualKey(
|
||||
// 'Del',
|
||||
// key: TerminalKey.delete,
|
||||
// ),
|
||||
VirtualKey('Paste', func: VirtualKeyFunc.paste, icon: Icons.paste),
|
||||
VirtualKey(
|
||||
'Del',
|
||||
key: TerminalKey.delete,
|
||||
icon: Icons.backspace,
|
||||
),
|
||||
VirtualKey('Snippet', func: VirtualKeyFunc.snippet, icon: Icons.code),
|
||||
VirtualKey('Tab', key: TerminalKey.tab),
|
||||
VirtualKey('Ctrl', key: TerminalKey.control, toggleable: true),
|
||||
VirtualKey('Left', key: TerminalKey.arrowLeft, icon: Icons.arrow_back),
|
||||
VirtualKey('Down', key: TerminalKey.arrowDown, icon: Icons.arrow_downward),
|
||||
VirtualKey('Right', key: TerminalKey.arrowRight, icon: Icons.arrow_forward),
|
||||
VirtualKey('Paste', func: VirtualKeyFunc.paste, icon: Icons.paste),
|
||||
VirtualKey(
|
||||
'IME',
|
||||
func: VirtualKeyFunc.toggleIME,
|
||||
|
||||
@@ -8,4 +8,8 @@ class DockerStore extends PersistentStore {
|
||||
void setDockerHost(String id, String host) {
|
||||
box.put(id, host);
|
||||
}
|
||||
|
||||
Map<String, String> fetch() {
|
||||
return box.toMap().cast<String, String>();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,11 +28,14 @@ class SettingStore extends PersistentStore {
|
||||
|
||||
/// Max retry count when connect to server
|
||||
StoreProperty<int> get maxRetryCount =>
|
||||
property('maxRetryCount', defaultValue: 7);
|
||||
property('maxRetryCount', defaultValue: 2);
|
||||
|
||||
/// Night mode: 0 -> auto, 1 -> light, 2 -> dark
|
||||
StoreProperty<int> get themeMode => property('themeMode', defaultValue: 0);
|
||||
|
||||
/// Font file path
|
||||
StoreProperty<String> get fontPath => property('fontPath');
|
||||
|
||||
/// Backgroud running (Android)
|
||||
StoreProperty<bool> get bgRun => property('bgRun', defaultValue: true);
|
||||
}
|
||||
|
||||
@@ -10,8 +10,10 @@
|
||||
"auto": "Auto",
|
||||
"backDir": "Back",
|
||||
"backup": "Backup",
|
||||
"backupTip": "The exported data is simply encrypted. \nPlease keep it safe.\nRestoring will not overwrite existing data (except setting).",
|
||||
"backupAndRestore": "Backup and Restore",
|
||||
"backupTip": "The exported data is simply encrypted. \nPlease keep it safe.",
|
||||
"backupVersionNotMatch": "Backup version is not match.",
|
||||
"bgRun": "Run in backgroud",
|
||||
"cancel": "Cancel",
|
||||
"choose": "Choose",
|
||||
"chooseDestination": "Choose destination",
|
||||
@@ -68,7 +70,6 @@
|
||||
"httpFailedWithCode": "request failed, status code: {code}",
|
||||
"imagesList": "Images list",
|
||||
"import": "Import",
|
||||
"importAndExport": "Import and Export",
|
||||
"inputDomainHere": "Input Domain here",
|
||||
"install": "install",
|
||||
"installDockerWithUrl": "Please https://docs.docker.com/engine/install docker first.",
|
||||
@@ -84,7 +85,7 @@
|
||||
"light": "Light",
|
||||
"loadingFiles": "Loading files...",
|
||||
"loss": "loss",
|
||||
"madeWithLove": "\nMade with ❤️ by {myGithub}",
|
||||
"madeWithLove": "Made with ❤️ by {myGithub}",
|
||||
"max": "max",
|
||||
"maxRetryCount": "Number of server reconnection",
|
||||
"maxRetryCountEqual0": "Will retry again and again.",
|
||||
@@ -106,6 +107,7 @@
|
||||
"onServerDetailPage": "On server detail page",
|
||||
"onlyIOS": "Only valid on iOS",
|
||||
"open": "Open",
|
||||
"paste": "Paste",
|
||||
"path": "Path",
|
||||
"pickFile": "Pick file",
|
||||
"ping": "Ping",
|
||||
@@ -150,6 +152,7 @@
|
||||
"stop": "Stop",
|
||||
"success": "Success",
|
||||
"sureDelete": "Are you sure to delete [{name}]?",
|
||||
"sureDirEmpty": "Make sure dir is empty.",
|
||||
"sureNoPwd": "Are you sure to use no password?",
|
||||
"sureToDeleteServer": "Are you sure to delete server [{server}]?",
|
||||
"termTheme": "Terminal theme",
|
||||
|
||||
@@ -10,8 +10,10 @@
|
||||
"auto": "自动",
|
||||
"backDir": "返回上一级",
|
||||
"backup": "备份",
|
||||
"backupTip": "导出的数据仅进行了简单加密,请妥善保管。\n除了设置项,恢复的数据不会覆盖现有数据。",
|
||||
"backupAndRestore": "备份和恢复",
|
||||
"backupTip": "导出的数据仅进行了简单加密,请妥善保管。",
|
||||
"backupVersionNotMatch": "备份版本不匹配,无法恢复",
|
||||
"bgRun": "后台运行",
|
||||
"cancel": "取消",
|
||||
"choose": "选择",
|
||||
"chooseDestination": "选择目标",
|
||||
@@ -68,7 +70,6 @@
|
||||
"httpFailedWithCode": "请求失败, 状态码: {code}",
|
||||
"imagesList": "镜像列表",
|
||||
"import": "导入",
|
||||
"importAndExport": "导入或导出",
|
||||
"inputDomainHere": "在这里输入域名",
|
||||
"install": "安装",
|
||||
"installDockerWithUrl": "请先 https://docs.docker.com/engine/install docker",
|
||||
@@ -84,7 +85,7 @@
|
||||
"light": "亮",
|
||||
"loadingFiles": "正在加载目录。。。",
|
||||
"loss": "丢包率",
|
||||
"madeWithLove": "\n用❤️制作 by {myGithub}",
|
||||
"madeWithLove": "用❤️制作 by {myGithub}",
|
||||
"max": "最大",
|
||||
"maxRetryCount": "服务器尝试重连次数",
|
||||
"maxRetryCountEqual0": "会无限重试",
|
||||
@@ -106,6 +107,7 @@
|
||||
"onServerDetailPage": "在服务器详情页",
|
||||
"onlyIOS": "仅在iOS上有效",
|
||||
"open": "打开",
|
||||
"paste": "粘贴",
|
||||
"path": "路径",
|
||||
"pickFile": "选择文件",
|
||||
"ping": "Ping",
|
||||
@@ -150,6 +152,7 @@
|
||||
"stop": "停止",
|
||||
"success": "成功",
|
||||
"sureDelete": "确定删除[{name}]?",
|
||||
"sureDirEmpty": "请确保文件夹为空",
|
||||
"sureNoPwd": "确认使用无密码?",
|
||||
"sureToDeleteServer": "你确定要删除服务器 [{server}] 吗?",
|
||||
"termTheme": "终端主题",
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:toolbox/data/res/color.dart';
|
||||
import 'package:toolbox/core/utils/navigator.dart';
|
||||
import 'package:toolbox/data/res/path.dart';
|
||||
|
||||
import '../../core/extension/colorx.dart';
|
||||
import '../../core/utils/misc.dart';
|
||||
import '../../core/utils/ui.dart';
|
||||
import '../../data/model/app/backup.dart';
|
||||
import '../../data/res/color.dart';
|
||||
import '../../data/res/ui.dart';
|
||||
import '../../data/store/docker.dart';
|
||||
import '../../data/store/private_key.dart';
|
||||
import '../../data/store/server.dart';
|
||||
import '../../data/store/setting.dart';
|
||||
import '../../data/store/snippet.dart';
|
||||
import '../../locator.dart';
|
||||
|
||||
@@ -22,10 +25,10 @@ const backupFormatVersion = 1;
|
||||
class BackupPage extends StatelessWidget {
|
||||
BackupPage({Key? key}) : super(key: key);
|
||||
|
||||
final _setting = locator<SettingStore>();
|
||||
final _server = locator<ServerStore>();
|
||||
final _snippet = locator<SnippetStore>();
|
||||
final _privateKey = locator<PrivateKeyStore>();
|
||||
final _dockerHosts = locator<DockerStore>();
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
@@ -33,7 +36,7 @@ class BackupPage extends StatelessWidget {
|
||||
final s = S.of(context)!;
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text(s.importAndExport, style: textSize18),
|
||||
title: Text(s.backupAndRestore, style: textSize18),
|
||||
),
|
||||
body: Center(
|
||||
child: Column(
|
||||
@@ -50,8 +53,20 @@ class BackupPage extends StatelessWidget {
|
||||
const SizedBox(
|
||||
height: 107,
|
||||
),
|
||||
_buildCard(s.restore, Icons.download, media,
|
||||
() => _showImportDialog(context, s)),
|
||||
_buildCard(s.restore, Icons.download, media, () async {
|
||||
final path = await pickOneFile();
|
||||
if (path == null) {
|
||||
showSnackBar(context, Text(s.notSelected));
|
||||
return;
|
||||
}
|
||||
final file = File(path);
|
||||
if (!file.existsSync()) {
|
||||
showSnackBar(context, Text(s.fileNotExist(path)));
|
||||
return;
|
||||
}
|
||||
final text = await file.readAsString();
|
||||
_import(text, context, s);
|
||||
}),
|
||||
const SizedBox(height: 7),
|
||||
const Divider(),
|
||||
const SizedBox(height: 7),
|
||||
@@ -59,7 +74,23 @@ class BackupPage extends StatelessWidget {
|
||||
s.backup,
|
||||
Icons.file_upload,
|
||||
media,
|
||||
() => _showExportDialog(context, s),
|
||||
() async {
|
||||
final result = _diyEncrtpt(
|
||||
json.encode(
|
||||
Backup(
|
||||
backupFormatVersion,
|
||||
DateTime.now().toString().split('.').first,
|
||||
_server.fetch(),
|
||||
_snippet.fetch(),
|
||||
_privateKey.fetch(),
|
||||
_dockerHosts.fetch(),
|
||||
),
|
||||
),
|
||||
);
|
||||
final path = '${(await docDir).path}/srvbox_bak.json';
|
||||
await File(path).writeAsString(result);
|
||||
await shareFiles(context, [path]);
|
||||
},
|
||||
)
|
||||
],
|
||||
)),
|
||||
@@ -93,77 +124,12 @@ class BackupPage extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _showExportDialog(BuildContext context, S s) async {
|
||||
final exportFieldController = TextEditingController()
|
||||
..text = _diyEncrtpt(
|
||||
json.encode(
|
||||
Backup(
|
||||
backupFormatVersion,
|
||||
DateTime.now().toString().split('.').first,
|
||||
_server.fetch(),
|
||||
_snippet.fetch(),
|
||||
_privateKey.fetch(),
|
||||
_setting.primaryColor.fetch() ?? Colors.pinkAccent.value,
|
||||
_setting.serverStatusUpdateInterval.fetch() ?? 2,
|
||||
_setting.launchPage.fetch() ?? 0,
|
||||
),
|
||||
),
|
||||
);
|
||||
await showRoundDialog(
|
||||
context,
|
||||
s.export,
|
||||
TextField(
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'JSON',
|
||||
),
|
||||
maxLines: 7,
|
||||
controller: exportFieldController,
|
||||
),
|
||||
[
|
||||
TextButton(
|
||||
child: Text(s.copy),
|
||||
onPressed: () {
|
||||
Clipboard.setData(ClipboardData(text: exportFieldController.text));
|
||||
Navigator.pop(context);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _showImportDialog(BuildContext context, S s) async {
|
||||
final importFieldController = TextEditingController();
|
||||
await showRoundDialog(
|
||||
context,
|
||||
s.import,
|
||||
TextField(
|
||||
decoration: const InputDecoration(
|
||||
labelText: 'JSON',
|
||||
),
|
||||
maxLines: 3,
|
||||
controller: importFieldController,
|
||||
),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(s.cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async =>
|
||||
await _import(importFieldController.text.trim(), context, s),
|
||||
child: const Text('GO'),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> _import(String text, BuildContext context, S s) async {
|
||||
if (text.isEmpty) {
|
||||
showSnackBar(context, Text(s.fieldMustNotEmpty));
|
||||
return;
|
||||
}
|
||||
_importBackup(text, context, s);
|
||||
Navigator.of(context).pop();
|
||||
await _importBackup(text, context, s);
|
||||
}
|
||||
|
||||
Future<void> _importBackup(String raw, BuildContext context, S s) async {
|
||||
@@ -180,7 +146,7 @@ class BackupPage extends StatelessWidget {
|
||||
Text(s.restoreSureWithDate(backup.date)),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(s.cancel),
|
||||
),
|
||||
TextButton(
|
||||
@@ -194,19 +160,32 @@ class BackupPage extends StatelessWidget {
|
||||
for (final s in backup.keys) {
|
||||
_privateKey.put(s);
|
||||
}
|
||||
_setting.primaryColor.put(backup.primaryColor);
|
||||
_setting.serverStatusUpdateInterval
|
||||
.put(backup.serverStatusUpdateInterval);
|
||||
_setting.launchPage.put(backup.launchPage);
|
||||
Navigator.of(context).pop();
|
||||
showSnackBar(context, Text(s.restoreSuccess));
|
||||
for (final k in backup.dockerHosts.keys) {
|
||||
_dockerHosts.setDockerHost(k, backup.dockerHosts[k]!);
|
||||
}
|
||||
context.pop();
|
||||
showRoundDialog(
|
||||
context,
|
||||
s.attention,
|
||||
Text(s.restoreSuccess),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => rebuildAll(context),
|
||||
child: Text(s.restart),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(s.cancel),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
child: Text(s.ok),
|
||||
),
|
||||
],
|
||||
);
|
||||
} catch (e) {
|
||||
showSnackBar(context, Text(s.invalidJson));
|
||||
showSnackBar(context, Text(e.toString()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:toolbox/core/utils/navigator.dart';
|
||||
|
||||
import '../../core/utils/ui.dart';
|
||||
import '../../data/model/docker/ps.dart';
|
||||
@@ -50,7 +51,7 @@ class _DockerManagePageState extends State<DockerManagePage> {
|
||||
final client = locator<ServerProvider>().getServer(widget.spi.id).client;
|
||||
if (client == null) {
|
||||
showSnackBar(context, Text(_s.noClient));
|
||||
Navigator.of(context).pop();
|
||||
context.pop();
|
||||
return;
|
||||
}
|
||||
_docker.init(client, widget.spi.user, onPwdRequest, widget.spi.id);
|
||||
@@ -119,12 +120,12 @@ class _DockerManagePageState extends State<DockerManagePage> {
|
||||
),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
context.pop();
|
||||
await _showAddCmdPreview(
|
||||
_buildAddCmd(
|
||||
imageCtrl.text.trim(),
|
||||
@@ -146,12 +147,12 @@ class _DockerManagePageState extends State<DockerManagePage> {
|
||||
Text(cmd),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
context.pop();
|
||||
final result = await _docker.run(cmd);
|
||||
if (result != null) {
|
||||
showSnackBar(context, Text(getErrMsg(result) ?? _s.unknownError));
|
||||
@@ -187,13 +188,13 @@ class _DockerManagePageState extends State<DockerManagePage> {
|
||||
if (_textController.text == '') {
|
||||
showRoundDialog(context, _s.attention, Text(_s.fieldMustNotEmpty), [
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.ok),
|
||||
),
|
||||
]);
|
||||
return;
|
||||
}
|
||||
Navigator.of(context).pop();
|
||||
context.pop();
|
||||
}
|
||||
|
||||
Future<String> onPwdRequest() async {
|
||||
@@ -213,8 +214,8 @@ class _DockerManagePageState extends State<DockerManagePage> {
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop();
|
||||
context.pop();
|
||||
context.pop();
|
||||
},
|
||||
child: Text(_s.cancel),
|
||||
),
|
||||
@@ -294,12 +295,12 @@ class _DockerManagePageState extends State<DockerManagePage> {
|
||||
Text(_s.sureDelete(e.repo)),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
context.pop();
|
||||
final result = await _docker.run(
|
||||
'docker rmi ${e.id} -f',
|
||||
);
|
||||
@@ -375,12 +376,12 @@ class _DockerManagePageState extends State<DockerManagePage> {
|
||||
onSubmitted: (value) {
|
||||
locator<DockerStore>().setDockerHost(widget.spi.id, value.trim());
|
||||
_docker.refresh();
|
||||
Navigator.of(context).pop();
|
||||
context.pop();
|
||||
},
|
||||
),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.cancel),
|
||||
),
|
||||
],
|
||||
@@ -478,7 +479,7 @@ class _DockerManagePageState extends State<DockerManagePage> {
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
context.pop();
|
||||
_docker.delete(dItem.containerId);
|
||||
},
|
||||
child: Text(_s.ok),
|
||||
|
||||
@@ -2,10 +2,14 @@ import 'package:after_layout/after_layout.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:toolbox/core/utils/navigator.dart';
|
||||
import 'package:toolbox/data/provider/app.dart';
|
||||
import 'package:toolbox/data/res/misc.dart';
|
||||
|
||||
import '../../core/analysis.dart';
|
||||
import '../../core/route.dart';
|
||||
import '../../core/update.dart';
|
||||
import '../../core/utils/platform.dart';
|
||||
import '../../core/utils/ui.dart';
|
||||
import '../../data/model/app/dynamic_color.dart';
|
||||
import '../../data/model/app/navigation_item.dart';
|
||||
@@ -42,8 +46,11 @@ class _MyHomePageState extends State<MyHomePage>
|
||||
AutomaticKeepAliveClientMixin,
|
||||
AfterLayoutMixin,
|
||||
WidgetsBindingObserver {
|
||||
late final ServerProvider _serverProvider;
|
||||
final _serverProvider = locator<ServerProvider>();
|
||||
final _setting = locator<SettingStore>();
|
||||
|
||||
late final PageController _pageController;
|
||||
|
||||
late int _selectIndex;
|
||||
late double _width;
|
||||
late S _s;
|
||||
@@ -51,9 +58,8 @@ class _MyHomePageState extends State<MyHomePage>
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_serverProvider = locator<ServerProvider>();
|
||||
WidgetsBinding.instance.addObserver(this);
|
||||
_selectIndex = locator<SettingStore>().launchPage.fetch()!;
|
||||
_selectIndex = _setting.launchPage.fetch()!;
|
||||
_pageController = PageController(initialPage: _selectIndex);
|
||||
}
|
||||
|
||||
@@ -74,12 +80,27 @@ class _MyHomePageState extends State<MyHomePage>
|
||||
@override
|
||||
void didChangeAppLifecycleState(AppLifecycleState state) {
|
||||
super.didChangeAppLifecycleState(state);
|
||||
if (state == AppLifecycleState.paused) {
|
||||
_serverProvider.setDisconnected();
|
||||
_serverProvider.stopAutoRefresh();
|
||||
}
|
||||
if (state == AppLifecycleState.resumed) {
|
||||
_serverProvider.startAutoRefresh();
|
||||
if (isDesktop) return;
|
||||
|
||||
switch (state) {
|
||||
case AppLifecycleState.resumed:
|
||||
if (isIOS) {
|
||||
_serverProvider.startAutoRefresh();
|
||||
}
|
||||
break;
|
||||
case AppLifecycleState.paused:
|
||||
// Keep running in background on Android device
|
||||
if (isAndroid && _setting.bgRun.fetch()!) {
|
||||
if (locator<AppProvider>().moveBg) {
|
||||
bgRunChannel.invokeMethod('sendToBackground');
|
||||
}
|
||||
} else {
|
||||
_serverProvider.setDisconnected();
|
||||
_serverProvider.stopAutoRefresh();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,7 +254,7 @@ class _MyHomePageState extends State<MyHomePage>
|
||||
child: Text(_s.feedback),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.close),
|
||||
)
|
||||
],
|
||||
@@ -245,27 +266,44 @@ class _MyHomePageState extends State<MyHomePage>
|
||||
onTap: () => AppRoute(const SnippetListPage(), 'snippet list')
|
||||
.go(context),
|
||||
),
|
||||
AboutListTile(
|
||||
icon: const Icon(Icons.text_snippet),
|
||||
applicationName: '\n${BuildData.name}',
|
||||
applicationVersion: _versionStr,
|
||||
applicationIcon: _buildIcon(),
|
||||
aboutBoxChildren: [
|
||||
UrlText(
|
||||
text: _s.madeWithLove(myGithub),
|
||||
replace: 'lollipopkit'),
|
||||
UrlText(
|
||||
text: _s.aboutThanks,
|
||||
),
|
||||
// Thanks
|
||||
...thanksMap.keys.map(
|
||||
(key) => UrlText(
|
||||
text: thanksMap[key] ?? '',
|
||||
replace: key,
|
||||
ListTile(
|
||||
leading: const Icon(Icons.text_snippet),
|
||||
title: Text(_s.about),
|
||||
onTap: () {
|
||||
showRoundDialog(
|
||||
context,
|
||||
_s.about,
|
||||
Column(
|
||||
mainAxisSize: MainAxisSize.min,
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
UrlText(
|
||||
text: _s.madeWithLove(myGithub),
|
||||
replace: 'lollipopkit'),
|
||||
UrlText(
|
||||
text: _s.aboutThanks,
|
||||
),
|
||||
// Thanks
|
||||
...thanksMap.keys.map(
|
||||
(key) => UrlText(
|
||||
text: thanksMap[key] ?? '',
|
||||
replace: key,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
],
|
||||
child: Text(_s.about),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => showLicensePage(context: context),
|
||||
child: Text(_s.license),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.close),
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
)
|
||||
],
|
||||
),
|
||||
@@ -307,7 +345,8 @@ class _MyHomePageState extends State<MyHomePage>
|
||||
@override
|
||||
Future<void> afterFirstLayout(BuildContext context) async {
|
||||
await GetIt.I.allReady();
|
||||
await locator<ServerProvider>().loadLocalData();
|
||||
await _serverProvider.loadLocalData();
|
||||
await _serverProvider.refreshData();
|
||||
await doUpdate(context);
|
||||
if (!Analysis.enabled) {
|
||||
await Analysis.init();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:toolbox/core/utils/navigator.dart';
|
||||
|
||||
import '../../data/model/pkg/upgrade_info.dart';
|
||||
import '../../data/model/server/dist.dart';
|
||||
@@ -51,7 +52,7 @@ class _PkgManagePageState extends State<PkgManagePage>
|
||||
final si = locator<ServerProvider>().getServer(widget.spi.id);
|
||||
if (si.client == null) {
|
||||
showSnackBar(context, Text(_s.waitConnection));
|
||||
Navigator.of(context).pop();
|
||||
context.pop();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -76,14 +77,14 @@ class _PkgManagePageState extends State<PkgManagePage>
|
||||
Text(_s.fieldMustNotEmpty),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.ok),
|
||||
),
|
||||
],
|
||||
);
|
||||
return;
|
||||
}
|
||||
Navigator.of(context).pop();
|
||||
context.pop();
|
||||
}
|
||||
|
||||
Future<String> onPwdRequest() async {
|
||||
@@ -103,8 +104,8 @@ class _PkgManagePageState extends State<PkgManagePage>
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop();
|
||||
context.pop();
|
||||
context.pop();
|
||||
},
|
||||
child: Text(_s.cancel)),
|
||||
TextButton(
|
||||
|
||||
@@ -7,6 +7,7 @@ import 'package:flutter/services.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:toolbox/core/extension/numx.dart';
|
||||
import 'package:toolbox/core/utils/misc.dart';
|
||||
import 'package:toolbox/core/utils/navigator.dart';
|
||||
import 'package:toolbox/data/res/misc.dart';
|
||||
|
||||
import '../../../core/utils/server.dart';
|
||||
@@ -68,7 +69,7 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage>
|
||||
tooltip: _s.delete,
|
||||
onPressed: () {
|
||||
_provider.delInfo(widget.info!);
|
||||
Navigator.of(context).pop();
|
||||
context.pop();
|
||||
},
|
||||
icon: const Icon(Icons.delete))
|
||||
: const SizedBox()
|
||||
@@ -176,7 +177,7 @@ class _PrivateKeyEditPageState extends State<PrivateKeyEditPage>
|
||||
} else {
|
||||
_provider.addInfo(info);
|
||||
}
|
||||
Navigator.of(context).pop();
|
||||
context.pop();
|
||||
},
|
||||
child: const Icon(Icons.save),
|
||||
),
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:after_layout/after_layout.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:toolbox/core/utils/navigator.dart';
|
||||
|
||||
import '../../../core/route.dart';
|
||||
import '../../../core/utils/ui.dart';
|
||||
@@ -74,8 +75,8 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
_serverProvider.delServer(widget.spi!.id);
|
||||
Navigator.of(context).pop();
|
||||
Navigator.of(context).pop();
|
||||
context.pop();
|
||||
context.pop();
|
||||
},
|
||||
child: Text(
|
||||
_s.ok,
|
||||
@@ -83,7 +84,7 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
||||
),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.cancel),
|
||||
)
|
||||
],
|
||||
@@ -232,11 +233,11 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
||||
Text(_s.sureNoPwd),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(false),
|
||||
onPressed: () => context.pop(false),
|
||||
child: Text(_s.ok),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(true),
|
||||
onPressed: () => context.pop(true),
|
||||
child: Text(_s.cancel),
|
||||
)
|
||||
],
|
||||
@@ -277,7 +278,7 @@ class _ServerEditPageState extends State<ServerEditPage> with AfterLayoutMixin {
|
||||
_serverProvider.updateServer(widget.spi!, spi);
|
||||
}
|
||||
|
||||
Navigator.of(context).pop();
|
||||
context.pop();
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:get_it/get_it.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:toolbox/core/utils/navigator.dart';
|
||||
|
||||
import '../../../core/route.dart';
|
||||
import '../../../core/utils/ui.dart';
|
||||
@@ -11,7 +12,6 @@ import '../../../data/model/server/server.dart';
|
||||
import '../../../data/model/server/server_private_info.dart';
|
||||
import '../../../data/model/server/server_status.dart';
|
||||
import '../../../data/provider/server.dart';
|
||||
import '../../../data/provider/snippet.dart';
|
||||
import '../../../data/res/color.dart';
|
||||
import '../../../data/res/menu.dart';
|
||||
import '../../../data/res/ui.dart';
|
||||
@@ -19,13 +19,11 @@ import '../../../data/res/url.dart';
|
||||
import '../../../data/store/setting.dart';
|
||||
import '../../../locator.dart';
|
||||
import '../../widget/dropdown_menu.dart';
|
||||
import '../../widget/picker.dart';
|
||||
import '../../widget/round_rect_card.dart';
|
||||
import '../../widget/url_text.dart';
|
||||
import '../docker.dart';
|
||||
import '../pkg.dart';
|
||||
import '../sftp/view.dart';
|
||||
import '../snippet/edit.dart';
|
||||
import '../ssh.dart';
|
||||
import 'detail.dart';
|
||||
import 'edit.dart';
|
||||
@@ -118,7 +116,7 @@ class _ServerPageState extends State<ServerPage>
|
||||
.go(context),
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.all(13),
|
||||
child: _buildRealServerCard(si.status, si.spi.name, si.cs, si.spi),
|
||||
child: _buildRealServerCard(si.status, si.spi.name, si.state, si.spi),
|
||||
),
|
||||
onTap: () => AppRoute(ServerDetailPage(si.spi.id), 'server detail page')
|
||||
.go(context),
|
||||
@@ -225,7 +223,7 @@ class _ServerPageState extends State<ServerPage>
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
context.pop();
|
||||
AppRoute(SSHPage(spi: spi), 'ssh page').go(context);
|
||||
},
|
||||
child: Text(_s.ok),
|
||||
@@ -266,7 +264,21 @@ class _ServerPageState extends State<ServerPage>
|
||||
AppRoute(SFTPPage(spi), 'SFTP').go(context);
|
||||
break;
|
||||
case ServerTabMenuItems.snippet:
|
||||
_showSnippetDialog(spi.id);
|
||||
showSnippetDialog(context, _s, (s) async {
|
||||
final result =
|
||||
await locator<ServerProvider>().runSnippet(spi.id, s);
|
||||
showRoundDialog(
|
||||
context,
|
||||
_s.result,
|
||||
Text(result ?? _s.error, style: textSize13),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.ok),
|
||||
)
|
||||
],
|
||||
);
|
||||
});
|
||||
break;
|
||||
case ServerTabMenuItems.edit:
|
||||
AppRoute(ServerEditPage(spi: spi), 'Edit server info').go(context);
|
||||
@@ -382,61 +394,6 @@ class _ServerPageState extends State<ServerPage>
|
||||
);
|
||||
}
|
||||
|
||||
void _showSnippetDialog(String id) {
|
||||
final provider = locator<SnippetProvider>();
|
||||
if (provider.snippets.isEmpty) {
|
||||
showRoundDialog(
|
||||
context,
|
||||
_s.attention,
|
||||
Text(_s.noSavedSnippet),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.pop(context),
|
||||
child: Text(_s.ok),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
Navigator.of(context).pop();
|
||||
AppRoute(const SnippetEditPage(), 'edit snippet').go(context);
|
||||
},
|
||||
child: Text(_s.addOne),
|
||||
)
|
||||
],
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
var snippet = provider.snippets.first;
|
||||
showRoundDialog(
|
||||
context,
|
||||
_s.choose,
|
||||
buildPicker(
|
||||
provider.snippets.map((e) => Text(e.name)).toList(),
|
||||
(idx) => snippet = provider.snippets[idx],
|
||||
),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
final result = await _serverProvider.runSnippet(id, snippet);
|
||||
showRoundDialog(
|
||||
context,
|
||||
_s.result,
|
||||
Text(result ?? _s.error, style: textSize13),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(_s.ok),
|
||||
)
|
||||
],
|
||||
);
|
||||
},
|
||||
child: Text(_s.run),
|
||||
)
|
||||
],
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
bool get wantKeepAlive => true;
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:flutter_material_color_picker/flutter_material_color_picker.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:toolbox/data/res/path.dart';
|
||||
|
||||
import '../../core/utils/misc.dart';
|
||||
import '../../core/utils/platform.dart';
|
||||
@@ -15,6 +14,7 @@ import '../../data/provider/app.dart';
|
||||
import '../../data/provider/server.dart';
|
||||
import '../../data/res/build_data.dart';
|
||||
import '../../data/res/color.dart';
|
||||
import '../../data/res/path.dart';
|
||||
import '../../data/res/tab.dart';
|
||||
import '../../data/res/ui.dart';
|
||||
import '../../data/store/setting.dart';
|
||||
@@ -61,6 +61,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
_nightMode = _setting.themeMode.fetch()!;
|
||||
_updateInterval = _setting.serverStatusUpdateInterval.fetch()!.toDouble();
|
||||
_maxRetryCount = _setting.maxRetryCount.fetch()!.toDouble();
|
||||
_selectedColorValue = _setting.primaryColor.fetch()!;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -78,6 +79,9 @@ class _SettingPageState extends State<SettingPage> {
|
||||
// Server
|
||||
_buildTitle(_s.server),
|
||||
_buildServer(),
|
||||
// SSH
|
||||
_buildTitle('SSH'),
|
||||
_buildSSH(),
|
||||
const SizedBox(height: 37),
|
||||
],
|
||||
),
|
||||
@@ -102,11 +106,13 @@ class _SettingPageState extends State<SettingPage> {
|
||||
_buildAppColorPreview(),
|
||||
_buildLaunchPage(),
|
||||
_buildCheckUpdate(),
|
||||
_buildFont(),
|
||||
];
|
||||
if (isIOS) {
|
||||
children.add(_buildPushToken());
|
||||
}
|
||||
if (isAndroid) {
|
||||
children.add(_buildBgRun());
|
||||
}
|
||||
return Column(
|
||||
children: children.map((e) => RoundRectCard(e)).toList(),
|
||||
);
|
||||
@@ -117,12 +123,20 @@ class _SettingPageState extends State<SettingPage> {
|
||||
children: [
|
||||
_buildDistLogoSwitch(),
|
||||
_buildUpdateInterval(),
|
||||
_buildTermTheme(),
|
||||
_buildMaxRetry(),
|
||||
].map((e) => RoundRectCard(e)).toList(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSSH() {
|
||||
return Column(
|
||||
children: [
|
||||
_buildTermTheme(),
|
||||
_buildFont(),
|
||||
].map((e) => RoundRectCard(e)).toList(),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildDistLogoSwitch() {
|
||||
return ListTile(
|
||||
title: Text(
|
||||
@@ -478,11 +492,17 @@ class _SettingPageState extends State<SettingPage> {
|
||||
Future<void> _pickFontFile() async {
|
||||
final path = await pickOneFile();
|
||||
if (path != null) {
|
||||
final fontDir_ = await fontDir;
|
||||
final fontFile = File(path);
|
||||
final newPath = '${fontDir_.path}/${path.split('/').last}';
|
||||
await fontFile.copy(newPath);
|
||||
_setting.fontPath.put(newPath);
|
||||
// iOS can't copy file to app dir, so we need to use the original path
|
||||
if (isIOS) {
|
||||
_setting.fontPath.put(path);
|
||||
} else {
|
||||
final fontDir_ = await fontDir;
|
||||
final fontFile = File(path);
|
||||
final newPath = '${fontDir_.path}/${path.split('/').last}';
|
||||
await fontFile.copy(newPath);
|
||||
_setting.fontPath.put(newPath);
|
||||
}
|
||||
|
||||
setState(() {});
|
||||
_showRestartSnackbar();
|
||||
return;
|
||||
@@ -498,4 +518,11 @@ class _SettingPageState extends State<SettingPage> {
|
||||
() => rebuildAll(context),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBgRun() {
|
||||
return ListTile(
|
||||
title: Text(_s.bgRun),
|
||||
trailing: buildSwitch(context, _setting.bgRun),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:toolbox/core/utils/navigator.dart';
|
||||
|
||||
import '../../../core/extension/numx.dart';
|
||||
import '../../../core/extension/stringx.dart';
|
||||
@@ -29,7 +30,7 @@ class _SFTPDownloadedPageState extends State<SFTPDownloadedPage> {
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
sftpDownloadDir.then((dir) {
|
||||
sftpDir.then((dir) {
|
||||
_path = PathWithPrefix(dir.path);
|
||||
_prefixPath = '${dir.path}/';
|
||||
setState(() {});
|
||||
@@ -144,21 +145,21 @@ class _SFTPDownloadedPageState extends State<SFTPDownloadedPage> {
|
||||
leading: const Icon(Icons.delete),
|
||||
title: Text(_s.delete),
|
||||
onTap: () {
|
||||
Navigator.of(context).pop();
|
||||
context.pop();
|
||||
showRoundDialog(
|
||||
context,
|
||||
_s.sureDelete(fileName),
|
||||
const SizedBox(),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
file.deleteSync();
|
||||
setState(() {});
|
||||
Navigator.of(context).pop();
|
||||
context.pop();
|
||||
},
|
||||
child: Text(_s.ok),
|
||||
),
|
||||
@@ -177,7 +178,7 @@ class _SFTPDownloadedPageState extends State<SFTPDownloadedPage> {
|
||||
),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: (() => Navigator.of(context).pop()),
|
||||
onPressed: (() => context.pop()),
|
||||
child: Text(_s.close),
|
||||
)
|
||||
],
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'dart:typed_data';
|
||||
import 'package:dartssh2/dartssh2.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:toolbox/core/utils/navigator.dart';
|
||||
|
||||
import '../../../core/extension/numx.dart';
|
||||
import '../../../core/extension/stringx.dart';
|
||||
@@ -18,6 +19,7 @@ import '../../../data/provider/sftp_download.dart';
|
||||
import '../../../data/res/path.dart';
|
||||
import '../../../data/store/private_key.dart';
|
||||
import '../../../locator.dart';
|
||||
import '../../widget/center_loading.dart';
|
||||
import '../../widget/fade_in.dart';
|
||||
import '../../widget/two_line_text.dart';
|
||||
import 'downloading.dart';
|
||||
@@ -113,7 +115,7 @@ class _SFTPPageState extends State<SFTPPage> {
|
||||
),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.close),
|
||||
)
|
||||
],
|
||||
@@ -134,14 +136,13 @@ class _SFTPPageState extends State<SFTPPage> {
|
||||
labelText: _s.path,
|
||||
hintText: '/',
|
||||
),
|
||||
onSubmitted: (value) =>
|
||||
Navigator.of(context).pop(value),
|
||||
onSubmitted: (value) => context.pop(value),
|
||||
),
|
||||
],
|
||||
),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.cancel),
|
||||
)
|
||||
],
|
||||
@@ -177,7 +178,7 @@ class _SFTPPageState extends State<SFTPPage> {
|
||||
);
|
||||
|
||||
Widget _buildFileView() {
|
||||
if (_client == null || _si?.cs != ServerState.connected) {
|
||||
if (_client == null || _si?.state != ServerState.connected) {
|
||||
return centerCircleLoading;
|
||||
}
|
||||
|
||||
@@ -279,7 +280,7 @@ class _SFTPPageState extends State<SFTPPage> {
|
||||
),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.cancel),
|
||||
)
|
||||
],
|
||||
@@ -293,16 +294,14 @@ class _SFTPPageState extends State<SFTPPage> {
|
||||
Text('${_s.dl2Local(name.filename)}\n${_s.keepForeground}'),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
Navigator.of(context).pop();
|
||||
final prePath = _status.path!.path;
|
||||
final remotePath =
|
||||
prePath + (prePath.endsWith('/') ? '' : '/') + name.filename;
|
||||
final local = '${(await sftpDownloadDir).path}$remotePath';
|
||||
context.pop();
|
||||
final remotePath = _getRemotePath(name);
|
||||
final local = '${(await sftpDir).path}$remotePath';
|
||||
final pubKeyId = widget.spi.pubKeyId;
|
||||
|
||||
locator<SftpProvider>().add(
|
||||
@@ -316,7 +315,7 @@ class _SFTPPageState extends State<SFTPPage> {
|
||||
: locator<PrivateKeyStore>().get(pubKeyId).privateKey,
|
||||
);
|
||||
|
||||
Navigator.of(context).pop();
|
||||
context.pop();
|
||||
},
|
||||
child: Text(_s.download),
|
||||
)
|
||||
@@ -325,20 +324,46 @@ class _SFTPPageState extends State<SFTPPage> {
|
||||
}
|
||||
|
||||
void delete(BuildContext context, SftpName file) {
|
||||
Navigator.of(context).pop();
|
||||
context.pop();
|
||||
final isDir = file.attr.isDirectory;
|
||||
showRoundDialog(
|
||||
context,
|
||||
_s.attention,
|
||||
Text(_s.sureDelete(file.filename)),
|
||||
Text(
|
||||
'${_s.sureDelete(file.filename)}${isDir ? '\n${_s.sureDirEmpty}' : ''}'),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: const Text('Cancel'),
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.cancel),
|
||||
),
|
||||
TextButton(
|
||||
onPressed: () {
|
||||
_status.client!.remove(file.filename);
|
||||
Navigator.of(context).pop();
|
||||
onPressed: () async {
|
||||
context.pop();
|
||||
showRoundDialog(context, 'Waiting...', centerSizedLoading, [],
|
||||
barrierDismiss: false);
|
||||
final remotePath = _getRemotePath(file);
|
||||
try {
|
||||
if (file.attr.isDirectory) {
|
||||
await _status.client!.rmdir(remotePath);
|
||||
} else {
|
||||
await _status.client!.remove(remotePath);
|
||||
}
|
||||
context.pop();
|
||||
} catch (e) {
|
||||
context.pop();
|
||||
showRoundDialog(
|
||||
context,
|
||||
_s.attention,
|
||||
Text(e.toString()),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.ok),
|
||||
)
|
||||
],
|
||||
);
|
||||
return;
|
||||
}
|
||||
listDir();
|
||||
},
|
||||
child: Text(
|
||||
@@ -351,7 +376,7 @@ class _SFTPPageState extends State<SFTPPage> {
|
||||
}
|
||||
|
||||
void mkdir(BuildContext context) {
|
||||
Navigator.of(context).pop();
|
||||
context.pop();
|
||||
final textController = TextEditingController();
|
||||
showRoundDialog(
|
||||
context,
|
||||
@@ -364,7 +389,7 @@ class _SFTPPageState extends State<SFTPPage> {
|
||||
),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.cancel),
|
||||
),
|
||||
TextButton(
|
||||
@@ -376,7 +401,7 @@ class _SFTPPageState extends State<SFTPPage> {
|
||||
Text(_s.fieldMustNotEmpty),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.ok),
|
||||
),
|
||||
],
|
||||
@@ -385,7 +410,7 @@ class _SFTPPageState extends State<SFTPPage> {
|
||||
}
|
||||
_status.client!
|
||||
.mkdir('${_status.path!.path}/${textController.text}');
|
||||
Navigator.of(context).pop();
|
||||
context.pop();
|
||||
listDir();
|
||||
},
|
||||
child: Text(
|
||||
@@ -398,7 +423,7 @@ class _SFTPPageState extends State<SFTPPage> {
|
||||
}
|
||||
|
||||
void newFile(BuildContext context) {
|
||||
Navigator.of(context).pop();
|
||||
context.pop();
|
||||
final textController = TextEditingController();
|
||||
showRoundDialog(
|
||||
context,
|
||||
@@ -411,7 +436,7 @@ class _SFTPPageState extends State<SFTPPage> {
|
||||
),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.cancel),
|
||||
),
|
||||
TextButton(
|
||||
@@ -423,7 +448,7 @@ class _SFTPPageState extends State<SFTPPage> {
|
||||
Text(_s.fieldMustNotEmpty),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.ok),
|
||||
),
|
||||
],
|
||||
@@ -433,7 +458,7 @@ class _SFTPPageState extends State<SFTPPage> {
|
||||
(await _status.client!
|
||||
.open('${_status.path!.path}/${textController.text}'))
|
||||
.writeBytes(Uint8List(0));
|
||||
Navigator.of(context).pop();
|
||||
context.pop();
|
||||
listDir();
|
||||
},
|
||||
child: Text(
|
||||
@@ -446,7 +471,7 @@ class _SFTPPageState extends State<SFTPPage> {
|
||||
}
|
||||
|
||||
void rename(BuildContext context, SftpName file) {
|
||||
Navigator.of(context).pop();
|
||||
context.pop();
|
||||
final textController = TextEditingController();
|
||||
showRoundDialog(
|
||||
context,
|
||||
@@ -458,9 +483,7 @@ class _SFTPPageState extends State<SFTPPage> {
|
||||
),
|
||||
),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
child: Text(_s.cancel)),
|
||||
TextButton(onPressed: () => context.pop(), child: Text(_s.cancel)),
|
||||
TextButton(
|
||||
onPressed: () async {
|
||||
if (textController.text == '') {
|
||||
@@ -470,7 +493,7 @@ class _SFTPPageState extends State<SFTPPage> {
|
||||
Text(_s.fieldMustNotEmpty),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.ok),
|
||||
),
|
||||
],
|
||||
@@ -478,7 +501,7 @@ class _SFTPPageState extends State<SFTPPage> {
|
||||
return;
|
||||
}
|
||||
await _status.client!.rename(file.filename, textController.text);
|
||||
Navigator.of(context).pop();
|
||||
context.pop();
|
||||
listDir();
|
||||
},
|
||||
child: Text(
|
||||
@@ -490,6 +513,11 @@ class _SFTPPageState extends State<SFTPPage> {
|
||||
);
|
||||
}
|
||||
|
||||
String _getRemotePath(SftpName name) {
|
||||
final prePath = _status.path!.path;
|
||||
return prePath + (prePath.endsWith('/') ? '' : '/') + name.filename;
|
||||
}
|
||||
|
||||
Future<void> listDir({String? path, SSHClient? client}) async {
|
||||
if (_status.isBusy) {
|
||||
return;
|
||||
@@ -517,7 +545,7 @@ class _SFTPPageState extends State<SFTPPage> {
|
||||
Text(e.toString()),
|
||||
[
|
||||
TextButton(
|
||||
onPressed: () => Navigator.of(context).pop(),
|
||||
onPressed: () => context.pop(),
|
||||
child: Text(_s.ok),
|
||||
)
|
||||
],
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:after_layout/after_layout.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:toolbox/core/utils/navigator.dart';
|
||||
|
||||
import '../../../core/utils/ui.dart';
|
||||
import '../../../data/model/server/snippet.dart';
|
||||
@@ -49,7 +50,7 @@ class _SnippetEditPageState extends State<SnippetEditPage>
|
||||
? IconButton(
|
||||
onPressed: () {
|
||||
_provider.del(widget.snippet!);
|
||||
Navigator.of(context).pop();
|
||||
context.pop();
|
||||
},
|
||||
tooltip: _s.delete,
|
||||
icon: const Icon(Icons.delete))
|
||||
@@ -93,7 +94,7 @@ class _SnippetEditPageState extends State<SnippetEditPage>
|
||||
} else {
|
||||
_provider.add(snippet);
|
||||
}
|
||||
Navigator.of(context).pop();
|
||||
context.pop();
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
@@ -6,6 +6,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_gen/gen_l10n/l10n.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:toolbox/core/utils/navigator.dart';
|
||||
import 'package:xterm/xterm.dart' hide TerminalColors;
|
||||
|
||||
import '../../core/utils/platform.dart';
|
||||
@@ -42,6 +43,9 @@ class _SSHPageState extends State<SSHPage> {
|
||||
late TextStyle _menuTextStyle;
|
||||
late TerminalColors _termColors;
|
||||
late S _s;
|
||||
late TerminalStyle _terminalStyle;
|
||||
late TerminalUITheme _termUITheme;
|
||||
late TerminalTheme _terminalTheme;
|
||||
|
||||
var _isDark = false;
|
||||
|
||||
@@ -50,6 +54,8 @@ class _SSHPageState extends State<SSHPage> {
|
||||
super.initState();
|
||||
final termColorIdx = _setting.termColorIdx.fetch()!;
|
||||
_termColors = TerminalColorsPlatform.values[termColorIdx].colors;
|
||||
final ts = TextStyle(fontFamily: getFileName(_setting.fontPath.fetch()));
|
||||
_terminalStyle = TerminalStyle.fromTextStyle(ts);
|
||||
initTerminal();
|
||||
}
|
||||
|
||||
@@ -60,6 +66,8 @@ class _SSHPageState extends State<SSHPage> {
|
||||
_media = MediaQuery.of(context);
|
||||
_menuTextStyle = TextStyle(color: contentColor.resolve(context));
|
||||
_s = S.of(context)!;
|
||||
_termUITheme = _isDark ? termDarkTheme : termLightTheme;
|
||||
_terminalTheme = _termUITheme.toTerminalTheme(_termColors);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -112,7 +120,7 @@ class _SSHPageState extends State<SSHPage> {
|
||||
|
||||
await session.done;
|
||||
if (mounted) {
|
||||
Navigator.of(context).pop();
|
||||
context.pop();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,11 +133,10 @@ class _SSHPageState extends State<SSHPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final termTheme = _isDark ? termDarkTheme : termLightTheme;
|
||||
Widget child = Scaffold(
|
||||
backgroundColor: termTheme.background,
|
||||
body: _buildBody(termTheme.toTerminalTheme(_termColors)),
|
||||
bottomNavigationBar: _buildBottom(termTheme.background),
|
||||
backgroundColor: _termUITheme.background,
|
||||
body: _buildBody(),
|
||||
bottomNavigationBar: _buildBottom(),
|
||||
);
|
||||
if (isIOS) {
|
||||
child = AnnotatedRegion(
|
||||
@@ -140,7 +147,7 @@ class _SSHPageState extends State<SSHPage> {
|
||||
return child;
|
||||
}
|
||||
|
||||
Widget _buildBody(TerminalTheme termTheme) {
|
||||
Widget _buildBody() {
|
||||
return SizedBox(
|
||||
height: _media.size.height -
|
||||
_virtualKeyboardHeight -
|
||||
@@ -150,9 +157,8 @@ class _SSHPageState extends State<SSHPage> {
|
||||
_terminal,
|
||||
controller: _terminalController,
|
||||
keyboardType: TextInputType.visiblePassword,
|
||||
textStyle: TerminalStyle.fromTextStyle(
|
||||
TextStyle(fontFamily: getFileName(_setting.fontPath.fetch()))),
|
||||
theme: termTheme,
|
||||
textStyle: _terminalStyle,
|
||||
theme: _terminalTheme,
|
||||
deleteDetection: isIOS,
|
||||
onTapUp: _onTapUp,
|
||||
autoFocus: true,
|
||||
@@ -161,14 +167,14 @@ class _SSHPageState extends State<SSHPage> {
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildBottom(Color bgColor) {
|
||||
Widget _buildBottom() {
|
||||
return SafeArea(
|
||||
child: AnimatedPadding(
|
||||
padding: _media.viewInsets,
|
||||
duration: const Duration(milliseconds: 23),
|
||||
curve: Curves.fastOutSlowIn,
|
||||
child: Container(
|
||||
color: bgColor,
|
||||
color: _termUITheme.background,
|
||||
height: _virtualKeyboardHeight,
|
||||
child: Consumer<VirtualKeyboard>(
|
||||
builder: (_, __, ___) => _buildVirtualKey(),
|
||||
@@ -218,7 +224,7 @@ class _SSHPageState extends State<SSHPage> {
|
||||
item.text,
|
||||
style: TextStyle(
|
||||
color: selected ? primaryColor : null,
|
||||
fontSize: 17,
|
||||
fontSize: 15,
|
||||
),
|
||||
);
|
||||
|
||||
@@ -274,6 +280,12 @@ class _SSHPageState extends State<SSHPage> {
|
||||
case VirtualKeyFunc.copy:
|
||||
copy(terminalSelected);
|
||||
break;
|
||||
case VirtualKeyFunc.snippet:
|
||||
showSnippetDialog(context, _s, (s) {
|
||||
_terminal.textInput(s.script);
|
||||
_terminal.keyInput(TerminalKey.enter);
|
||||
});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -304,12 +316,12 @@ class _SSHPageState extends State<SSHPage> {
|
||||
// context: context,
|
||||
// contextMenuBuilder: (context) {
|
||||
// return TextSelectionToolbar(
|
||||
// anchorAbove: detail.globalPosition,
|
||||
// anchorBelow: detail.globalPosition,
|
||||
// anchorAbove: details.globalPosition,
|
||||
// anchorBelow: details.globalPosition,
|
||||
// children: [
|
||||
// TextButton(
|
||||
// child: Text(
|
||||
// 'Paste',
|
||||
// _s.paste,
|
||||
// style: _menuTextStyle,
|
||||
// ),
|
||||
// onPressed: () async {
|
||||
|
||||
@@ -25,10 +25,11 @@ Widget buildPicker(List<Widget> items, Function(int idx) onSelected) {
|
||||
onSelectedItemChanged: (idx) => onSelected(idx),
|
||||
physics: const FixedExtentScrollPhysics(),
|
||||
childDelegate: ListWheelChildBuilderDelegate(
|
||||
builder: (context, index) => Center(
|
||||
child: items[index],
|
||||
),
|
||||
childCount: items.length),
|
||||
builder: (context, index) => Center(
|
||||
child: items[index],
|
||||
),
|
||||
childCount: items.length,
|
||||
),
|
||||
)
|
||||
],
|
||||
),
|
||||
|
||||
18
make.dart
18
make.dart
@@ -5,17 +5,15 @@ import 'dart:convert';
|
||||
import 'dart:io';
|
||||
|
||||
const appName = 'ServerBox';
|
||||
|
||||
const buildDataFilePath = 'lib/data/res/build_data.dart';
|
||||
|
||||
const apkPath = 'build/app/outputs/flutter-apk/app-release.apk';
|
||||
|
||||
const xcarchivePath = 'build/ios/archive/Runner.xcarchive';
|
||||
const appleXCConfigPath = '/Runner.xcodeproj/project.pbxproj';
|
||||
const appleXCConfigPath = 'Runner.xcodeproj/project.pbxproj';
|
||||
|
||||
var regAppleProjectVer = RegExp(r'CURRENT_PROJECT_VERSION = .+;');
|
||||
var regAppleMarketVer = RegExp(r'MARKETING_VERSION = .+');
|
||||
|
||||
const skslFileSuffix = '.sksl.json';
|
||||
|
||||
const buildFuncs = {
|
||||
'ios': flutterBuildIOS,
|
||||
'android': flutterBuildAndroid,
|
||||
@@ -62,7 +60,8 @@ Future<int> getGitModificationCount() async {
|
||||
|
||||
Future<String> getFlutterVersion() async {
|
||||
final result = await fvmRun(['flutter', '--version']);
|
||||
return (result.stdout as String);
|
||||
final stdout = result.stdout as String;
|
||||
return stdout.split('\n')[0].split('•')[0].split(' ')[1].trim();
|
||||
}
|
||||
|
||||
Future<Map<String, dynamic>> getBuildData() async {
|
||||
@@ -109,8 +108,7 @@ Future<void> flutterBuild(
|
||||
'build',
|
||||
buildType,
|
||||
];
|
||||
// No sksl cache for macos
|
||||
final skslPath = '$buildType$skslFileSuffix';
|
||||
final skslPath = '$buildType.sksl.json';
|
||||
if (await File(skslPath).exists()) {
|
||||
args.add('--bundle-sksl-path=$skslPath');
|
||||
}
|
||||
@@ -164,7 +162,7 @@ Future<void> flutterBuildAndroid() async {
|
||||
|
||||
Future<void> changeAppleVersion() async {
|
||||
for (final path in ['ios', 'macos']) {
|
||||
final file = File(path + appleXCConfigPath);
|
||||
final file = File('$path/$appleXCConfigPath');
|
||||
final contents = await file.readAsString();
|
||||
final newContents = contents
|
||||
.replaceAll(regAppleMarketVer, 'MARKETING_VERSION = 1.0.$build;')
|
||||
@@ -198,6 +196,8 @@ void main(List<String> args) async {
|
||||
final stopwatch = Stopwatch()..start();
|
||||
await dartFormat();
|
||||
await getGitCommitCount();
|
||||
// always change version to avoid dismatch version between different
|
||||
// platforms
|
||||
await changeAppleVersion();
|
||||
await updateBuildData();
|
||||
if (args.length > 1) {
|
||||
|
||||
@@ -746,10 +746,10 @@ packages:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: share_plus
|
||||
sha256: "8c6892037b1824e2d7e8f59d54b3105932899008642e6372e5079c6939b4b625"
|
||||
sha256: "692261968a494e47323dcc8bc66d8d52e81bc27cb4b808e4e8d7e8079d4cc01a"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.3.1"
|
||||
version: "6.3.2"
|
||||
share_plus_platform_interface:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
||||
11
pubspec.yaml
11
pubspec.yaml
@@ -47,15 +47,20 @@ dependencies:
|
||||
url: https://github.com/lollipopkit/circle_chart
|
||||
ref: main
|
||||
# path: ../circle_chart
|
||||
r_upgrade: ^0.3.6
|
||||
|
||||
# TODO: Update this :)
|
||||
r_upgrade: 0.3.8+2
|
||||
path_provider: ^2.0.9
|
||||
easy_isolate: ^1.3.0
|
||||
share_plus: ^6.3.1
|
||||
share_plus: ^6.3.2
|
||||
intl: ^0.17.0
|
||||
share_plus_web: ^3.1.0
|
||||
# xterm: ^3.4.1
|
||||
xterm:
|
||||
xterm:
|
||||
path: ../xterm.dart
|
||||
# git:
|
||||
# ref: master
|
||||
# url: https://github.com/lollipopkit/xterm.dart
|
||||
file_picker: ^5.2.5
|
||||
plain_notification_token: ^0.0.4
|
||||
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 332 KiB After Width: | Height: | Size: 392 KiB |
Reference in New Issue
Block a user