add: use multi provider for canvas
Signed-off-by: Kingtous <kingtous@qq.com>
This commit is contained in:
parent
d6047a69e2
commit
ed434fa90e
@ -244,6 +244,13 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
clientClose();
|
clientClose();
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
child: MultiProvider(
|
||||||
|
providers: [
|
||||||
|
ChangeNotifierProvider.value(value: _ffi.ffiModel),
|
||||||
|
ChangeNotifierProvider.value(value: _ffi.imageModel),
|
||||||
|
ChangeNotifierProvider.value(value: _ffi.cursorModel),
|
||||||
|
ChangeNotifierProvider.value(value: _ffi.canvasModel),
|
||||||
|
],
|
||||||
child: getRawPointerAndKeyBody(
|
child: getRawPointerAndKeyBody(
|
||||||
keyboard,
|
keyboard,
|
||||||
Scaffold(
|
Scaffold(
|
||||||
@ -252,14 +259,16 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
? null
|
? null
|
||||||
: FloatingActionButton(
|
: FloatingActionButton(
|
||||||
mini: !hideKeyboard,
|
mini: !hideKeyboard,
|
||||||
child: Icon(
|
child: Icon(hideKeyboard
|
||||||
hideKeyboard ? Icons.expand_more : Icons.expand_less),
|
? Icons.expand_more
|
||||||
|
: Icons.expand_less),
|
||||||
backgroundColor: MyTheme.accent,
|
backgroundColor: MyTheme.accent,
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
setState(() {
|
setState(() {
|
||||||
if (hideKeyboard) {
|
if (hideKeyboard) {
|
||||||
_showEdit = false;
|
_showEdit = false;
|
||||||
_ffi.invokeMethod("enable_soft_keyboard", false);
|
_ffi.invokeMethod(
|
||||||
|
"enable_soft_keyboard", false);
|
||||||
_mobileFocusNode.unfocus();
|
_mobileFocusNode.unfocus();
|
||||||
_physicalFocusNode.requestFocus();
|
_physicalFocusNode.requestFocus();
|
||||||
} else {
|
} else {
|
||||||
@ -286,7 +295,7 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
|||||||
})
|
})
|
||||||
],
|
],
|
||||||
))),
|
))),
|
||||||
);
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
Widget getRawPointerAndKeyBody(bool keyboard, Widget child) {
|
Widget getRawPointerAndKeyBody(bool keyboard, Widget child) {
|
||||||
@ -916,13 +925,12 @@ class ImagePaint extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final m = ffi(this.id).imageModel;
|
final m = Provider.of<ImageModel>(context);
|
||||||
final c = ffi(this.id).canvasModel;
|
final c = Provider.of<CanvasModel>(context);
|
||||||
final adjust = ffi(this.id).cursorModel.adjustForKeyboard();
|
|
||||||
var s = c.scale;
|
var s = c.scale;
|
||||||
return CustomPaint(
|
return CustomPaint(
|
||||||
painter: new ImagePainter(
|
painter:
|
||||||
image: m.image, x: c.x / s, y: (c.y - adjust) / s, scale: s),
|
new ImagePainter(image: m.image, x: c.x / s, y: c.y / s, scale: s),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -934,15 +942,15 @@ class CursorPaint extends StatelessWidget {
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
final m = ffi(this.id).cursorModel;
|
final m = Provider.of<CursorModel>(context);
|
||||||
final c = ffi(this.id).canvasModel;
|
final c = Provider.of<CanvasModel>(context);
|
||||||
final adjust = ffi(this.id).cursorModel.adjustForKeyboard();
|
// final adjust = m.adjustForKeyboard();
|
||||||
var s = c.scale;
|
var s = c.scale;
|
||||||
return CustomPaint(
|
return CustomPaint(
|
||||||
painter: new ImagePainter(
|
painter: new ImagePainter(
|
||||||
image: m.image,
|
image: m.image,
|
||||||
x: m.x * s - m.hotx + c.x,
|
x: m.x * s - m.hotx + c.x,
|
||||||
y: m.y * s - m.hoty + c.y - adjust,
|
y: m.y * s - m.hoty + c.y,
|
||||||
scale: 1),
|
scale: 1),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user