mirror of
https://github.com/rustdesk/rustdesk.git
synced 2025-01-18 07:43:01 +08:00
flutter_desktop: load popup menu items onTap
Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
parent
279a38a7f2
commit
dab8fc6cc9
@ -167,6 +167,7 @@ class RecentPeerWidget extends BasePeerWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<List<Peer>> _loadPeers() async {
|
Future<List<Peer>> _loadPeers() async {
|
||||||
|
debugPrint("call RecentPeerWidget _loadPeers");
|
||||||
return gFFI.peers();
|
return gFFI.peers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -180,6 +181,7 @@ class FavoritePeerWidget extends BasePeerWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Future<List<Peer>> _loadPeers() async {
|
Future<List<Peer>> _loadPeers() async {
|
||||||
|
debugPrint("call FavoritePeerWidget _loadPeers");
|
||||||
return await gFFI.bind.mainGetFav().then((peers) async {
|
return await gFFI.bind.mainGetFav().then((peers) async {
|
||||||
final peersEntities = await Future.wait(peers
|
final peersEntities = await Future.wait(peers
|
||||||
.map((id) => gFFI.bind.mainGetPeers(id: id))
|
.map((id) => gFFI.bind.mainGetPeers(id: id))
|
||||||
@ -206,6 +208,7 @@ class DiscoveredPeerWidget extends BasePeerWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<List<Peer>> _loadPeers() async {
|
Future<List<Peer>> _loadPeers() async {
|
||||||
|
debugPrint("call DiscoveredPeerWidget _loadPeers");
|
||||||
return await gFFI.bind.mainGetLanPeers().then((peers_string) {
|
return await gFFI.bind.mainGetLanPeers().then((peers_string) {
|
||||||
debugPrint(peers_string);
|
debugPrint(peers_string);
|
||||||
return [];
|
return [];
|
||||||
@ -222,6 +225,7 @@ class AddressBookPeerWidget extends BasePeerWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Future<List<Peer>> _loadPeers() async {
|
Future<List<Peer>> _loadPeers() async {
|
||||||
|
debugPrint("call AddressBookPeerWidget _loadPeers");
|
||||||
return gFFI.abModel.peers.map((e) {
|
return gFFI.abModel.peers.map((e) {
|
||||||
return Peer.fromJson(e['id'], e);
|
return Peer.fromJson(e['id'], e);
|
||||||
}).toList();
|
}).toList();
|
||||||
|
@ -7,11 +7,13 @@ import '../../common.dart';
|
|||||||
import '../../models/model.dart';
|
import '../../models/model.dart';
|
||||||
import '../../models/peer_model.dart';
|
import '../../models/peer_model.dart';
|
||||||
|
|
||||||
|
typedef PopupMenuItemsFunc = Future<List<PopupMenuItem<String>>> Function();
|
||||||
|
|
||||||
class _PeerCard extends StatefulWidget {
|
class _PeerCard extends StatefulWidget {
|
||||||
final Peer peer;
|
final Peer peer;
|
||||||
final List<PopupMenuItem<String>> popupMenuItems;
|
final PopupMenuItemsFunc popupMenuItemsFunc;
|
||||||
|
|
||||||
_PeerCard({required this.peer, required this.popupMenuItems, Key? key})
|
_PeerCard({required this.peer, required this.popupMenuItemsFunc, Key? key})
|
||||||
: super(key: key);
|
: super(key: key);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -148,7 +150,7 @@ class _PeerCardState extends State<_PeerCard> {
|
|||||||
var value = await showMenu(
|
var value = await showMenu(
|
||||||
context: context,
|
context: context,
|
||||||
position: this._menuPos,
|
position: this._menuPos,
|
||||||
items: super.widget.popupMenuItems,
|
items: await super.widget.popupMenuItemsFunc(),
|
||||||
elevation: 8,
|
elevation: 8,
|
||||||
);
|
);
|
||||||
if (value == 'remove') {
|
if (value == 'remove') {
|
||||||
@ -271,17 +273,18 @@ abstract class BasePeerCard extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return _PeerCard(peer: peer, popupMenuItems: _getPopupMenuItems());
|
return _PeerCard(peer: peer, popupMenuItemsFunc: _getPopupMenuItems);
|
||||||
}
|
}
|
||||||
|
|
||||||
@protected
|
@protected
|
||||||
List<PopupMenuItem<String>> _getPopupMenuItems();
|
Future<List<PopupMenuItem<String>>> _getPopupMenuItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
class RecentPeerCard extends BasePeerCard {
|
class RecentPeerCard extends BasePeerCard {
|
||||||
RecentPeerCard({required Peer peer, Key? key}) : super(peer: peer, key: key);
|
RecentPeerCard({required Peer peer, Key? key}) : super(peer: peer, key: key);
|
||||||
|
|
||||||
List<PopupMenuItem<String>> _getPopupMenuItems() {
|
Future<List<PopupMenuItem<String>>> _getPopupMenuItems() async {
|
||||||
|
debugPrint("call RecentPeerCard _getPopupMenuItems");
|
||||||
return [
|
return [
|
||||||
PopupMenuItem<String>(
|
PopupMenuItem<String>(
|
||||||
child: Text(translate('Connect')), value: 'connect'),
|
child: Text(translate('Connect')), value: 'connect'),
|
||||||
@ -304,7 +307,8 @@ class FavoritePeerCard extends BasePeerCard {
|
|||||||
FavoritePeerCard({required Peer peer, Key? key})
|
FavoritePeerCard({required Peer peer, Key? key})
|
||||||
: super(peer: peer, key: key);
|
: super(peer: peer, key: key);
|
||||||
|
|
||||||
List<PopupMenuItem<String>> _getPopupMenuItems() {
|
Future<List<PopupMenuItem<String>>> _getPopupMenuItems() async {
|
||||||
|
debugPrint("call FavoritePeerCard _getPopupMenuItems");
|
||||||
return [
|
return [
|
||||||
PopupMenuItem<String>(
|
PopupMenuItem<String>(
|
||||||
child: Text(translate('Connect')), value: 'connect'),
|
child: Text(translate('Connect')), value: 'connect'),
|
||||||
@ -327,7 +331,8 @@ class DiscoveredPeerCard extends BasePeerCard {
|
|||||||
DiscoveredPeerCard({required Peer peer, Key? key})
|
DiscoveredPeerCard({required Peer peer, Key? key})
|
||||||
: super(peer: peer, key: key);
|
: super(peer: peer, key: key);
|
||||||
|
|
||||||
List<PopupMenuItem<String>> _getPopupMenuItems() {
|
Future<List<PopupMenuItem<String>>> _getPopupMenuItems() async {
|
||||||
|
debugPrint("call DiscoveredPeerCard _getPopupMenuItems");
|
||||||
return [
|
return [
|
||||||
PopupMenuItem<String>(
|
PopupMenuItem<String>(
|
||||||
child: Text(translate('Connect')), value: 'connect'),
|
child: Text(translate('Connect')), value: 'connect'),
|
||||||
@ -350,7 +355,8 @@ class AddressBookPeerCard extends BasePeerCard {
|
|||||||
AddressBookPeerCard({required Peer peer, Key? key})
|
AddressBookPeerCard({required Peer peer, Key? key})
|
||||||
: super(peer: peer, key: key);
|
: super(peer: peer, key: key);
|
||||||
|
|
||||||
List<PopupMenuItem<String>> _getPopupMenuItems() {
|
Future<List<PopupMenuItem<String>>> _getPopupMenuItems() async {
|
||||||
|
debugPrint("call AddressBookPeerCard _getPopupMenuItems");
|
||||||
return [
|
return [
|
||||||
PopupMenuItem<String>(
|
PopupMenuItem<String>(
|
||||||
child: Text(translate('Connect')), value: 'connect'),
|
child: Text(translate('Connect')), value: 'connect'),
|
||||||
|
Loading…
Reference in New Issue
Block a user