From 6b774b52cd5ab35cd8ba893612739015b637fa19 Mon Sep 17 00:00:00 2001 From: open-trade Date: Sat, 21 Nov 2020 02:18:04 +0800 Subject: [PATCH] GestureDetector --- flutter_hbb/lib/remote_page.dart | 51 ++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/flutter_hbb/lib/remote_page.dart b/flutter_hbb/lib/remote_page.dart index 94fc7faa4..ba465a858 100644 --- a/flutter_hbb/lib/remote_page.dart +++ b/flutter_hbb/lib/remote_page.dart @@ -23,6 +23,7 @@ class _RemotePageState extends State { Timer _interval; bool _showBar = true; double _bottom = 0; + bool _pan = false; final FocusNode _focusNode = FocusNode(); @override @@ -140,11 +141,15 @@ class _RemotePageState extends State { showOptions(context); }, ), - IconButton( - color: Colors.white, - icon: Icon(Icons.settings), - onPressed: () {}, - ) + Container( + color: _pan ? Colors.blue[500] : null, + child: IconButton( + color: Colors.white, + icon: Icon(Icons.pan_tool), + onPressed: () { + setState(() => _pan = !_pan); + }, + )) ]), IconButton( color: Colors.white, @@ -159,16 +164,32 @@ class _RemotePageState extends State { body: FlutterEasyLoading( child: Container( color: MyTheme.canvasColor, - child: InteractiveViewer( - constrained: false, - panEnabled: true, - onInteractionUpdate: (details) { - print('$details'); + child: GestureDetector( + onTap: () { + if (_pan) return; }, - child: Stack(children: [ - ImagePaint(), - CursorPaint(), - ]), + onDoubleTap: () { + if (_pan) return; + }, + onLongPress: () { + if (_pan) return; + }, + child: InteractiveViewer( + constrained: false, + panEnabled: _pan, + onInteractionUpdate: (details) { + // print('$details'); + }, + onInteractionStart: (s) { + print('$s'); + }, + onInteractionEnd: (x) { + print('$x'); + }, + child: Stack(children: [ + ImagePaint(), + CursorPaint(), + ])), ), ))))); } @@ -344,7 +365,7 @@ void showOptions(BuildContext context) { }); }, ), - Divider(color: MyTheme.border), + Divider(color: Colors.black), CheckboxListTile( value: showRemoteCursor, onChanged: (v) {