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();
|
||||
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(
|
||||
keyboard,
|
||||
Scaffold(
|
||||
@ -252,14 +259,16 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
||||
? null
|
||||
: FloatingActionButton(
|
||||
mini: !hideKeyboard,
|
||||
child: Icon(
|
||||
hideKeyboard ? Icons.expand_more : Icons.expand_less),
|
||||
child: Icon(hideKeyboard
|
||||
? Icons.expand_more
|
||||
: Icons.expand_less),
|
||||
backgroundColor: MyTheme.accent,
|
||||
onPressed: () {
|
||||
setState(() {
|
||||
if (hideKeyboard) {
|
||||
_showEdit = false;
|
||||
_ffi.invokeMethod("enable_soft_keyboard", false);
|
||||
_ffi.invokeMethod(
|
||||
"enable_soft_keyboard", false);
|
||||
_mobileFocusNode.unfocus();
|
||||
_physicalFocusNode.requestFocus();
|
||||
} else {
|
||||
@ -286,7 +295,7 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
|
||||
})
|
||||
],
|
||||
))),
|
||||
);
|
||||
));
|
||||
}
|
||||
|
||||
Widget getRawPointerAndKeyBody(bool keyboard, Widget child) {
|
||||
@ -916,13 +925,12 @@ class ImagePaint extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final m = ffi(this.id).imageModel;
|
||||
final c = ffi(this.id).canvasModel;
|
||||
final adjust = ffi(this.id).cursorModel.adjustForKeyboard();
|
||||
final m = Provider.of<ImageModel>(context);
|
||||
final c = Provider.of<CanvasModel>(context);
|
||||
var s = c.scale;
|
||||
return CustomPaint(
|
||||
painter: new ImagePainter(
|
||||
image: m.image, x: c.x / s, y: (c.y - adjust) / s, scale: s),
|
||||
painter:
|
||||
new ImagePainter(image: m.image, x: c.x / s, y: c.y / s, scale: s),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -934,15 +942,15 @@ class CursorPaint extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final m = ffi(this.id).cursorModel;
|
||||
final c = ffi(this.id).canvasModel;
|
||||
final adjust = ffi(this.id).cursorModel.adjustForKeyboard();
|
||||
final m = Provider.of<CursorModel>(context);
|
||||
final c = Provider.of<CanvasModel>(context);
|
||||
// final adjust = m.adjustForKeyboard();
|
||||
var s = c.scale;
|
||||
return CustomPaint(
|
||||
painter: new ImagePainter(
|
||||
image: m.image,
|
||||
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),
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user