diff --git a/build.rs b/build.rs index 4d51cd297..176fa8779 100644 --- a/build.rs +++ b/build.rs @@ -77,7 +77,7 @@ fn gen_flutter_rust_bridge() { ..Default::default() }; // run fbr_codegen - lib_flutter_rust_bridge_codegen::frb_codegen(opts).unwrap(); + // lib_flutter_rust_bridge_codegen::frb_codegen(opts).unwrap(); } fn main() { diff --git a/flutter/lib/desktop/pages/remote_page.dart b/flutter/lib/desktop/pages/remote_page.dart index 30e647593..9412e03c5 100644 --- a/flutter/lib/desktop/pages/remote_page.dart +++ b/flutter/lib/desktop/pages/remote_page.dart @@ -31,7 +31,8 @@ class RemotePage extends StatefulWidget { _RemotePageState createState() => _RemotePageState(); } -class _RemotePageState extends State with WindowListener { +class _RemotePageState extends State + with WindowListener, AutomaticKeepAliveClientMixin { Timer? _interval; Timer? _timer; bool _showBar = !isWebDesktop; @@ -234,13 +235,14 @@ class _RemotePageState extends State with WindowListener { @override Widget build(BuildContext context) { + super.build(context); final pi = Provider.of(context).pi; final hideKeyboard = isKeyboardShown() && _showEdit; final showActionButton = !_showBar || hideKeyboard; final keyboard = _ffi.ffiModel.permissions['keyboard'] != false; return WillPopScope( - onWillPop: () async { + onWillPop: () async { clientClose(); return false; }, @@ -254,28 +256,28 @@ class _RemotePageState extends State with WindowListener { child: getRawPointerAndKeyBody( keyboard, Scaffold( - // resizeToAvoidBottomInset: true, + // 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; - } - }); - }), + 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, @@ -287,11 +289,11 @@ class _RemotePageState extends State with WindowListener { child: isWebDesktop ? getBodyForDesktopWithListener(keyboard) : SafeArea( - child: Container( - color: MyTheme.canvasColor, - child: _isPhysicalMouse - ? getBodyForMobile() - : getBodyForMobileWithGesture()))); + child: Container( + color: MyTheme.canvasColor, + child: _isPhysicalMouse + ? getBodyForMobile() + : getBodyForMobileWithGesture()))); }) ], ))), @@ -916,6 +918,9 @@ class _RemotePageState extends State with WindowListener { break; } } + + @override + bool get wantKeepAlive => true; } class ImagePaint extends StatelessWidget { diff --git a/flutter/lib/main.dart b/flutter/lib/main.dart index 2707d9535..e4a75244f 100644 --- a/flutter/lib/main.dart +++ b/flutter/lib/main.dart @@ -22,7 +22,7 @@ Future main(List args) async { // global FFI, use this **ONLY** for global configuration // for convenience, use global FFI on mobile platform // focus on multi-ffi on desktop first - initGlobalFFI(); + await initGlobalFFI(); // await Firebase.initializeApp(); if (isAndroid) { toAndroidChannelInit(); diff --git a/flutter/lib/models/model.dart b/flutter/lib/models/model.dart index 85bdc13b7..5c383f774 100644 --- a/flutter/lib/models/model.dart +++ b/flutter/lib/models/model.dart @@ -913,7 +913,7 @@ class FFI { }(); // every instance will bind a stream } - id = id; + this.id = id; } /// Login with [password], choose if the client should [remember] it. @@ -935,6 +935,7 @@ class FFI { ffiModel.clear(); canvasModel.clear(); resetModifiers(); + print("model closed"); } /// Send **get** command to the Rust core based on [name] and [arg].