feat file transfer history (goBack)

This commit is contained in:
csf 2022-10-11 17:25:34 +09:00
parent 168b47469e
commit 5b1a12c6a7
3 changed files with 224 additions and 189 deletions

View File

@ -202,7 +202,7 @@ class _FileManagerPageState extends State<FileManagerPage>
sortColumnIndex: sortIndex,
sortAscending: sortAscending,
columns: [
DataColumn(label: Text(translate(" "))), // icon
DataColumn(label: Text(" ")), // icon
DataColumn(
label: Text(
translate("Name"),
@ -402,10 +402,6 @@ class _FileManagerPageState extends State<FileManagerPage>
));
}
goBack({bool? isLocal}) {
model.goToParentDirectory(isLocal: isLocal);
}
Widget headTools(bool isLocal) {
final locationStatus =
isLocal ? _locationStatusLocal : _locationStatusRemote;
@ -456,14 +452,20 @@ class _FileManagerPageState extends State<FileManagerPage>
icon: const Icon(Icons.home_outlined),
splashRadius: 20,
),
IconButton(
icon: const Icon(Icons.arrow_back),
splashRadius: 20,
onPressed: () {
model.goBack(isLocal: isLocal);
},
),
IconButton(
icon: const Icon(Icons.arrow_upward),
splashRadius: 20,
onPressed: () {
goBack(isLocal: isLocal);
model.goToParentDirectory(isLocal: isLocal);
},
),
menu(isLocal: isLocal),
],
),
Expanded(
@ -508,6 +510,7 @@ class _FileManagerPageState extends State<FileManagerPage>
)),
)),
PopupMenuButton(
tooltip: "",
itemBuilder: (context) => [
PopupMenuItem(
enabled: false,
@ -612,6 +615,7 @@ class _FileManagerPageState extends State<FileManagerPage>
},
splashRadius: 20,
icon: const Icon(Icons.delete_forever_outlined)),
menu(isLocal: isLocal),
],
),
),

View File

@ -16,12 +16,15 @@ class FileModel extends ChangeNotifier {
var _isLocal = false;
var _selectMode = false;
var _localOption = DirectoryOption();
var _remoteOption = DirectoryOption();
final _localOption = DirectoryOption();
final _remoteOption = DirectoryOption();
List<String> localHistory = [];
List<String> remoteHistory = [];
var _jobId = 0;
var _jobProgress = JobProgress(); // from rust update
final _jobProgress = JobProgress(); // from rust update
/// JobTable <jobId, JobProgress>
final _jobTable = List<JobProgress>.empty(growable: true).obs;
@ -368,8 +371,11 @@ class FileModel extends ChangeNotifier {
}
}
openDirectory(String path, {bool? isLocal}) async {
openDirectory(String path, {bool? isLocal, bool isBack = false}) async {
isLocal = isLocal ?? _isLocal;
if (!isBack) {
pushHistory(isLocal);
}
final showHidden =
isLocal ? _localOption.showHidden : _remoteOption.showHidden;
final isWindows =
@ -397,11 +403,34 @@ class FileModel extends ChangeNotifier {
}
}
void pushHistory(bool isLocal) {
final history = isLocal ? localHistory : remoteHistory;
final currPath = isLocal ? currentLocalDir.path : currentRemoteDir.path;
if (history.isNotEmpty && history.last == currPath) {
return;
}
history.add(currPath);
}
goHome({bool? isLocal}) {
isLocal = isLocal ?? _isLocal;
openDirectory(getCurrentHome(isLocal), isLocal: isLocal);
}
goBack({bool? isLocal}) {
isLocal = isLocal ?? _isLocal;
final history = isLocal ? localHistory : remoteHistory;
if (history.isEmpty) return;
final path = history.removeAt(history.length - 1);
if (path.isEmpty) return;
final currPath = isLocal ? currentLocalDir.path : currentRemoteDir.path;
if (currPath == path) {
goBack(isLocal: isLocal);
return;
}
openDirectory(path, isLocal: isLocal, isBack: true);
}
goToParentDirectory({bool? isLocal}) {
isLocal = isLocal ?? _isLocal;
final isWindows =
@ -685,6 +714,8 @@ class FileModel extends ChangeNotifier {
}
sendRemoveEmptyDir(String path, int fileNum, bool isLocal) {
final history = isLocal ? localHistory : remoteHistory;
history.removeWhere((element) => element.contains(path));
bind.sessionRemoveAllEmptyDirs(
id: '${parent.target?.id}',
actId: _jobId,

File diff suppressed because it is too large Load Diff