Add navigation to system tray

This commit is contained in:
problematicconsumer
2023-11-15 18:48:48 +03:30
parent 129a522b24
commit 7820486e1a
5 changed files with 31 additions and 3 deletions

View File

@@ -241,6 +241,7 @@
"tray": {
"dashboard": "Dashboard",
"quit": "Quit",
"open": "Open",
"status": {
"connect": "Connect",
"connecting": "Connecting",

View File

@@ -246,7 +246,8 @@
"connecting": "در حال اتصال",
"disconnect": "قطع اتصال",
"disconnecting": "در حال قطع اتصال"
}
},
"open": "باز کن"
},
"failure": {
"unexpected": "خطای غیرمنتظره",

View File

@@ -246,7 +246,8 @@
"connecting": "Подключение",
"disconnect": "Отключено",
"disconnecting": "Отключение"
}
},
"open": "Открыть"
},
"failure": {
"unexpected": "Непредвиденная ошибка",

View File

@@ -246,7 +246,8 @@
"connecting": "正在连接",
"disconnect": "已断开连接",
"disconnecting": "正在断开连接"
}
},
"open": "打开"
},
"failure": {
"unexpected": "意外错误",

View File

@@ -1,6 +1,7 @@
import 'dart:io';
import 'package:hiddify/core/core_providers.dart';
import 'package:hiddify/core/router/router.dart';
import 'package:hiddify/data/repository/config_options_store.dart';
import 'package:hiddify/domain/connectivity/connectivity.dart';
import 'package:hiddify/domain/constants.dart';
@@ -37,6 +38,13 @@ class SystemTrayController extends _$SystemTrayController
final serviceMode = ref.watch(serviceModeStoreProvider);
final t = ref.watch(translationsProvider);
final destinations = <(String label, String location)>[
(t.home.pageTitle, const HomeRoute().location),
(t.proxies.pageTitle, const ProxiesRoute().location),
(t.logs.pageTitle, const LogsRoute().location),
(t.settings.pageTitle, const SettingsRoute().location),
(t.about.pageTitle, const AboutRoute().location),
];
loggy.debug('updating system tray');
@@ -79,6 +87,22 @@ class SystemTrayController extends _$SystemTrayController
],
),
),
MenuItem.submenu(
label: t.tray.open,
submenu: Menu(
items: [
...destinations.map(
(e) => MenuItem(
label: e.$1,
onClick: (_) async {
await ref.read(windowControllerProvider.notifier).show();
ref.read(routerProvider).go(e.$2);
},
),
),
],
),
),
MenuItem.separator(),
MenuItem(
label: t.tray.quit,