fix: rename file

This commit is contained in:
lollipopkit🏳️‍⚧️
2024-09-22 16:06:09 +08:00
parent eab06abcaf
commit 47aedb2f2e
11 changed files with 164 additions and 142 deletions

View File

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

View File

@@ -17,7 +17,6 @@ import 'package:server_box/view/page/snippet/result.dart';
import 'package:server_box/view/page/ssh/page.dart'; import 'package:server_box/view/page/ssh/page.dart';
import 'package:server_box/view/page/setting/seq/virt_key.dart'; import 'package:server_box/view/page/setting/seq/virt_key.dart';
import 'package:server_box/data/model/server/snippet.dart'; import 'package:server_box/data/model/server/snippet.dart';
import 'package:server_box/view/page/editor.dart';
import 'package:server_box/view/page/process.dart'; import 'package:server_box/view/page/process.dart';
import 'package:server_box/view/page/server/tab.dart'; import 'package:server_box/view/page/server/tab.dart';
import 'package:server_box/view/page/setting/seq/srv_detail_seq.dart'; import 'package:server_box/view/page/setting/seq/srv_detail_seq.dart';
@@ -114,26 +113,6 @@ class AppRoutes {
return AppRoutes(ContainerPage(key: key, spi: spi), 'docker'); return AppRoutes(ContainerPage(key: key, spi: spi), 'docker');
} }
/// - Pop true if the text is changed & [path] is not null
/// - Pop text if [path] is null
static AppRoutes editor({
Key? key,
String? path,
String? text,
String? langCode,
String? title,
}) {
return AppRoutes(
EditorPage(
key: key,
path: path,
text: text,
langCode: langCode,
title: title,
),
'editor');
}
// static AppRoutes fullscreen({Key? key}) { // static AppRoutes fullscreen({Key? key}) {
// return AppRoutes(FullScreenPage(key: key), 'fullscreen'); // return AppRoutes(FullScreenPage(key: key), 'fullscreen');
// } // }

View File

@@ -1,35 +0,0 @@
import 'package:fl_lib/fl_lib.dart';
class AbsolutePath {
String _path;
final _prePath = <String>[];
AbsolutePath(this._path);
String get path => _path;
/// Update path, not set path
set path(String newPath) {
_prePath.add(_path);
if (newPath == '..') {
_path = _path.substring(0, _path.lastIndexOf('/'));
if (_path == '') {
_path = '/';
}
return;
}
if (newPath.startsWith('/')) {
_path = newPath;
return;
}
_path = _path.joinPath(newPath, seperator: '/');
}
bool undo() {
if (_prePath.isEmpty) {
return false;
}
_path = _prePath.removeLast();
return true;
}
}

View File

@@ -1,12 +1,49 @@
import 'package:dartssh2/dartssh2.dart'; import 'package:dartssh2/dartssh2.dart';
import 'package:server_box/data/model/sftp/absolute_path.dart'; import 'package:fl_lib/fl_lib.dart';
/// Remote server only can be linux-like system, so use '/' as seperator
const _sep = '/';
class SftpBrowserStatus { class SftpBrowserStatus {
final List<SftpName> files = []; final List<SftpName> files = [];
final AbsolutePath path = AbsolutePath('/'); final path = _AbsolutePath(_sep);
SftpClient? client; SftpClient? client;
SftpBrowserStatus(SSHClient client) { SftpBrowserStatus(SSHClient client) {
client.sftp().then((value) => this.client = value); client.sftp().then((value) => this.client = value);
} }
} }
class _AbsolutePath {
String _path;
final _prePath = <String>[];
_AbsolutePath(this._path);
String get path => _path;
/// Update path, not set path
set path(String newPath) {
_prePath.add(_path);
if (newPath == '..') {
_path = _path.substring(0, _path.lastIndexOf(_sep));
if (_path == '') {
_path = _sep;
}
return;
}
if (newPath.startsWith(_sep)) {
_path = newPath;
return;
}
_path = _path.joinPath(newPath, seperator: _sep);
}
bool undo() {
if (_prePath.isEmpty) {
return false;
}
_path = _prePath.removeLast();
return true;
}
}

View File

@@ -3,6 +3,6 @@
abstract class BuildData { abstract class BuildData {
static const String name = "ServerBox"; static const String name = "ServerBox";
static const int build = 1091; static const int build = 1095;
static const int script = 58; static const int script = 58;
} }

View File

@@ -14,7 +14,17 @@ import 'package:server_box/data/res/store.dart';
import 'package:server_box/view/widget/two_line_text.dart'; import 'package:server_box/view/widget/two_line_text.dart';
class EditorPage extends StatefulWidget { final class EditorPageRet {
/// If edit text, this includes the edited result
final String? result;
/// Indicates whether it's ok to edit existing file
final bool? editExistedOk;
const EditorPageRet({this.result, this.editExistedOk});
}
final class EditorPageArgs {
/// If path is not null, then it's a file editor /// If path is not null, then it's a file editor
/// If path is null, then it's a text editor /// If path is null, then it's a text editor
final String? path; final String? path;
@@ -28,13 +38,23 @@ class EditorPage extends StatefulWidget {
final String? title; final String? title;
const EditorPage({ const EditorPageArgs({
super.key,
this.path, this.path,
this.text, this.text,
this.langCode, this.langCode,
this.title, this.title,
}); });
}
class EditorPage extends StatefulWidget {
final EditorPageArgs? args;
const EditorPage({super.key, this.args});
static const route = AppRoute<EditorPageRet, EditorPageArgs>(
page: EditorPage.new,
path: '/editor',
);
@override @override
State<EditorPage> createState() => _EditorPageState(); State<EditorPage> createState() => _EditorPageState();
@@ -63,7 +83,8 @@ class _EditorPageState extends State<EditorPage> {
/// Higher priority than [path] /// Higher priority than [path]
if (Stores.setting.editorHighlight.fetch()) { if (Stores.setting.editorHighlight.fetch()) {
_langCode = widget.langCode ?? Highlights.getCode(widget.path); _langCode =
widget.args?.langCode ?? Highlights.getCode(widget.args?.path);
} }
_controller = CodeController( _controller = CodeController(
language: Highlights.all[_langCode], language: Highlights.all[_langCode],
@@ -79,14 +100,15 @@ class _EditorPageState extends State<EditorPage> {
} }
Future<void> _setupCtrl() async { Future<void> _setupCtrl() async {
if (widget.path != null) { final path = widget.args?.path;
final code = await Computer.shared.start( final text = widget.args?.text;
(path) async => await File(path).readAsString(), if (path != null) {
widget.path!, final code = await Computer.shared.startNoParam(
() => File(path).readAsString(),
); );
_controller.text = code; _controller.text = code;
} else if (widget.text != null) { } else if (text != null) {
_controller.text = widget.text!; _controller.text = text;
} }
} }
@@ -117,7 +139,9 @@ class _EditorPageState extends State<EditorPage> {
return CustomAppBar( return CustomAppBar(
centerTitle: true, centerTitle: true,
title: TwoLineText( title: TwoLineText(
up: widget.title ?? widget.path?.getFileName() ?? l10n.unknown, up: widget.args?.title ??
widget.args?.path?.getFileName() ??
l10n.unknown,
down: l10n.editor, down: l10n.editor,
), ),
actions: [ actions: [
@@ -144,20 +168,21 @@ class _EditorPageState extends State<EditorPage> {
onPressed: () async { onPressed: () async {
// If path is not null, then it's a file editor // If path is not null, then it's a file editor
// save the text and return true to pop the page // save the text and return true to pop the page
if (widget.path != null) { final path = widget.args?.path;
if (path != null) {
final (res, _) = await context.showLoadingDialog( final (res, _) = await context.showLoadingDialog(
fn: () => File(widget.path!).writeAsString(_controller.text), fn: () => File(path).writeAsString(_controller.text),
); );
if (res == null) { if (res == null) {
context.showSnackBar(libL10n.fail); context.showSnackBar(libL10n.fail);
return; return;
} }
context.pop(true); context.pop(const EditorPageRet(editExistedOk: true));
return; return;
} }
// else it's a text editor // else it's a text editor
// return the text to the previous page // return the text to the previous page
context.pop(_controller.text); context.pop(EditorPageRet(result: _controller.text));
}, },
) )
], ],

View File

@@ -16,6 +16,7 @@ import 'package:server_box/core/route.dart';
import 'package:server_box/data/model/app/net_view.dart'; import 'package:server_box/data/model/app/net_view.dart';
import 'package:server_box/data/res/build_data.dart'; import 'package:server_box/data/res/build_data.dart';
import 'package:server_box/view/page/backup.dart'; import 'package:server_box/view/page/backup.dart';
import 'package:server_box/view/page/editor.dart';
import 'package:server_box/view/page/private_key/list.dart'; import 'package:server_box/view/page/private_key/list.dart';
const _kIconSize = 23.0; const _kIconSize = 23.0;
@@ -1150,6 +1151,7 @@ final class _AppSettingsPageState extends State<AppSettingsPage> {
_buildCollapseUI(), _buildCollapseUI(),
_buildCupertinoRoute(), _buildCupertinoRoute(),
if (isDesktop) _buildHideTitleBar(), if (isDesktop) _buildHideTitleBar(),
_buildEditRawSettings(),
], ],
); );
} }
@@ -1315,20 +1317,30 @@ final class _AppSettingsPageState extends State<AppSettingsPage> {
); );
} }
Future<void> _onLongPressSetting() async { Widget _buildEditRawSettings() {
return ListTile(
title: const Text('(Dev) Edit raw json'),
trailing: const Icon(Icons.keyboard_arrow_right),
onTap: _editRawSettings,
);
}
Future<void> _editRawSettings() async {
final map = Stores.setting.box.toJson(includeInternal: false); final map = Stores.setting.box.toJson(includeInternal: false);
final keys = map.keys; final keys = map.keys;
/// Encode [map] to String with indent `\t` /// Encode [map] to String with indent `\t`
final text = jsonIndentEncoder.convert(map); final text = jsonIndentEncoder.convert(map);
final result = await AppRoutes.editor( final ret = await EditorPage.route.go(
context,
args: EditorPageArgs(
text: text, text: text,
langCode: 'json', langCode: 'json',
title: libL10n.setting, title: libL10n.setting,
).go<String>(context); ),
if (result == null) { );
return; final result = ret?.result;
} if (result == null) return;
try { try {
final newSettings = json.decode(result) as Map<String, dynamic>; final newSettings = json.decode(result) as Map<String, dynamic>;
Stores.setting.box.putAll(newSettings); Stores.setting.box.putAll(newSettings);

View File

@@ -11,6 +11,7 @@ import 'package:server_box/data/res/misc.dart';
import 'package:server_box/core/route.dart'; import 'package:server_box/core/route.dart';
import 'package:server_box/data/model/app/path_with_prefix.dart'; import 'package:server_box/data/model/app/path_with_prefix.dart';
import 'package:server_box/view/page/editor.dart';
final class LocalFilePageArgs { final class LocalFilePageArgs {
final bool? isPickFile; final bool? isPickFile;
@@ -183,7 +184,7 @@ class _LocalFilePageState extends State<LocalFilePage>
Future<void> _showFileActionDialog(FileSystemEntity file) async { Future<void> _showFileActionDialog(FileSystemEntity file) async {
final fileName = file.path.split('/').last; final fileName = file.path.split('/').last;
if (isPickFile) { if (isPickFile) {
await context.showRoundDialog( context.showRoundDialog(
title: libL10n.file, title: libL10n.file,
child: Text(fileName), child: Text(fileName),
actions: [ actions: [
@@ -199,9 +200,9 @@ class _LocalFilePageState extends State<LocalFilePage>
child: Column( child: Column(
mainAxisSize: MainAxisSize.min, mainAxisSize: MainAxisSize.min,
children: [ children: [
ListTile( Btn.tile(
leading: const Icon(Icons.edit), icon: const Icon(Icons.edit),
title: Text(libL10n.edit), text: libL10n.edit,
onTap: () async { onTap: () async {
context.pop(); context.pop();
final stat = await file.stat(); final stat = await file.stat();
@@ -212,34 +213,35 @@ class _LocalFilePageState extends State<LocalFilePage>
); );
return; return;
} }
final result = await AppRoutes.editor( final ret = await EditorPage.route.go(
path: file.absolute.path, context,
).go<bool>(context); args: EditorPageArgs(path: file.absolute.path),
if (result == true) { );
if (ret?.editExistedOk == true) {
context.showSnackBar(l10n.saved); context.showSnackBar(l10n.saved);
setState(() {}); setState(() {});
} }
}, },
), ),
ListTile( Btn.tile(
leading: const Icon(Icons.abc), icon: const Icon(Icons.abc),
title: Text(libL10n.rename), text: libL10n.rename,
onTap: () { onTap: () {
context.pop(); context.pop();
_showRenameDialog(file); _showRenameDialog(file);
}, },
), ),
ListTile( Btn.tile(
leading: const Icon(Icons.delete), icon: const Icon(Icons.delete),
title: Text(libL10n.delete), text: libL10n.delete,
onTap: () { onTap: () {
context.pop(); context.pop();
_showDeleteDialog(file); _showDeleteDialog(file);
}, },
), ),
ListTile( Btn.tile(
leading: const Icon(Icons.upload), icon: const Icon(Icons.upload),
title: Text(l10n.upload), text: l10n.upload,
onTap: () async { onTap: () async {
context.pop(); context.pop();
@@ -270,9 +272,9 @@ class _LocalFilePageState extends State<LocalFilePage>
context.showSnackBar(l10n.added2List); context.showSnackBar(l10n.added2List);
}, },
), ),
ListTile( Btn.tile(
leading: const Icon(Icons.open_in_new), icon: const Icon(Icons.open_in_new),
title: Text(libL10n.open), text: libL10n.open,
onTap: () { onTap: () {
Pfs.share(path: file.absolute.path); Pfs.share(path: file.absolute.path);
}, },
@@ -283,7 +285,7 @@ class _LocalFilePageState extends State<LocalFilePage>
} }
void _showRenameDialog(FileSystemEntity file) { void _showRenameDialog(FileSystemEntity file) {
final fileName = file.path.split('/').last; final fileName = file.path.split(Pfs.seperator).last;
final ctrl = TextEditingController(text: fileName); final ctrl = TextEditingController(text: fileName);
void onSubmit() async { void onSubmit() async {
final newName = ctrl.text; final newName = ctrl.text;
@@ -293,7 +295,7 @@ class _LocalFilePageState extends State<LocalFilePage>
} }
context.pop(); context.pop();
final newPath = '${file.parent.path}/$newName'; final newPath = '${file.parent.path}${Pfs.seperator}$newName';
await context.showLoadingDialog(fn: () => file.rename(newPath)); await context.showLoadingDialog(fn: () => file.rename(newPath));
setState(() {}); setState(() {});
@@ -305,7 +307,7 @@ class _LocalFilePageState extends State<LocalFilePage>
autoFocus: true, autoFocus: true,
icon: Icons.abc, icon: Icons.abc,
label: libL10n.name, label: libL10n.name,
controller: TextEditingController(text: fileName), controller: ctrl,
suggestion: true, suggestion: true,
maxLines: 3, maxLines: 3,
onSubmitted: (p0) => onSubmit(), onSubmitted: (p0) => onSubmit(),

View File

@@ -14,6 +14,7 @@ import 'package:server_box/data/model/sftp/worker.dart';
import 'package:server_box/data/provider/sftp.dart'; import 'package:server_box/data/provider/sftp.dart';
import 'package:server_box/data/res/misc.dart'; import 'package:server_box/data/res/misc.dart';
import 'package:server_box/data/res/store.dart'; import 'package:server_box/data/res/store.dart';
import 'package:server_box/view/page/editor.dart';
import 'package:server_box/view/page/storage/local.dart'; import 'package:server_box/view/page/storage/local.dart';
import 'package:server_box/view/widget/omit_start_text.dart'; import 'package:server_box/view/widget/omit_start_text.dart';
import 'package:server_box/view/widget/two_line_text.dart'; import 'package:server_box/view/widget/two_line_text.dart';
@@ -302,7 +303,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
} }
final remotePath = _getRemotePath(name); final remotePath = _getRemotePath(name);
final localPath = await _getLocalPath(remotePath); final localPath = _getLocalPath(remotePath);
final completer = Completer(); final completer = Completer();
final req = SftpReq( final req = SftpReq(
widget.spi, widget.spi,
@@ -316,8 +317,11 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
); );
if (suc == null || err != null) return; if (suc == null || err != null) return;
final result = await AppRoutes.editor(path: localPath).go<bool>(context); final ret = await EditorPage.route.go(
if (result != null && result) { context,
args: EditorPageArgs(path: localPath),
);
if (ret?.editExistedOk == true) {
SftpProvider.add(SftpReq( SftpProvider.add(SftpReq(
req.spi, req.spi,
remotePath, remotePath,
@@ -346,7 +350,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
SftpReq( SftpReq(
widget.spi, widget.spi,
remotePath, remotePath,
await _getLocalPath(remotePath), _getLocalPath(remotePath),
SftpReqType.download, SftpReqType.download,
), ),
); );
@@ -554,11 +558,8 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
onSubmitted: (_) => onSubmitted(), onSubmitted: (_) => onSubmitted(),
), ),
actions: [ actions: [
TextButton(onPressed: () => context.pop(), child: Text(libL10n.cancel)), Btn.cancel(),
TextButton( Btn.ok(onTap: onSubmitted, red: true),
onPressed: onSubmitted,
child: Text(libL10n.rename, style: UIs.textRed),
),
], ],
); );
} }
@@ -593,8 +594,9 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
return prePath.joinPath(name.filename, seperator: '/'); return prePath.joinPath(name.filename, seperator: '/');
} }
Future<String> _getLocalPath(String remotePath) async { /// Local file dir + server id + remote path
return Paths.file.joinPath(remotePath); String _getLocalPath(String remotePath) {
return Paths.file.joinPath(widget.spi.id).joinPath(remotePath);
} }
/// Only return true if the path is changed /// Only return true if the path is changed

View File

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

View File

@@ -1,7 +1,7 @@
name: server_box name: server_box
description: server status & toolbox app. description: server status & toolbox app.
publish_to: 'none' publish_to: 'none'
version: 1.0.1091+1091 version: 1.0.1095+1095
environment: environment:
sdk: ">=3.0.0" sdk: ">=3.0.0"