mirror of
https://github.com/Yubico/yubioath-flutter.git
synced 2024-11-22 16:32:01 +03:00
Mac: Keep app running on window hide().
This commit is contained in:
parent
6ead9860fb
commit
f4f48f8158
@ -54,9 +54,9 @@ final _log = Logger('desktop.init');
|
||||
const String _keyWidth = 'DESKTOP_WINDOW_WIDTH';
|
||||
const String _keyHeight = 'DESKTOP_WINDOW_HEIGHT';
|
||||
|
||||
class _WindowResizeListener extends WindowListener {
|
||||
class _WindowEventListener extends WindowListener {
|
||||
final SharedPreferences _prefs;
|
||||
_WindowResizeListener(this._prefs);
|
||||
_WindowEventListener(this._prefs);
|
||||
|
||||
@override
|
||||
void onWindowResize() async {
|
||||
@ -64,6 +64,13 @@ class _WindowResizeListener extends WindowListener {
|
||||
await _prefs.setDouble(_keyWidth, size.width);
|
||||
await _prefs.setDouble(_keyHeight, size.height);
|
||||
}
|
||||
|
||||
@override
|
||||
void onWindowClose() async {
|
||||
if (Platform.isMacOS) {
|
||||
await windowManager.destroy();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Future<Widget> initialize(List<String> argv) async {
|
||||
@ -78,7 +85,7 @@ Future<Widget> initialize(List<String> argv) async {
|
||||
final height = prefs.getDouble(_keyHeight) ?? 720;
|
||||
await windowManager.setSize(Size(width, height));
|
||||
await windowManager.show();
|
||||
windowManager.addListener(_WindowResizeListener(prefs));
|
||||
windowManager.addListener(_WindowEventListener(prefs));
|
||||
}));
|
||||
|
||||
// Either use the _HELPER_PATH environment variable, or look relative to executable.
|
||||
|
@ -4,6 +4,7 @@ import FlutterMacOS
|
||||
@NSApplicationMain
|
||||
class AppDelegate: FlutterAppDelegate {
|
||||
override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
|
||||
return true
|
||||
// Keep app running if window closes
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user