diff --git a/flutter_hbb/lib/common.dart b/flutter_hbb/lib/common.dart index 6a1ada3fc..469564182 100644 --- a/flutter_hbb/lib/common.dart +++ b/flutter_hbb/lib/common.dart @@ -61,19 +61,22 @@ Future showAlertDialog(BuildContext context, BuildAlertDailog build, } void msgbox(String type, String title, String text, BuildContext context, - [hasCancel = false]) { + [bool hasCancel]) { + if (hasCancel == null) { + hasCancel = type != 'error'; + } showAlertDialog( context, (_) => Tuple3(Text(title), Text(text), [ hasCancel - ? Spacer() - : FlatButton( + ? FlatButton( textColor: MyTheme.accent, onPressed: () { Navigator.pop(context); }, child: Text('Cancel'), - ), + ) + : Spacer(), FlatButton( textColor: MyTheme.accent, onPressed: () { diff --git a/flutter_hbb/lib/home_page.dart b/flutter_hbb/lib/home_page.dart index 1a7de8666..57f3dca76 100644 --- a/flutter_hbb/lib/home_page.dart +++ b/flutter_hbb/lib/home_page.dart @@ -48,6 +48,10 @@ class _HomePageState extends State { builder: (BuildContext context) => RemotePage(id: id), ), ); + FocusScopeNode currentFocus = FocusScope.of(context); + if (!currentFocus.hasPrimaryFocus) { + currentFocus.unfocus(); + } } Widget getSearchBarUI() { @@ -98,7 +102,7 @@ class _HomePageState extends State { color: Color(0xFFB9BABC), ), ), - autofocus: false, + autofocus: _idController.text.isEmpty, controller: _idController, ), ), @@ -110,6 +114,7 @@ class _HomePageState extends State { icon: Icon(Icons.arrow_forward, color: Color(0xFFB9BABC), size: 45), onPressed: onConnect, + autofocus: _idController.text.isNotEmpty, ), ) ], diff --git a/flutter_hbb/lib/model.dart b/flutter_hbb/lib/model.dart index f976769f4..6588b2352 100644 --- a/flutter_hbb/lib/model.dart +++ b/flutter_hbb/lib/model.dart @@ -177,7 +177,24 @@ class CanvasModel with ChangeNotifier { void updateOffset(double dx, double dy) { _x += dx; + if (_x > 0) { + _x = 0; + dx = -dx; + } _y += dy; + if (_y > 0) { + _y = 0; + dy = -dy; + } + _xPan += dx; + _yPan += dy; + var px = (_xPan > 0 ? _xPan.floor() : _xPan.ceil()).toDouble(); + var py = (_yPan > 0 ? _yPan.floor() : _yPan.ceil()).toDouble(); + if (px != 0 || py != 0) { + FFI.cursorModel.update(-px, -py); + _xPan -= px; + _yPan -= py; + } notifyListeners(); } @@ -253,6 +270,14 @@ class CursorModel with ChangeNotifier { notifyListeners(); } + void update(double dx, double dy) { + _x += dx; + _y += dy; + var x = _x.toInt(); + var y = _y.toInt(); + FFI.setByName('send_mouse', json.encode({'x': '$x', 'y': '$y'})); + } + void clear() { _x = -10000; _x = -10000; diff --git a/flutter_hbb/lib/remote_page.dart b/flutter_hbb/lib/remote_page.dart index ee38e3e97..4a03136e2 100644 --- a/flutter_hbb/lib/remote_page.dart +++ b/flutter_hbb/lib/remote_page.dart @@ -169,9 +169,6 @@ class _RemotePageState extends State { if (value == 'mode') {} }(); }, - onDoubleTap: () { - print('double tap'); - }, onTap: () { print('tap'); },