fix peer card double click
This commit is contained in:
parent
14f34f589c
commit
343be3ddf2
@ -35,9 +35,10 @@ class _PeerCard extends StatefulWidget {
|
|||||||
/// State for the connection page.
|
/// State for the connection page.
|
||||||
class _PeerCardState extends State<_PeerCard>
|
class _PeerCardState extends State<_PeerCard>
|
||||||
with AutomaticKeepAliveClientMixin {
|
with AutomaticKeepAliveClientMixin {
|
||||||
var _menuPos;
|
var _menuPos = RelativeRect.fill;
|
||||||
final double _cardRadis = 20;
|
final double _cardRadis = 20;
|
||||||
final double _borderWidth = 2;
|
final double _borderWidth = 2;
|
||||||
|
final RxBool _iconMoreHover = false.obs;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@ -64,7 +65,7 @@ class _PeerCardState extends State<_PeerCard>
|
|||||||
: null);
|
: null);
|
||||||
},
|
},
|
||||||
child: GestureDetector(
|
child: GestureDetector(
|
||||||
onDoubleTapDown: (_) => _connect(peer.id),
|
onDoubleTap: () => _connect(peer.id),
|
||||||
child: Obx(() => peerCardUiType.value == PeerUiType.grid
|
child: Obx(() => peerCardUiType.value == PeerUiType.grid
|
||||||
? _buildPeerCard(context, peer, deco)
|
? _buildPeerCard(context, peer, deco)
|
||||||
: _buildPeerTile(context, peer, deco))),
|
: _buildPeerTile(context, peer, deco))),
|
||||||
@ -75,7 +76,6 @@ class _PeerCardState extends State<_PeerCard>
|
|||||||
BuildContext context, Peer peer, Rx<BoxDecoration?> deco) {
|
BuildContext context, Peer peer, Rx<BoxDecoration?> deco) {
|
||||||
final greyStyle =
|
final greyStyle =
|
||||||
TextStyle(fontSize: 12, color: MyTheme.color(context).lighterText);
|
TextStyle(fontSize: 12, color: MyTheme.color(context).lighterText);
|
||||||
RxBool iconHover = false.obs;
|
|
||||||
return Obx(
|
return Obx(
|
||||||
() => Container(
|
() => Container(
|
||||||
foregroundDecoration: deco.value,
|
foregroundDecoration: deco.value,
|
||||||
@ -147,30 +147,7 @@ class _PeerCardState extends State<_PeerCard>
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
InkWell(
|
_actionMore(peer),
|
||||||
child: CircleAvatar(
|
|
||||||
radius: 12,
|
|
||||||
backgroundColor: iconHover.value
|
|
||||||
? MyTheme.color(context).grayBg!
|
|
||||||
: MyTheme.color(context).bg!,
|
|
||||||
child: Icon(
|
|
||||||
Icons.more_vert,
|
|
||||||
size: 18,
|
|
||||||
color: iconHover.value
|
|
||||||
? MyTheme.color(context).text
|
|
||||||
: MyTheme.color(context).lightText,
|
|
||||||
),
|
|
||||||
),
|
|
||||||
onTapDown: (e) {
|
|
||||||
final x = e.globalPosition.dx;
|
|
||||||
final y = e.globalPosition.dy;
|
|
||||||
_menuPos = RelativeRect.fromLTRB(x, y, x, y);
|
|
||||||
},
|
|
||||||
onTap: () {
|
|
||||||
_showPeerMenu(context, peer.id);
|
|
||||||
},
|
|
||||||
onHover: (value) => iconHover.value = value,
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
).paddingSymmetric(horizontal: 4.0),
|
).paddingSymmetric(horizontal: 4.0),
|
||||||
),
|
),
|
||||||
@ -183,7 +160,6 @@ class _PeerCardState extends State<_PeerCard>
|
|||||||
|
|
||||||
Widget _buildPeerCard(
|
Widget _buildPeerCard(
|
||||||
BuildContext context, Peer peer, Rx<BoxDecoration?> deco) {
|
BuildContext context, Peer peer, Rx<BoxDecoration?> deco) {
|
||||||
RxBool iconHover = false.obs;
|
|
||||||
return Card(
|
return Card(
|
||||||
color: Colors.transparent,
|
color: Colors.transparent,
|
||||||
elevation: 0,
|
elevation: 0,
|
||||||
@ -272,29 +248,10 @@ class _PeerCardState extends State<_PeerCard>
|
|||||||
? Colors.green
|
? Colors.green
|
||||||
: Colors.yellow)),
|
: Colors.yellow)),
|
||||||
Text('${peer.id}')
|
Text('${peer.id}')
|
||||||
]),
|
]).paddingSymmetric(vertical: 8),
|
||||||
InkWell(
|
_actionMore(peer),
|
||||||
child: CircleAvatar(
|
|
||||||
radius: 12,
|
|
||||||
backgroundColor: iconHover.value
|
|
||||||
? MyTheme.color(context).grayBg!
|
|
||||||
: MyTheme.color(context).bg!,
|
|
||||||
child: Icon(Icons.more_vert,
|
|
||||||
size: 18,
|
|
||||||
color: iconHover.value
|
|
||||||
? MyTheme.color(context).text
|
|
||||||
: MyTheme.color(context).lightText)),
|
|
||||||
onTapDown: (e) {
|
|
||||||
final x = e.globalPosition.dx;
|
|
||||||
final y = e.globalPosition.dy;
|
|
||||||
_menuPos = RelativeRect.fromLTRB(x, y, x, y);
|
|
||||||
},
|
|
||||||
onTap: () {
|
|
||||||
_showPeerMenu(context, peer.id);
|
|
||||||
},
|
|
||||||
onHover: (value) => iconHover.value = value),
|
|
||||||
],
|
],
|
||||||
).paddingSymmetric(vertical: 8.0, horizontal: 12.0),
|
).paddingSymmetric(horizontal: 12.0),
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
@ -304,6 +261,27 @@ class _PeerCardState extends State<_PeerCard>
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _actionMore(Peer peer) => Listener(
|
||||||
|
onPointerDown: (e) {
|
||||||
|
final x = e.position.dx;
|
||||||
|
final y = e.position.dy;
|
||||||
|
_menuPos = RelativeRect.fromLTRB(x, y, x, y);
|
||||||
|
},
|
||||||
|
onPointerUp: (_) => _showPeerMenu(context, peer.id),
|
||||||
|
child: MouseRegion(
|
||||||
|
onEnter: (_) => _iconMoreHover.value = true,
|
||||||
|
onExit: (_) => _iconMoreHover.value = false,
|
||||||
|
child: CircleAvatar(
|
||||||
|
radius: 14,
|
||||||
|
backgroundColor: _iconMoreHover.value
|
||||||
|
? MyTheme.color(context).grayBg!
|
||||||
|
: MyTheme.color(context).bg!,
|
||||||
|
child: Icon(Icons.more_vert,
|
||||||
|
size: 18,
|
||||||
|
color: _iconMoreHover.value
|
||||||
|
? MyTheme.color(context).text
|
||||||
|
: MyTheme.color(context).lightText))));
|
||||||
|
|
||||||
/// Connect to a peer with [id].
|
/// Connect to a peer with [id].
|
||||||
/// If [isFileTransfer], starts a session only for file transfer.
|
/// If [isFileTransfer], starts a session only for file transfer.
|
||||||
void _connect(String id, {bool isFileTransfer = false}) async {
|
void _connect(String id, {bool isFileTransfer = false}) async {
|
||||||
@ -325,7 +303,7 @@ class _PeerCardState extends State<_PeerCard>
|
|||||||
void _showPeerMenu(BuildContext context, String id) async {
|
void _showPeerMenu(BuildContext context, String id) async {
|
||||||
var value = await showMenu(
|
var value = await showMenu(
|
||||||
context: context,
|
context: context,
|
||||||
position: this._menuPos,
|
position: _menuPos,
|
||||||
items: await super.widget.popupMenuItemsFunc(),
|
items: await super.widget.popupMenuItemsFunc(),
|
||||||
elevation: 8,
|
elevation: 8,
|
||||||
);
|
);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user