From 8dfd60df1969d03498371af62682b861d5920d0a Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Sat, 30 Mar 2024 19:02:05 +0530 Subject: [PATCH 1/3] fix: close app on exit and add option to hide window --- auth/lib/app/view/app.dart | 21 ++++++++++----------- auth/lib/main.dart | 4 ++++ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/auth/lib/app/view/app.dart b/auth/lib/app/view/app.dart index 8ec9a6426..3bd9d4e73 100644 --- a/auth/lib/app/view/app.dart +++ b/auth/lib/app/view/app.dart @@ -46,7 +46,6 @@ class _AppState extends State with WindowListener, TrayListener { Future initWindowManager() async { windowManager.addListener(this); - await windowManager.setPreventClose(true); } Future initTrayManager() async { @@ -154,11 +153,6 @@ class _AppState extends State with WindowListener, TrayListener { }; } - @override - void onWindowClose() async { - await windowManager.hide(); - } - @override void onWindowResize() { WindowListenerService.instance.onWindowResize().ignore(); @@ -187,11 +181,16 @@ class _AppState extends State with WindowListener, TrayListener { @override void onTrayMenuItemClick(MenuItem menuItem) { - if (menuItem.key == 'show_window') { - windowManager.show(); - } else if (menuItem.key == 'exit_app') { - windowManager.setPreventClose(false); - windowManager.close(); + switch (menuItem.key) { + case 'hide_window': + windowManager.hide(); + break; + case 'show_window': + windowManager.show(); + break; + case 'exit_app': + windowManager.close(); + break; } } } diff --git a/auth/lib/main.dart b/auth/lib/main.dart index f475a5598..09b85d8b3 100644 --- a/auth/lib/main.dart +++ b/auth/lib/main.dart @@ -43,6 +43,10 @@ Future initSystemTray() async { await trayManager.setIcon(path); Menu menu = Menu( items: [ + MenuItem( + key: 'hide_window', + label: 'Hide Window', + ), MenuItem( key: 'show_window', label: 'Show Window', From 204d4d048e84e8b0f79f0d6055cecfe327eba13a Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Sat, 30 Mar 2024 19:10:01 +0530 Subject: [PATCH 2/3] chore: update podfile --- auth/macos/Podfile.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/auth/macos/Podfile.lock b/auth/macos/Podfile.lock index 641289552..a5b6eb77c 100644 --- a/auth/macos/Podfile.lock +++ b/auth/macos/Podfile.lock @@ -63,7 +63,7 @@ PODS: - sqlite3/fts5 - sqlite3/perf-threadsafe - sqlite3/rtree - - system_tray (0.0.1): + - tray_manager (0.0.1): - FlutterMacOS - url_launcher_macos (0.0.1): - FlutterMacOS @@ -91,7 +91,7 @@ DEPENDENCIES: - sodium_libs (from `Flutter/ephemeral/.symlinks/plugins/sodium_libs/macos`) - sqflite (from `Flutter/ephemeral/.symlinks/plugins/sqflite/darwin`) - sqlite3_flutter_libs (from `Flutter/ephemeral/.symlinks/plugins/sqlite3_flutter_libs/macos`) - - system_tray (from `Flutter/ephemeral/.symlinks/plugins/system_tray/macos`) + - tray_manager (from `Flutter/ephemeral/.symlinks/plugins/tray_manager/macos`) - url_launcher_macos (from `Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos`) - window_manager (from `Flutter/ephemeral/.symlinks/plugins/window_manager/macos`) @@ -144,8 +144,8 @@ EXTERNAL SOURCES: :path: Flutter/ephemeral/.symlinks/plugins/sqflite/darwin sqlite3_flutter_libs: :path: Flutter/ephemeral/.symlinks/plugins/sqlite3_flutter_libs/macos - system_tray: - :path: Flutter/ephemeral/.symlinks/plugins/system_tray/macos + tray_manager: + :path: Flutter/ephemeral/.symlinks/plugins/tray_manager/macos url_launcher_macos: :path: Flutter/ephemeral/.symlinks/plugins/url_launcher_macos/macos window_manager: @@ -177,7 +177,7 @@ SPEC CHECKSUMS: sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec sqlite3: 73b7fc691fdc43277614250e04d183740cb15078 sqlite3_flutter_libs: 06a05802529659a272beac4ee1350bfec294f386 - system_tray: e53c972838c69589ff2e77d6d3abfd71332f9e5d + tray_manager: 9064e219c56d75c476e46b9a21182087930baf90 url_launcher_macos: d2691c7dd33ed713bf3544850a623080ec693d95 window_manager: 3a1844359a6295ab1e47659b1a777e36773cd6e8 From 1391cff1f1d689e47a65c6e1272a6534409340ad Mon Sep 17 00:00:00 2001 From: Prateek Sunal Date: Sat, 30 Mar 2024 19:13:30 +0530 Subject: [PATCH 3/3] fix: translate labels of context menu --- auth/lib/ui/code_widget.dart | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/auth/lib/ui/code_widget.dart b/auth/lib/ui/code_widget.dart index c579def12..f97e865ec 100644 --- a/auth/lib/ui/code_widget.dart +++ b/auth/lib/ui/code_widget.dart @@ -98,13 +98,13 @@ class _CodeWidgetState extends State { onSelected: () => _onShowQrPressed(null), ), MenuItem( - label: 'Edit', + label: l10n.edit, icon: Icons.edit, onSelected: () => _onEditPressed(null), ), const MenuDivider(), MenuItem( - label: 'Delete', + label: l10n.delete, value: "Delete", icon: Icons.delete, onSelected: () => _onDeletePressed(null),