opt.: page struct

This commit is contained in:
lollipopkit🏳️‍⚧️
2025-04-09 12:15:42 +08:00
parent e185414355
commit 391e4f6b65
13 changed files with 1187 additions and 1260 deletions

View File

@@ -71,6 +71,22 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
);
}
@override
FutureOr<void> afterFirstLayout(BuildContext context) {
var initPath = '/';
if (Stores.setting.sftpOpenLastPath.fetch()) {
final history = Stores.history.sftpLastPath.fetch(widget.spi.id);
if (history != null) {
initPath = history;
}
}
_status.path.path = widget.initPath ?? initPath;
_listDir();
}
}
extension _UI on _SftpPageState {
Widget _buildSortMenu() {
final options = [
(_SortType.name, libL10n.name),
@@ -205,7 +221,9 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
),
);
}
}
extension _Actions on _SftpPageState {
void _onItemPress(SftpName file, bool notDir) {
final children = [
ListTile(
@@ -626,6 +644,7 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
fs.removeAt(0);
}
if (mounted) {
// ignore: invalid_use_of_protected_member
setState(() {
_status.files
..clear()
@@ -805,20 +824,6 @@ class _SftpPageState extends State<SftpPage> with AfterLayoutMixin {
icon: const Icon(Icons.home),
);
}
@override
FutureOr<void> afterFirstLayout(BuildContext context) {
var initPath = '/';
if (Stores.setting.sftpOpenLastPath.fetch()) {
final history = Stores.history.sftpLastPath.fetch(widget.spi.id);
if (history != null) {
initPath = history;
}
}
_status.path.path = widget.initPath ?? initPath;
_listDir();
}
}
String? _getDecompressCmd(String filename) {