new: open sftp with last viewed path

This commit is contained in:
lollipopkit
2023-10-14 23:03:12 +08:00
parent c9d54f4fea
commit a397f81988
14 changed files with 123 additions and 12 deletions

View File

@@ -156,6 +156,8 @@ class _SettingPageState extends State<SettingPage> {
_buildServer(),
_buildTitle('SSH'),
_buildSSH(),
_buildTitle('SFTP'),
_buildSFTP(),
_buildTitle(l10n.editor),
_buildEditor(),
_buildTitle(l10n.fullScreen),
@@ -230,7 +232,6 @@ class _SettingPageState extends State<SettingPage> {
// Use hardware keyboard on desktop, so there is no need to set it
if (isMobile) _buildKeyboardType(),
_buildSSHVirtKeys(),
_buildSftpRmrDir(),
].map((e) => RoundRectCard(e)).toList(),
);
}
@@ -842,6 +843,23 @@ class _SettingPageState extends State<SettingPage> {
);
}
Widget _buildSFTP() {
return Column(
children: [
_buildSftpRmrDir(),
_buildSftpOpenLastPath(),
].map((e) => RoundRectCard(e)).toList(),
);
}
Widget _buildSftpOpenLastPath() {
return ListTile(
title: Text(l10n.openLastPath),
subtitle: Text(l10n.openLastPathTip, style: UIs.textGrey),
trailing: StoreSwitch(prop: _setting.sftpOpenLastPath),
);
}
Widget _buildNetViewType() {
final items = NetViewType.values
.map((e) => PopupMenuItem(

View File

@@ -647,6 +647,12 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
_status.files = fs;
});
context.pop();
// Only update history when success
if (Stores.setting.sftpOpenLastPath.fetch()) {
Stores.history.sftpLastPath.put(widget.spi.id, listPath);
}
return true;
}
return false;
@@ -679,7 +685,14 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
@override
FutureOr<void> afterFirstLayout(BuildContext context) {
_status.path = AbsolutePath(widget.initPath ?? '/');
var initPath = '/';
if (Stores.setting.sftpOpenLastPath.fetch()) {
final history = Stores.history.sftpLastPath.fetch(widget.spi.id);
if (history != null) {
initPath = history;
}
}
_status.path = AbsolutePath(widget.initPath ?? initPath);
_listDir();
}
}