optimize model.dart
This commit is contained in:
parent
e9d94fdb24
commit
2e2bf3b8fb
@ -331,7 +331,7 @@ class ImageModel with ChangeNotifier {
|
|||||||
|
|
||||||
ui.Image? get image => _image;
|
ui.Image? get image => _image;
|
||||||
|
|
||||||
String _id = '';
|
String id = '';
|
||||||
|
|
||||||
WeakReference<FFI> parent;
|
WeakReference<FFI> parent;
|
||||||
|
|
||||||
@ -375,7 +375,7 @@ class ImageModel with ChangeNotifier {
|
|||||||
await initializeCursorAndCanvas(parent.target!);
|
await initializeCursorAndCanvas(parent.target!);
|
||||||
}
|
}
|
||||||
if (parent.target?.ffiModel.isPeerAndroid ?? false) {
|
if (parent.target?.ffiModel.isPeerAndroid ?? false) {
|
||||||
bind.sessionPeerOption(id: _id, name: 'view-style', value: 'adaptive');
|
bind.sessionPeerOption(id: id, name: 'view-style', value: 'adaptive');
|
||||||
parent.target?.canvasModel.updateViewStyle();
|
parent.target?.canvasModel.updateViewStyle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -468,7 +468,7 @@ class CanvasModel with ChangeNotifier {
|
|||||||
double _scale = 1.0;
|
double _scale = 1.0;
|
||||||
// the tabbar over the image
|
// the tabbar over the image
|
||||||
double tabBarHeight = 0.0;
|
double tabBarHeight = 0.0;
|
||||||
// TODO multi canvas model
|
// remote id
|
||||||
String id = '';
|
String id = '';
|
||||||
// scroll offset x percent
|
// scroll offset x percent
|
||||||
double _scrollX = 0.0;
|
double _scrollX = 0.0;
|
||||||
@ -681,7 +681,7 @@ class CursorModel with ChangeNotifier {
|
|||||||
double _hoty = 0;
|
double _hoty = 0;
|
||||||
double _displayOriginX = 0;
|
double _displayOriginX = 0;
|
||||||
double _displayOriginY = 0;
|
double _displayOriginY = 0;
|
||||||
String id = ''; // TODO multi cursor model
|
String id = '';
|
||||||
WeakReference<FFI> parent;
|
WeakReference<FFI> parent;
|
||||||
|
|
||||||
ui.Image? get image => _image;
|
ui.Image? get image => _image;
|
||||||
@ -991,7 +991,7 @@ extension ToString on MouseButtons {
|
|||||||
|
|
||||||
enum ConnType { defaultConn, fileTransfer, portForward, rdp }
|
enum ConnType { defaultConn, fileTransfer, portForward, rdp }
|
||||||
|
|
||||||
/// FFI class for communicating with the Rust core.
|
/// Flutter state manager and data communication with the Rust core.
|
||||||
class FFI {
|
class FFI {
|
||||||
var id = '';
|
var id = '';
|
||||||
var shift = false;
|
var shift = false;
|
||||||
@ -1020,7 +1020,7 @@ class FFI {
|
|||||||
ffiModel = FfiModel(WeakReference(this));
|
ffiModel = FfiModel(WeakReference(this));
|
||||||
cursorModel = CursorModel(WeakReference(this));
|
cursorModel = CursorModel(WeakReference(this));
|
||||||
canvasModel = CanvasModel(WeakReference(this));
|
canvasModel = CanvasModel(WeakReference(this));
|
||||||
serverModel = ServerModel(WeakReference(this)); // use global FFI
|
serverModel = ServerModel(WeakReference(this));
|
||||||
chatModel = ChatModel(WeakReference(this));
|
chatModel = ChatModel(WeakReference(this));
|
||||||
fileModel = FileModel(WeakReference(this));
|
fileModel = FileModel(WeakReference(this));
|
||||||
abModel = AbModel(WeakReference(this));
|
abModel = AbModel(WeakReference(this));
|
||||||
@ -1042,12 +1042,6 @@ class FFI {
|
|||||||
.encode(modify({'id': id, 'type': 'wheel', 'y': y.toString()})));
|
.encode(modify({'id': id, 'type': 'wheel', 'y': y.toString()})));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Reconnect to the remote peer.
|
|
||||||
// static reconnect() {
|
|
||||||
// setByName('reconnect');
|
|
||||||
// parent.target?.ffiModel.clearPermissions();
|
|
||||||
// }
|
|
||||||
|
|
||||||
/// Reset key modifiers to false, including [shift], [ctrl], [alt] and [command].
|
/// Reset key modifiers to false, including [shift], [ctrl], [alt] and [command].
|
||||||
resetModifiers() {
|
resetModifiers() {
|
||||||
shift = ctrl = alt = command = false;
|
shift = ctrl = alt = command = false;
|
||||||
@ -1070,7 +1064,7 @@ class FFI {
|
|||||||
msg: json.encode(modify({'type': type, 'buttons': button.value})));
|
msg: json.encode(modify({'type': type, 'buttons': button.value})));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Raw Key
|
/// Send raw Key Event
|
||||||
inputRawKey(String name, int keyCode, int scanCode, bool down) {
|
inputRawKey(String name, int keyCode, int scanCode, bool down) {
|
||||||
bind.sessionHandleFlutterKeyEvent(
|
bind.sessionHandleFlutterKeyEvent(
|
||||||
id: id,
|
id: id,
|
||||||
@ -1080,10 +1074,6 @@ class FFI {
|
|||||||
downOrUp: down);
|
downOrUp: down);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<String> getKeyboardMode() {
|
|
||||||
return bind.sessionGetKeyboardName(id: id);
|
|
||||||
}
|
|
||||||
|
|
||||||
enterOrLeave(bool enter) {
|
enterOrLeave(bool enter) {
|
||||||
// Fix status
|
// Fix status
|
||||||
if (!enter) {
|
if (!enter) {
|
||||||
@ -1097,18 +1087,6 @@ class FFI {
|
|||||||
/// [press] indicates a click event(down and up).
|
/// [press] indicates a click event(down and up).
|
||||||
inputKey(String name, {bool? down, bool? press}) {
|
inputKey(String name, {bool? down, bool? press}) {
|
||||||
if (!ffiModel.keyboard()) return;
|
if (!ffiModel.keyboard()) return;
|
||||||
// final Map<String, String> out = Map();
|
|
||||||
// out['name'] = name;
|
|
||||||
// // default: down = false
|
|
||||||
// if (down == true) {
|
|
||||||
// out['down'] = 'true';
|
|
||||||
// }
|
|
||||||
// // default: press = true
|
|
||||||
// if (press != false) {
|
|
||||||
// out['press'] = 'true';
|
|
||||||
// }
|
|
||||||
// setByName('input_key', json.encode(modify(out)));
|
|
||||||
// TODO id
|
|
||||||
bind.sessionInputKey(
|
bind.sessionInputKey(
|
||||||
id: id,
|
id: id,
|
||||||
name: name,
|
name: name,
|
||||||
@ -1161,7 +1139,7 @@ class FFI {
|
|||||||
} else {
|
} else {
|
||||||
chatModel.resetClientMode();
|
chatModel.resetClientMode();
|
||||||
canvasModel.id = id;
|
canvasModel.id = id;
|
||||||
imageModel._id = id;
|
imageModel.id = id;
|
||||||
cursorModel.id = id;
|
cursorModel.id = id;
|
||||||
}
|
}
|
||||||
// ignore: unused_local_variable
|
// ignore: unused_local_variable
|
||||||
@ -1212,17 +1190,6 @@ class FFI {
|
|||||||
debugPrint('model $id closed');
|
debugPrint('model $id closed');
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Send **get** command to the Rust core based on [name] and [arg].
|
|
||||||
/// Return the result as a string.
|
|
||||||
// String getByName(String name, [String arg = '']) {
|
|
||||||
// return platformFFI.getByName(name, arg);
|
|
||||||
// }
|
|
||||||
|
|
||||||
/// Send **set** command to the Rust core based on [name] and [value].
|
|
||||||
// setByName(String name, [String value = '']) {
|
|
||||||
// platformFFI.setByName(name, value);
|
|
||||||
// }
|
|
||||||
|
|
||||||
handleMouse(Map<String, dynamic> evt, {double tabBarHeight = 0.0}) {
|
handleMouse(Map<String, dynamic> evt, {double tabBarHeight = 0.0}) {
|
||||||
var type = '';
|
var type = '';
|
||||||
var isMove = false;
|
var isMove = false;
|
||||||
|
Loading…
Reference in New Issue
Block a user