mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-12-11 18:47:47 +00:00
Allow flipping sort order in mobile app's file transfer (#13273)
* Allow flipping sort order in mobile app's file transfer Signed-off-by: Nguyen Quy Hy <nguyenquyhy@live.com.sg> * Change ascending to be non-nullable Signed-off-by: Nguyen Quy Hy <nguyenquyhy@live.com.sg> * Revert file_model change Signed-off-by: Nguyen Quy Hy <nguyenquyhy@live.com.sg> --------- Signed-off-by: Nguyen Quy Hy <nguyenquyhy@live.com.sg>
This commit is contained in:
@@ -424,6 +424,7 @@ class FileManagerView extends StatefulWidget {
|
|||||||
class _FileManagerViewState extends State<FileManagerView> {
|
class _FileManagerViewState extends State<FileManagerView> {
|
||||||
final _listScrollController = ScrollController();
|
final _listScrollController = ScrollController();
|
||||||
final _breadCrumbScroller = ScrollController();
|
final _breadCrumbScroller = ScrollController();
|
||||||
|
late final ascending = Rx<bool>(controller.sortAscending);
|
||||||
|
|
||||||
bool get isLocal => widget.controller.isLocal;
|
bool get isLocal => widget.controller.isLocal;
|
||||||
FileController get controller => widget.controller;
|
FileController get controller => widget.controller;
|
||||||
@@ -589,57 +590,67 @@ class _FileManagerViewState extends State<FileManagerView> {
|
|||||||
|
|
||||||
Widget headTools() => Container(
|
Widget headTools() => Container(
|
||||||
child: Row(
|
child: Row(
|
||||||
children: [
|
|
||||||
Expanded(child: Obx(() {
|
|
||||||
final home = controller.options.value.home;
|
|
||||||
final isWindows = controller.options.value.isWindows;
|
|
||||||
return BreadCrumb(
|
|
||||||
items: getPathBreadCrumbItems(controller.shortPath, isWindows,
|
|
||||||
() => controller.goToHomeDirectory(), (list) {
|
|
||||||
var path = "";
|
|
||||||
if (home.startsWith(list[0])) {
|
|
||||||
// absolute path
|
|
||||||
for (var item in list) {
|
|
||||||
path = PathUtil.join(path, item, isWindows);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
path += home;
|
|
||||||
for (var item in list) {
|
|
||||||
path = PathUtil.join(path, item, isWindows);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
controller.openDirectory(path);
|
|
||||||
}),
|
|
||||||
divider: Icon(Icons.chevron_right),
|
|
||||||
overflow: ScrollableOverflow(controller: _breadCrumbScroller),
|
|
||||||
);
|
|
||||||
})),
|
|
||||||
Row(
|
|
||||||
children: [
|
children: [
|
||||||
IconButton(
|
Expanded(child: Obx(() {
|
||||||
icon: Icon(Icons.arrow_back),
|
final home = controller.options.value.home;
|
||||||
onPressed: controller.goBack,
|
final isWindows = controller.options.value.isWindows;
|
||||||
),
|
return BreadCrumb(
|
||||||
IconButton(
|
items: getPathBreadCrumbItems(controller.shortPath, isWindows,
|
||||||
icon: Icon(Icons.arrow_upward),
|
() => controller.goToHomeDirectory(), (list) {
|
||||||
onPressed: controller.goToParentDirectory,
|
var path = "";
|
||||||
),
|
if (home.startsWith(list[0])) {
|
||||||
PopupMenuButton<SortBy>(
|
// absolute path
|
||||||
tooltip: "",
|
for (var item in list) {
|
||||||
icon: Icon(Icons.sort),
|
path = PathUtil.join(path, item, isWindows);
|
||||||
itemBuilder: (context) {
|
}
|
||||||
return SortBy.values
|
} else {
|
||||||
.map((e) => PopupMenuItem(
|
path += home;
|
||||||
child: Text(translate(e.toString())),
|
for (var item in list) {
|
||||||
value: e,
|
path = PathUtil.join(path, item, isWindows);
|
||||||
))
|
}
|
||||||
.toList();
|
}
|
||||||
},
|
controller.openDirectory(path);
|
||||||
onSelected: controller.changeSortStyle),
|
}),
|
||||||
|
divider: Icon(Icons.chevron_right),
|
||||||
|
overflow: ScrollableOverflow(controller: _breadCrumbScroller),
|
||||||
|
);
|
||||||
|
})),
|
||||||
|
Row(
|
||||||
|
children: [
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Icons.arrow_back),
|
||||||
|
onPressed: controller.goBack,
|
||||||
|
),
|
||||||
|
IconButton(
|
||||||
|
icon: Icon(Icons.arrow_upward),
|
||||||
|
onPressed: controller.goToParentDirectory,
|
||||||
|
),
|
||||||
|
PopupMenuButton<SortBy>(
|
||||||
|
tooltip: "",
|
||||||
|
icon: Icon(Icons.sort),
|
||||||
|
itemBuilder: (context) {
|
||||||
|
return SortBy.values
|
||||||
|
.map((e) => PopupMenuItem(
|
||||||
|
child: Text(translate(e.toString())),
|
||||||
|
value: e,
|
||||||
|
))
|
||||||
|
.toList();
|
||||||
|
},
|
||||||
|
onSelected: (sortBy) {
|
||||||
|
// If selecting the same sort option, flip the order
|
||||||
|
// If selecting a different sort option, use ascending order
|
||||||
|
if (controller.sortBy.value == sortBy) {
|
||||||
|
ascending.value = !controller.sortAscending;
|
||||||
|
} else {
|
||||||
|
ascending.value = true;
|
||||||
|
}
|
||||||
|
controller.changeSortStyle(sortBy, ascending: ascending.value);
|
||||||
|
}
|
||||||
|
),
|
||||||
|
],
|
||||||
|
)
|
||||||
],
|
],
|
||||||
)
|
));
|
||||||
],
|
|
||||||
));
|
|
||||||
|
|
||||||
Widget listTail() => Obx(() => Container(
|
Widget listTail() => Obx(() => Container(
|
||||||
height: 100,
|
height: 100,
|
||||||
|
|||||||
Reference in New Issue
Block a user