mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2026-01-31 13:25:10 +01:00
@@ -691,6 +691,7 @@ class _SettingPageState extends State<SettingPage> {
|
||||
Widget _buildSFTP() {
|
||||
return Column(
|
||||
children: [
|
||||
_buildSftpEditor(),
|
||||
_buildSftpRmrDir(),
|
||||
_buildSftpOpenLastPath(),
|
||||
_buildSftpShowFoldersFirst(),
|
||||
@@ -1237,4 +1238,40 @@ class _SettingPageState extends State<SettingPage> {
|
||||
trailing: StoreSwitch(prop: _setting.letterCache),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildSftpEditor() {
|
||||
return _setting.sftpEditor.listenable().listenVal(
|
||||
(val) {
|
||||
return ListTile(
|
||||
leading: const Icon(MingCute.edit_fill),
|
||||
title: TipText(text: l10n.editor, tip: l10n.sftpEditorTip),
|
||||
trailing: Text(
|
||||
val.isEmpty ? l10n.inner : val,
|
||||
style: UIs.text15,
|
||||
),
|
||||
onTap: () async {
|
||||
final ctrl = TextEditingController(text: val);
|
||||
void onSave(String s) {
|
||||
_setting.sftpEditor.put(s);
|
||||
context.pop();
|
||||
}
|
||||
|
||||
await context.showRoundDialog<bool>(
|
||||
title: l10n.choose,
|
||||
child: Input(
|
||||
controller: ctrl,
|
||||
autoFocus: true,
|
||||
label: l10n.editor,
|
||||
hint: '\$EDITOR / vim / nano ...',
|
||||
icon: Icons.edit,
|
||||
suggestion: false,
|
||||
onSubmitted: onSave,
|
||||
),
|
||||
actions: Btns.oks(onTap: () => onSave(ctrl.text)),
|
||||
);
|
||||
},
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,6 +445,18 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
}
|
||||
|
||||
Future<void> _edit(SftpName name) async {
|
||||
context.pop();
|
||||
|
||||
// #489
|
||||
final editor = Stores.setting.sftpEditor.fetch();
|
||||
if (editor.isNotEmpty) {
|
||||
// Use single quote to avoid escape
|
||||
final cmd = "$editor '${_getRemotePath(name)}'";
|
||||
await AppRoutes.ssh(spi: widget.spi, initCmd: cmd).go(context);
|
||||
await _listDir();
|
||||
return;
|
||||
}
|
||||
|
||||
final size = name.attr.size;
|
||||
if (size == null || size > Miscs.editorMaxSize) {
|
||||
context.showSnackBar(l10n.fileTooLarge(
|
||||
@@ -454,7 +466,6 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
|
||||
));
|
||||
return;
|
||||
}
|
||||
context.pop();
|
||||
|
||||
final remotePath = _getRemotePath(name);
|
||||
final localPath = await _getLocalPath(remotePath);
|
||||
|
||||
Reference in New Issue
Block a user