Merge pull request #1202 from fufesou/flutter_desktop_remote_menus
Flutter desktop remote menus
This commit is contained in:
commit
d173fd9cec
@ -58,6 +58,8 @@ class _ConnectionPageState extends State<ConnectionPage> {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
|
Provider.of<FfiModel>(context);
|
||||||
|
|
||||||
if (_idController.text.isEmpty) _idController.text = gFFI.getId();
|
if (_idController.text.isEmpty) _idController.text = gFFI.getId();
|
||||||
return Container(
|
return Container(
|
||||||
decoration: BoxDecoration(color: isDarkTheme() ? null : MyTheme.grayBg),
|
decoration: BoxDecoration(color: isDarkTheme() ? null : MyTheme.grayBg),
|
||||||
|
@ -236,15 +236,49 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
_ffi.inputKey(label, down: down, press: press ?? false);
|
_ffi.inputKey(label, down: down, press: press ?? false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget buildBody(FfiModel ffiModel) {
|
||||||
|
final hasDisplays = ffiModel.pi.displays.length > 0;
|
||||||
|
final hideKeyboard = isKeyboardShown() && _showEdit;
|
||||||
|
final showActionButton = !_showBar || hideKeyboard;
|
||||||
|
final keyboard = ffiModel.permissions['keyboard'] != false;
|
||||||
|
return Scaffold(
|
||||||
|
// resizeToAvoidBottomInset: true,
|
||||||
|
floatingActionButton: !showActionButton
|
||||||
|
? null
|
||||||
|
: FloatingActionButton(
|
||||||
|
mini: !hideKeyboard,
|
||||||
|
child:
|
||||||
|
Icon(hideKeyboard ? Icons.expand_more : Icons.expand_less),
|
||||||
|
backgroundColor: MyTheme.accent,
|
||||||
|
onPressed: () {
|
||||||
|
setState(() {
|
||||||
|
if (hideKeyboard) {
|
||||||
|
_showEdit = false;
|
||||||
|
_ffi.invokeMethod("enable_soft_keyboard", false);
|
||||||
|
_mobileFocusNode.unfocus();
|
||||||
|
_physicalFocusNode.requestFocus();
|
||||||
|
} else {
|
||||||
|
_showBar = !_showBar;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
bottomNavigationBar: _showBar && hasDisplays ? getBottomAppBar() : null,
|
||||||
|
body: Overlay(
|
||||||
|
initialEntries: [
|
||||||
|
OverlayEntry(builder: (context) {
|
||||||
|
return Container(
|
||||||
|
color: Colors.black,
|
||||||
|
child: getBodyForDesktopWithListener(keyboard));
|
||||||
|
})
|
||||||
|
],
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
super.build(context);
|
super.build(context);
|
||||||
Provider.of<CanvasModel>(context, listen: false).tabBarHeight =
|
Provider.of<CanvasModel>(context, listen: false).tabBarHeight =
|
||||||
super.widget.tabBarHeight;
|
super.widget.tabBarHeight;
|
||||||
final pi = Provider.of<FfiModel>(context).pi;
|
|
||||||
final hideKeyboard = isKeyboardShown() && _showEdit;
|
|
||||||
final showActionButton = !_showBar || hideKeyboard;
|
|
||||||
final keyboard = _ffi.ffiModel.permissions['keyboard'] != false;
|
|
||||||
return WillPopScope(
|
return WillPopScope(
|
||||||
onWillPop: () async {
|
onWillPop: () async {
|
||||||
clientClose();
|
clientClose();
|
||||||
@ -257,47 +291,11 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
ChangeNotifierProvider.value(value: _ffi.cursorModel),
|
ChangeNotifierProvider.value(value: _ffi.cursorModel),
|
||||||
ChangeNotifierProvider.value(value: _ffi.canvasModel),
|
ChangeNotifierProvider.value(value: _ffi.canvasModel),
|
||||||
],
|
],
|
||||||
child: getRawPointerAndKeyBody(
|
child: getRawPointerAndKeyBody(Consumer<FfiModel>(
|
||||||
keyboard,
|
builder: (context, ffiModel, _child) => buildBody(ffiModel)))));
|
||||||
Scaffold(
|
|
||||||
// resizeToAvoidBottomInset: true,
|
|
||||||
floatingActionButton: !showActionButton
|
|
||||||
? null
|
|
||||||
: FloatingActionButton(
|
|
||||||
mini: !hideKeyboard,
|
|
||||||
child: Icon(hideKeyboard
|
|
||||||
? Icons.expand_more
|
|
||||||
: Icons.expand_less),
|
|
||||||
backgroundColor: MyTheme.accent,
|
|
||||||
onPressed: () {
|
|
||||||
setState(() {
|
|
||||||
if (hideKeyboard) {
|
|
||||||
_showEdit = false;
|
|
||||||
_ffi.invokeMethod(
|
|
||||||
"enable_soft_keyboard", false);
|
|
||||||
_mobileFocusNode.unfocus();
|
|
||||||
_physicalFocusNode.requestFocus();
|
|
||||||
} else {
|
|
||||||
_showBar = !_showBar;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}),
|
|
||||||
bottomNavigationBar: _showBar && pi.displays.length > 0
|
|
||||||
? getBottomAppBar(keyboard)
|
|
||||||
: null,
|
|
||||||
body: Overlay(
|
|
||||||
initialEntries: [
|
|
||||||
OverlayEntry(builder: (context) {
|
|
||||||
return Container(
|
|
||||||
color: Colors.black,
|
|
||||||
child: getBodyForDesktopWithListener(keyboard));
|
|
||||||
})
|
|
||||||
],
|
|
||||||
))),
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget getRawPointerAndKeyBody(bool keyboard, Widget child) {
|
Widget getRawPointerAndKeyBody(Widget child) {
|
||||||
return Listener(
|
return Listener(
|
||||||
onPointerHover: (e) {
|
onPointerHover: (e) {
|
||||||
if (e.kind != ui.PointerDeviceKind.mouse) return;
|
if (e.kind != ui.PointerDeviceKind.mouse) return;
|
||||||
@ -352,8 +350,11 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
'{"id": "${widget.id}", "type": "wheel", "x": "$dx", "y": "$dy"}');
|
'{"id": "${widget.id}", "type": "wheel", "x": "$dx", "y": "$dy"}');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
child: MouseRegion(
|
child: Consumer<FfiModel>(
|
||||||
cursor: keyboard ? SystemMouseCursors.none : MouseCursor.defer,
|
builder: (context, FfiModel, _child) => MouseRegion(
|
||||||
|
cursor: FfiModel.permissions['keyboard'] != false
|
||||||
|
? SystemMouseCursors.none
|
||||||
|
: MouseCursor.defer,
|
||||||
child: FocusScope(
|
child: FocusScope(
|
||||||
autofocus: true,
|
autofocus: true,
|
||||||
child: Focus(
|
child: Focus(
|
||||||
@ -397,10 +398,10 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
}
|
}
|
||||||
return KeyEventResult.handled;
|
return KeyEventResult.handled;
|
||||||
},
|
},
|
||||||
child: child))));
|
child: child)))));
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget getBottomAppBar(bool keyboard) {
|
Widget? getBottomAppBar() {
|
||||||
return BottomAppBar(
|
return BottomAppBar(
|
||||||
elevation: 10,
|
elevation: 10,
|
||||||
color: MyTheme.accent,
|
color: MyTheme.accent,
|
||||||
@ -515,6 +516,7 @@ class _RemotePageState extends State<RemotePage>
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
paints.add(getHelpTools());
|
paints.add(getHelpTools());
|
||||||
|
|
||||||
return MouseRegion(
|
return MouseRegion(
|
||||||
onEnter: (evt) {
|
onEnter: (evt) {
|
||||||
bind.hostStopSystemKeyPropagate(stopped: false);
|
bind.hostStopSystemKeyPropagate(stopped: false);
|
||||||
@ -878,7 +880,14 @@ class ImagePainter extends CustomPainter {
|
|||||||
void paint(Canvas canvas, Size size) {
|
void paint(Canvas canvas, Size size) {
|
||||||
if (image == null) return;
|
if (image == null) return;
|
||||||
canvas.scale(scale, scale);
|
canvas.scale(scale, scale);
|
||||||
canvas.drawImage(image!, new Offset(x, y), new Paint());
|
// https://github.com/flutter/flutter/issues/76187#issuecomment-784628161
|
||||||
|
var paint = new Paint();
|
||||||
|
if (scale > 1.00001) {
|
||||||
|
paint.filterQuality = FilterQuality.high;
|
||||||
|
} else if (scale < 0.99999) {
|
||||||
|
paint.filterQuality = FilterQuality.medium;
|
||||||
|
}
|
||||||
|
canvas.drawImage(image!, new Offset(x, y), paint);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user