This commit is contained in:
open-trade 2020-11-30 21:14:23 +08:00
parent e367a33fc8
commit 0388e51299

View File

@ -212,35 +212,37 @@ class _HomePageState extends State<HomePage> {
final cards = <Widget>[]; final cards = <Widget>[];
var peers = FFI.peers(); var peers = FFI.peers();
peers.forEach((p) { peers.forEach((p) {
cards.add(Card( cards.add(Padding(
child: GestureDetector( padding: EdgeInsets.symmetric(horizontal: 12),
onTap: () => connect('${p.id}'), child: Card(
onLongPressStart: (details) { child: GestureDetector(
var x = details.globalPosition.dx; onTap: () => connect('${p.id}'),
var y = details.globalPosition.dy; onLongPressStart: (details) {
() async { var x = details.globalPosition.dx;
var value = await showMenu( var y = details.globalPosition.dy;
context: context, () async {
position: RelativeRect.fromLTRB(x, y, x, y), var value = await showMenu(
items: [ context: context,
PopupMenuItem<String>( position: RelativeRect.fromLTRB(x, y, x, y),
child: Text('Remove'), value: 'remove'), items: [
], PopupMenuItem<String>(
elevation: 8, child: Text('Remove'), value: 'remove'),
); ],
if (value == 'remove') { elevation: 8,
setState(() => FFI.setByName('remove', '${p.id}')); );
} if (value == 'remove') {
}(); setState(() => FFI.setByName('remove', '${p.id}'));
}, }
child: ListTile( }();
subtitle: Text('${p.username}@${p.hostname}'), },
title: Text('${p.id}'), child: ListTile(
leading: Container( subtitle: Text('${p.username}@${p.hostname}'),
padding: const EdgeInsets.all(6), title: Text('${p.id}'),
child: getPlatformImage('${p.platform}'), leading: Container(
color: str2color('${p.id}${p.platform}', 0x77)), padding: const EdgeInsets.all(6),
)))); child: getPlatformImage('${p.platform}'),
color: str2color('${p.id}${p.platform}', 0x77)),
)))));
}); });
return Wrap(children: cards); return Wrap(children: cards);
} }