migrate: fl_lib

This commit is contained in:
lollipopkit🏳️‍⚧️
2024-08-01 13:44:32 +08:00
parent 969643d3df
commit 73248011a1
11 changed files with 119 additions and 123 deletions

View File

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

View File

@@ -2,6 +2,6 @@
class BuildData {
static const String name = "ServerBox";
static const int build = 1038;
static const int build = 1041;
static const int script = 55;
}

View File

@@ -222,10 +222,10 @@ class BackupPage extends StatelessWidget {
if (text == null) return;
try {
final backup = await context.showLoadingDialog(
final (backup, err) = await context.showLoadingDialog(
fn: () => Computer.shared.start(Backup.fromJsonString, text.trim()),
);
if (backup == null) return;
if (err != null || backup == null) return;
if (backupFormatVersion != backup.version) {
context.showSnackBar(l10n.backupVersionNotMatch);
return;
@@ -364,11 +364,11 @@ class BackupPage extends StatelessWidget {
}
try {
final backup = await context.showLoadingDialog(
final (backup, err) = await context.showLoadingDialog(
fn: () => Computer.shared.start(Backup.fromJsonString, text.trim()),
);
if (err != null || backup == null) return;
if (backup == null) return;
if (backupFormatVersion != backup.version) {
context.showSnackBar(l10n.backupVersionNotMatch);
return;
@@ -404,13 +404,13 @@ class BackupPage extends StatelessWidget {
if (text == null) return;
try {
final spis = await context.showLoadingDialog(
final (spis, err) = await context.showLoadingDialog(
fn: () => Computer.shared.start((val) {
final list = json.decode(val) as List;
return list.map((e) => ServerPrivateInfo.fromJson(e)).toList();
}, text.trim()),
);
if (spis == null) return;
if (err != null || spis == null) return;
final sure = await context.showRoundDialog<bool>(
title: l10n.import,
child: Text(l10n.askContinue('${spis.length} ${l10n.server}')),
@@ -422,7 +422,7 @@ class BackupPage extends StatelessWidget {
],
);
if (sure == true) {
final suc = await context.showLoadingDialog(
final (suc, err) = await context.showLoadingDialog(
fn: () async {
for (var spi in spis) {
Stores.server.put(spi);
@@ -430,7 +430,7 @@ class BackupPage extends StatelessWidget {
return true;
},
);
if (suc != true) return;
if (err != null || suc != true) return;
context.showSnackBar(l10n.success);
}
} catch (e, s) {

View File

@@ -391,11 +391,15 @@ class _ContainerPageState extends State<ContainerPage> {
onPressed: () async {
context.pop();
final result = await context.showLoadingDialog(
final (result, err) = await context.showLoadingDialog(
fn: () => _container.run(cmd),
);
if (result != null) {
context.showSnackBar(result.message ?? l10n.unknownError);
if (err != null || result != null) {
final e = result?.message ?? err?.toString();
context.showRoundDialog(
title: l10n.error,
child: Text(e ?? l10n.unknownError),
);
}
},
child: Text(l10n.run),
@@ -506,13 +510,14 @@ class _ContainerPageState extends State<ContainerPage> {
onPressed: () async {
context.pop();
final result = await context.showLoadingDialog(
final (result, err) = await context.showLoadingDialog(
fn: () => _container.delete(id, force),
);
if (result != null) {
if (err != null || result != null) {
final e = result?.message ?? err?.toString();
context.showRoundDialog(
title: l10n.error,
child: Text(result.message ?? l10n.unknownError),
child: Text(e ?? l10n.unknownError),
);
}
},
@@ -522,35 +527,38 @@ class _ContainerPageState extends State<ContainerPage> {
);
break;
case ContainerMenu.start:
final result = await context.showLoadingDialog(
final (result, err) = await context.showLoadingDialog(
fn: () => _container.start(id),
);
if (result != null) {
if (err != null || result != null) {
final e = result?.message ?? err?.toString();
context.showRoundDialog(
title: l10n.error,
child: Text(result.message ?? l10n.unknownError),
child: Text(e ?? l10n.unknownError),
);
}
break;
case ContainerMenu.stop:
final result = await context.showLoadingDialog(
final (result, err) = await context.showLoadingDialog(
fn: () => _container.stop(id),
);
if (result != null) {
if (err != null || result != null) {
final e = result?.message ?? err?.toString();
context.showRoundDialog(
title: l10n.error,
child: Text(result.message ?? l10n.unknownError),
child: Text(e ?? l10n.unknownError),
);
}
break;
case ContainerMenu.restart:
final result = await context.showLoadingDialog(
final (result, err) = await context.showLoadingDialog(
fn: () => _container.restart(id),
);
if (result != null) {
if (err != null || result != null) {
final e = result?.message ?? err?.toString();
context.showRoundDialog(
title: l10n.error,
child: Text(result.message ?? l10n.unknownError),
child: Text(e ?? l10n.unknownError),
);
}
break;

View File

@@ -145,10 +145,13 @@ class _EditorPageState extends State<EditorPage> {
// If path is not null, then it's a file editor
// save the text and return true to pop the page
if (widget.path != null) {
final res = await context.showLoadingDialog(
final (res, _) = await context.showLoadingDialog(
fn: () => File(widget.path!).writeAsString(_controller.text),
);
if (res == null) return;
if (res == null) {
context.showSnackBar(l10n.failed);
return;
}
context.pop(true);
return;
}

View File

@@ -430,12 +430,13 @@ final class _PvePageState extends State<PvePage> {
);
if (sure != true) return;
final suc =
await context.showLoadingDialog(fn: () => func(item.node, item.id));
final (suc, err) = await context.showLoadingDialog(
fn: () => func(item.node, item.id),
);
if (suc == true) {
context.showSnackBar(l10n.success);
} else {
context.showSnackBar(l10n.failed);
context.showSnackBar(err?.toString() ?? l10n.failed);
}
}

View File

@@ -114,12 +114,12 @@ class _IOSSettingsPageState extends State<IOSSettingsPage> {
final result = await AppRoutes.kvEditor(data: urls).go(context);
if (result == null || result is! Map<String, String>) return;
final suc = await context.showLoadingDialog(fn: () async {
final (suc, err) = await context.showLoadingDialog(fn: () async {
await wc.updateApplicationContext({'urls': result});
return true;
});
if (suc == true) {
context.showSnackBar(l10n.success);
context.showSnackBar(err?.toString() ?? l10n.success);
}
}
}

View File

@@ -471,8 +471,10 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
SftpReqType.download,
);
Pros.sftp.add(req, completer: completer);
final suc = await context.showLoadingDialog(fn: () => completer.future);
if (suc == null) return;
final (suc, err) = await context.showLoadingDialog(
fn: () => completer.future,
);
if (suc == null || err != null) return;
final result = await AppRoutes.editor(path: localPath).go<bool>(context);
if (result != null && result) {
@@ -564,7 +566,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
onPressed: () async {
context.pop();
final suc = await context.showLoadingDialog(
final (suc, err) = await context.showLoadingDialog(
fn: () async {
final remotePath = _getRemotePath(file);
if (useRmr) {
@@ -577,7 +579,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
return true;
},
);
if (suc == null) return;
if (suc == null || err != null) return;
_listDir();
},
@@ -606,14 +608,14 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
}
context.pop();
final suc = await context.showLoadingDialog(
final (suc, err) = await context.showLoadingDialog(
fn: () async {
final dir = '${_status.path!.path}/${textController.text}';
await _status.client!.mkdir(dir);
return true;
},
);
if (suc == null) return;
if (suc == null || err != null) return;
_listDir();
}
@@ -661,14 +663,14 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
}
context.pop();
final suc = await context.showLoadingDialog(
final (suc, err) = await context.showLoadingDialog(
fn: () async {
final path = '${_status.path!.path}/${textController.text}';
await _client!.run('touch "$path"');
return true;
},
);
if (suc == null) return;
if (suc == null || err != null) return;
_listDir();
}
@@ -712,14 +714,14 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
}
context.pop();
final suc = await context.showLoadingDialog(
final (suc, err) = await context.showLoadingDialog(
fn: () async {
final newName = textController.text;
await _status.client?.rename(file.filename, newName);
return true;
},
);
if (suc == null) return;
if (suc == null || err != null) return;
_listDir();
}
@@ -767,10 +769,10 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
);
if (confirm != true) return;
final suc = await context.showLoadingDialog(
final (suc, err) = await context.showLoadingDialog(
fn: () => _client?.run(cmd) ?? Future.value(false),
);
if (suc == null) return;
if (suc == null || err != null) return;
_listDir();
}
@@ -786,65 +788,47 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
/// Only return true if the path is changed
Future<bool?> _listDir() async {
return context.showLoadingDialog(
final (ret, err) = await context.showLoadingDialog(
fn: () async {
_status.client ??= await _client?.sftp();
try {
final listPath = _status.path?.path ?? '/';
final fs = await _status.client?.listdir(listPath);
if (fs == null) {
return false;
}
fs.sort((a, b) => a.filename.compareTo(b.filename));
/// Issue #97
/// In order to compatible with the Synology NAS
/// which not has '.' and '..' in listdir
if (fs.isNotEmpty && fs.firstOrNull?.filename == '.') {
fs.removeAt(0);
}
/// Issue #96
/// Due to [WillPopScope] added in this page
/// There is no need to keep '..' folder in listdir
/// So remove it
if (fs.isNotEmpty && fs.firstOrNull?.filename == '..') {
fs.removeAt(0);
}
if (mounted) {
setState(() {
_status.files = fs;
});
// Only update history when success
if (Stores.setting.sftpOpenLastPath.fetch()) {
Stores.history.sftpLastPath.put(widget.spi.id, listPath);
}
return true;
}
return false;
} catch (e, trace) {
Loggers.app.warning('List dir failed', e, trace);
await _backward();
Future.delayed(
const Duration(milliseconds: 177),
() => context.showRoundDialog(
title: l10n.error,
child: Text(e.toString()),
actions: [
TextButton(
onPressed: () => context.pop(),
child: Text(l10n.ok),
)
],
),
);
final listPath = _status.path?.path ?? '/';
final fs = await _status.client?.listdir(listPath);
if (fs == null) {
return false;
}
fs.sort((a, b) => a.filename.compareTo(b.filename));
/// Issue #97
/// In order to compatible with the Synology NAS
/// which not has '.' and '..' in listdir
if (fs.isNotEmpty && fs.firstOrNull?.filename == '.') {
fs.removeAt(0);
}
/// Issue #96
/// Due to [WillPopScope] added in this page
/// There is no need to keep '..' folder in listdir
/// So remove it
if (fs.isNotEmpty && fs.firstOrNull?.filename == '..') {
fs.removeAt(0);
}
if (mounted) {
setState(() {
_status.files = fs;
});
// Only update history when success
if (Stores.setting.sftpOpenLastPath.fetch()) {
Stores.history.sftpLastPath.put(widget.spi.id, listPath);
}
return true;
}
return false;
},
barrierDismiss: true,
);
return ret ?? err == null;
}
Future<void> _backward() async {

View File

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

View File

@@ -385,8 +385,8 @@ packages:
dependency: "direct main"
description:
path: "."
ref: "v1.0.99"
resolved-ref: d2b9bb5093528cc014e8ddc0bcb70bf7fec16e99
ref: "v1.0.103"
resolved-ref: "29498d4fc22e628dcd46943601c15f12a59b7c4e"
url: "https://github.com/lppcg/fl_lib"
source: git
version: "0.0.1"

View File

@@ -1,7 +1,7 @@
name: server_box
description: server status & toolbox app.
publish_to: 'none'
version: 1.0.1038+1038
version: 1.0.1041+1041
environment:
sdk: ">=3.0.0"
@@ -62,7 +62,7 @@ dependencies:
fl_lib:
git:
url: https://github.com/lppcg/fl_lib
ref: v1.0.99
ref: v1.0.103
dependency_overrides:
# dartssh2: