Skip to content

Commit

Permalink
desktop file transfer, all columns respond to tap, add right click it…
Browse files Browse the repository at this point in the history
…em border (rustdesk#9153)

When right click selected item, the border is not obvious but can feel
some change.

Signed-off-by: 21pages <[email protected]>
  • Loading branch information
21pages authored Aug 23, 2024
1 parent 5931af4 commit 50aa8e1
Showing 1 changed file with 63 additions and 40 deletions.
103 changes: 63 additions & 40 deletions flutter/lib/desktop/pages/file_manager_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,7 @@ class _FileManagerViewState extends State<FileManagerView> {
BuildContext context, ScrollController scrollController) {
final fd = controller.directory.value;
final entries = fd.entries;
Rx<Entry?> rightClickEntry = Rx(null);

return ListSearchActionListener(
node: _keyboardNode,
Expand Down Expand Up @@ -989,6 +990,53 @@ class _FileManagerViewState extends State<FileManagerView> {
? " "
: "${entry.lastModified().toString().replaceAll(".000", "")} ";
var secondaryPosition = RelativeRect.fromLTRB(0, 0, 0, 0);
onTap() {
final items = selectedItems;
// handle double click
if (_checkDoubleClick(entry)) {
controller.openDirectory(entry.path);
items.clear();
return;
}
_onSelectedChanged(items, filteredEntries, entry, isLocal);
}

onSecondaryTap() {
final items = [
if (!entry.isDrive &&
versionCmp(_ffi.ffiModel.pi.version, "1.3.0") >= 0)
mod_menu.PopupMenuItem(
child: Text("Rename"),
height: CustomPopupMenuTheme.height,
onTap: () {
controller.renameAction(entry, isLocal);
},
)
];
if (items.isNotEmpty) {
rightClickEntry.value = entry;
final future = mod_menu.showMenu(
context: context,
position: secondaryPosition,
items: items,
);
future.then((value) {
rightClickEntry.value = null;
});
future.onError((error, stackTrace) {
rightClickEntry.value = null;
});
}
}

onSecondaryTapDown(details) {
secondaryPosition = RelativeRect.fromLTRB(
details.globalPosition.dx,
details.globalPosition.dy,
details.globalPosition.dx,
details.globalPosition.dy);
}

return Padding(
padding: EdgeInsets.symmetric(vertical: 1),
child: Obx(() => Container(
Expand All @@ -999,6 +1047,12 @@ class _FileManagerViewState extends State<FileManagerView> {
borderRadius: BorderRadius.all(
Radius.circular(5.0),
),
border: rightClickEntry.value == entry
? Border.all(
color: MyTheme.button,
width: 1.0,
)
: null,
),
key: ValueKey(entry.name),
height: kDesktopFileTransferRowHeight,
Expand Down Expand Up @@ -1047,46 +1101,9 @@ class _FileManagerViewState extends State<FileManagerView> {
]),
)),
),
onTap: () {
final items = selectedItems;
// handle double click
if (_checkDoubleClick(entry)) {
controller.openDirectory(entry.path);
items.clear();
return;
}
_onSelectedChanged(
items, filteredEntries, entry, isLocal);
},
onSecondaryTap: () {
final items = [
if (!entry.isDrive &&
versionCmp(_ffi.ffiModel.pi.version,
"1.3.0") >=
0)
mod_menu.PopupMenuItem(
child: Text("Rename"),
height: CustomPopupMenuTheme.height,
onTap: () {
controller.renameAction(entry, isLocal);
},
)
];
if (items.isNotEmpty) {
mod_menu.showMenu(
context: context,
position: secondaryPosition,
items: items,
);
}
},
onSecondaryTapDown: (details) {
secondaryPosition = RelativeRect.fromLTRB(
details.globalPosition.dx,
details.globalPosition.dy,
details.globalPosition.dx,
details.globalPosition.dy);
},
onTap: onTap,
onSecondaryTap: onSecondaryTap,
onSecondaryTapDown: onSecondaryTapDown,
),
SizedBox(
width: 2.0,
Expand All @@ -1111,6 +1128,9 @@ class _FileManagerViewState extends State<FileManagerView> {
)),
),
),
onTap: onTap,
onSecondaryTap: onSecondaryTap,
onSecondaryTapDown: onSecondaryTapDown,
),
// Divider from header.
SizedBox(
Expand All @@ -1133,6 +1153,9 @@ class _FileManagerViewState extends State<FileManagerView> {
: MyTheme.darkGray),
),
),
onTap: onTap,
onSecondaryTap: onSecondaryTap,
onSecondaryTapDown: onSecondaryTapDown,
),
),
],
Expand Down

0 comments on commit 50aa8e1

Please sign in to comment.