SyncReturn

This commit is contained in:
csf 2022-06-01 15:09:48 +08:00
parent 317b350d2b
commit 1b7eb73ee8
6 changed files with 20 additions and 19 deletions

2
Cargo.lock generated
View File

@ -1477,7 +1477,7 @@ dependencies = [
[[package]]
name = "flutter_rust_bridge_codegen"
version = "1.32.0"
source = "git+https://github.com/SoLongAndThanksForAllThePizza/flutter_rust_bridge#3cc3818d19b731d5f9893c48699182bed4d4c15e"
source = "git+https://github.com/SoLongAndThanksForAllThePizza/flutter_rust_bridge#e5adce55eea0b74d3680e66a2c5252edf17b07e1"
dependencies = [
"anyhow",
"cargo_metadata",

View File

@ -600,9 +600,8 @@ class _RemotePageState extends State<RemotePage> with WindowListener {
Widget getBodyForDesktopWithListener(bool keyboard) {
var paints = <Widget>[ImagePaint()];
final cursor = FFI.bind.getSessionToggleOptionSync(
id: widget.id, arg: 'show-remote-cursor')[0] ==
1;
final cursor = FFI.bind
.getSessionToggleOptionSync(id: widget.id, arg: 'show-remote-cursor');
if (keyboard || cursor) {
paints.add(CursorPaint());
}
@ -955,7 +954,7 @@ class ImagePainter extends CustomPainter {
CheckboxListTile getToggle(
String id, void Function(void Function()) setState, option, name) {
final opt = FFI.bind.getSessionToggleOptionSync(id: id, arg: option)[0] == 1;
final opt = FFI.bind.getSessionToggleOptionSync(id: id, arg: option);
return CheckboxListTile(
value: opt,
onChanged: (v) {

View File

@ -314,7 +314,7 @@ class ImageModel with ChangeNotifier {
ui.Image? get image => _image;
String id = ""; // TODO multi image model
String _id = "";
void onRgba(Uint8List rgba) {
if (_waitForImage) {
@ -351,7 +351,7 @@ class ImageModel with ChangeNotifier {
Future.delayed(Duration(milliseconds: 1), () {
if (FFI.ffiModel.isPeerAndroid) {
FFI.bind
.sessionPeerOption(id: id, name: "view-style", value: "shrink");
.sessionPeerOption(id: _id, name: "view-style", value: "shrink");
FFI.canvasModel.updateViewStyle();
}
});
@ -850,7 +850,7 @@ class FFI {
// setByName('connect', id);
// TODO multi model instances
FFI.canvasModel.id = id;
FFI.imageModel.id = id;
FFI.imageModel._id = id;
FFI.cursorModel.id = id;
final stream =
FFI.bind.sessionConnect(id: id, isFileTransfer: isFileTransfer);

View File

@ -396,9 +396,11 @@ packages:
flutter_rust_bridge:
dependency: "direct main"
description:
name: flutter_rust_bridge
url: "https://pub.dartlang.org"
source: hosted
path: frb_dart
ref: master
resolved-ref: e5adce55eea0b74d3680e66a2c5252edf17b07e1
url: "https://github.com/SoLongAndThanksForAllThePizza/flutter_rust_bridge"
source: git
version: "1.32.0"
flutter_smart_dialog:
dependency: "direct main"

View File

@ -53,7 +53,11 @@ dependencies:
image_picker: ^0.8.5
image: ^3.1.3
flutter_smart_dialog: ^4.3.1
flutter_rust_bridge: ^1.30.0
flutter_rust_bridge:
git:
url: https://github.com/SoLongAndThanksForAllThePizza/flutter_rust_bridge
ref: master
path: frb_dart
window_manager: ^0.2.3
desktop_multi_window:
git:

View File

@ -95,13 +95,9 @@ pub fn get_session_toggle_option(id: String, arg: String) -> Option<bool> {
}
}
pub fn get_session_toggle_option_sync(id: String, arg: String) -> SyncReturn<Vec<u8>> {
let res = if get_session_toggle_option(id, arg) == Some(true) {
1
} else {
0
};
SyncReturn(vec![res])
pub fn get_session_toggle_option_sync(id: String, arg: String) -> SyncReturn<bool> {
let res = get_session_toggle_option(id, arg) == Some(true);
SyncReturn(res)
}
pub fn get_session_image_quality(id: String) -> Option<String> {