fix msgbox hasCancel and home id editor focus problem

This commit is contained in:
open-trade 2020-11-24 11:25:56 +08:00
parent 23f1ce5da5
commit 982df980bd
4 changed files with 38 additions and 8 deletions

View File

@ -61,19 +61,22 @@ Future<T> showAlertDialog<T>(BuildContext context, BuildAlertDailog build,
} }
void msgbox(String type, String title, String text, BuildContext context, void msgbox(String type, String title, String text, BuildContext context,
[hasCancel = false]) { [bool hasCancel]) {
if (hasCancel == null) {
hasCancel = type != 'error';
}
showAlertDialog( showAlertDialog(
context, context,
(_) => Tuple3(Text(title), Text(text), [ (_) => Tuple3(Text(title), Text(text), [
hasCancel hasCancel
? Spacer() ? FlatButton(
: FlatButton(
textColor: MyTheme.accent, textColor: MyTheme.accent,
onPressed: () { onPressed: () {
Navigator.pop(context); Navigator.pop(context);
}, },
child: Text('Cancel'), child: Text('Cancel'),
), )
: Spacer(),
FlatButton( FlatButton(
textColor: MyTheme.accent, textColor: MyTheme.accent,
onPressed: () { onPressed: () {

View File

@ -48,6 +48,10 @@ class _HomePageState extends State<HomePage> {
builder: (BuildContext context) => RemotePage(id: id), builder: (BuildContext context) => RemotePage(id: id),
), ),
); );
FocusScopeNode currentFocus = FocusScope.of(context);
if (!currentFocus.hasPrimaryFocus) {
currentFocus.unfocus();
}
} }
Widget getSearchBarUI() { Widget getSearchBarUI() {
@ -98,7 +102,7 @@ class _HomePageState extends State<HomePage> {
color: Color(0xFFB9BABC), color: Color(0xFFB9BABC),
), ),
), ),
autofocus: false, autofocus: _idController.text.isEmpty,
controller: _idController, controller: _idController,
), ),
), ),
@ -110,6 +114,7 @@ class _HomePageState extends State<HomePage> {
icon: Icon(Icons.arrow_forward, icon: Icon(Icons.arrow_forward,
color: Color(0xFFB9BABC), size: 45), color: Color(0xFFB9BABC), size: 45),
onPressed: onConnect, onPressed: onConnect,
autofocus: _idController.text.isNotEmpty,
), ),
) )
], ],

View File

@ -177,7 +177,24 @@ class CanvasModel with ChangeNotifier {
void updateOffset(double dx, double dy) { void updateOffset(double dx, double dy) {
_x += dx; _x += dx;
if (_x > 0) {
_x = 0;
dx = -dx;
}
_y += dy; _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(); notifyListeners();
} }
@ -253,6 +270,14 @@ class CursorModel with ChangeNotifier {
notifyListeners(); 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() { void clear() {
_x = -10000; _x = -10000;
_x = -10000; _x = -10000;

View File

@ -169,9 +169,6 @@ class _RemotePageState extends State<RemotePage> {
if (value == 'mode') {} if (value == 'mode') {}
}(); }();
}, },
onDoubleTap: () {
print('double tap');
},
onTap: () { onTap: () {
print('tap'); print('tap');
}, },