✨ Desktop mute notification
🐛 Bug fixes on tray icon
This commit is contained in:
parent
52d6bb083e
commit
ad0ee971c1
@ -719,6 +719,7 @@
|
|||||||
"stickersNewDescription": "Create a new sticker belongs to this pack.",
|
"stickersNewDescription": "Create a new sticker belongs to this pack.",
|
||||||
"stickersPackNew": "New Sticker Pack",
|
"stickersPackNew": "New Sticker Pack",
|
||||||
"trayMenuShow": "Show",
|
"trayMenuShow": "Show",
|
||||||
|
"trayMenuMuteNotification": "Do Not Disturb",
|
||||||
"update": "Update",
|
"update": "Update",
|
||||||
"forceUpdate": "Force Update",
|
"forceUpdate": "Force Update",
|
||||||
"forceUpdateDescription": "Force to show the application update popup, even the new version is not available."
|
"forceUpdateDescription": "Force to show the application update popup, even the new version is not available."
|
||||||
|
@ -717,6 +717,7 @@
|
|||||||
"stickersNewDescription": "创建一个新的贴图。",
|
"stickersNewDescription": "创建一个新的贴图。",
|
||||||
"stickersPackNew": "新建贴图包",
|
"stickersPackNew": "新建贴图包",
|
||||||
"trayMenuShow": "显示",
|
"trayMenuShow": "显示",
|
||||||
|
"trayMenuMuteNotification": "静音通知",
|
||||||
"update": "更新",
|
"update": "更新",
|
||||||
"forceUpdate": "强制更新",
|
"forceUpdate": "强制更新",
|
||||||
"forceUpdateDescription": "强制更新应用程序,即使有更新的版本可能不可用。"
|
"forceUpdateDescription": "强制更新应用程序,即使有更新的版本可能不可用。"
|
||||||
|
@ -717,6 +717,7 @@
|
|||||||
"stickersNewDescription": "創建一個新的貼圖。",
|
"stickersNewDescription": "創建一個新的貼圖。",
|
||||||
"stickersPackNew": "新建貼圖包",
|
"stickersPackNew": "新建貼圖包",
|
||||||
"trayMenuShow": "顯示",
|
"trayMenuShow": "顯示",
|
||||||
|
"trayMenuMuteNotification": "靜音通知",
|
||||||
"update": "更新",
|
"update": "更新",
|
||||||
"forceUpdate": "強制更新",
|
"forceUpdate": "強制更新",
|
||||||
"forceUpdateDescription": "強制更新應用程序,即使有更新的版本可能不可用。"
|
"forceUpdateDescription": "強制更新應用程序,即使有更新的版本可能不可用。"
|
||||||
|
@ -717,6 +717,7 @@
|
|||||||
"stickersNewDescription": "創建一個新的貼圖。",
|
"stickersNewDescription": "創建一個新的貼圖。",
|
||||||
"stickersPackNew": "新建貼圖包",
|
"stickersPackNew": "新建貼圖包",
|
||||||
"trayMenuShow": "顯示",
|
"trayMenuShow": "顯示",
|
||||||
|
"trayMenuMuteNotification": "靜音通知",
|
||||||
"update": "更新",
|
"update": "更新",
|
||||||
"forceUpdate": "強制更新",
|
"forceUpdate": "強制更新",
|
||||||
"forceUpdateDescription": "強制更新應用程序,即使有更新的版本可能不可用。"
|
"forceUpdateDescription": "強制更新應用程序,即使有更新的版本可能不可用。"
|
||||||
|
@ -333,6 +333,31 @@ class _AppSplashScreenState extends State<_AppSplashScreen> with TrayListener {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
final Menu _appTrayMenu = Menu(
|
||||||
|
items: [
|
||||||
|
MenuItem(
|
||||||
|
key: 'version_label',
|
||||||
|
label: 'Solian',
|
||||||
|
disabled: true,
|
||||||
|
),
|
||||||
|
MenuItem.separator(),
|
||||||
|
MenuItem.checkbox(
|
||||||
|
checked: false,
|
||||||
|
key: 'mute_notification',
|
||||||
|
label: 'trayMenuMuteNotification'.tr(),
|
||||||
|
),
|
||||||
|
MenuItem.separator(),
|
||||||
|
MenuItem(
|
||||||
|
key: 'window_show',
|
||||||
|
label: 'trayMenuShow'.tr(),
|
||||||
|
),
|
||||||
|
MenuItem(
|
||||||
|
key: 'exit',
|
||||||
|
label: 'trayMenuExit'.tr(),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
);
|
||||||
|
|
||||||
Future<void> _trayInitialization() async {
|
Future<void> _trayInitialization() async {
|
||||||
if (kIsWeb || Platform.isAndroid || Platform.isIOS) return;
|
if (kIsWeb || Platform.isAndroid || Platform.isIOS) return;
|
||||||
|
|
||||||
@ -344,25 +369,13 @@ class _AppSplashScreenState extends State<_AppSplashScreen> with TrayListener {
|
|||||||
trayManager.addListener(this);
|
trayManager.addListener(this);
|
||||||
await trayManager.setIcon(icon);
|
await trayManager.setIcon(icon);
|
||||||
|
|
||||||
Menu menu = Menu(
|
_appTrayMenu.items![0] = MenuItem(
|
||||||
items: [
|
key: 'version_label',
|
||||||
MenuItem(
|
label: 'Solian ${appVersion.version}+${appVersion.buildNumber}',
|
||||||
key: 'version_label',
|
disabled: true,
|
||||||
label: 'Solian ${appVersion.version}+${appVersion.buildNumber}',
|
|
||||||
disabled: true,
|
|
||||||
),
|
|
||||||
MenuItem.separator(),
|
|
||||||
MenuItem(
|
|
||||||
key: 'window_show',
|
|
||||||
label: 'trayMenuShow'.tr(),
|
|
||||||
),
|
|
||||||
MenuItem(
|
|
||||||
key: 'exit',
|
|
||||||
label: 'trayMenuExit'.tr(),
|
|
||||||
),
|
|
||||||
],
|
|
||||||
);
|
);
|
||||||
await trayManager.setContextMenu(menu);
|
|
||||||
|
await trayManager.setContextMenu(_appTrayMenu);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _notifyInitialization() async {
|
Future<void> _notifyInitialization() async {
|
||||||
@ -424,8 +437,15 @@ class _AppSplashScreenState extends State<_AppSplashScreen> with TrayListener {
|
|||||||
@override
|
@override
|
||||||
void onTrayMenuItemClick(MenuItem menuItem) {
|
void onTrayMenuItemClick(MenuItem menuItem) {
|
||||||
switch (menuItem.key) {
|
switch (menuItem.key) {
|
||||||
|
case 'mute_notification':
|
||||||
|
final nty = context.read<NotificationProvider>();
|
||||||
|
nty.isMuted = !nty.isMuted;
|
||||||
|
_appTrayMenu.items![2].checked = nty.isMuted;
|
||||||
|
trayManager.setContextMenu(_appTrayMenu);
|
||||||
|
break;
|
||||||
case 'window_show':
|
case 'window_show':
|
||||||
appWindow.show();
|
// To prevent the window from being hide after just show on macOS
|
||||||
|
Timer(const Duration(milliseconds: 100), () => appWindow.show());
|
||||||
break;
|
break;
|
||||||
case 'exit':
|
case 'exit':
|
||||||
_appLifecycleListener?.dispose();
|
_appLifecycleListener?.dispose();
|
||||||
|
@ -79,6 +79,7 @@ class NotificationProvider extends ChangeNotifier {
|
|||||||
List<SnNotification> notifications = List.empty(growable: true);
|
List<SnNotification> notifications = List.empty(growable: true);
|
||||||
|
|
||||||
int? skippableNotifyChannel;
|
int? skippableNotifyChannel;
|
||||||
|
bool isMuted = false;
|
||||||
|
|
||||||
void listen() {
|
void listen() {
|
||||||
_ws.pk.stream.listen((event) {
|
_ws.pk.stream.listen((event) {
|
||||||
@ -107,7 +108,7 @@ class NotificationProvider extends ChangeNotifier {
|
|||||||
notifyListeners();
|
notifyListeners();
|
||||||
updateTray();
|
updateTray();
|
||||||
|
|
||||||
if (!kIsWeb) {
|
if (!kIsWeb && !isMuted) {
|
||||||
if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) {
|
if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) {
|
||||||
LocalNotification notify = LocalNotification(
|
LocalNotification notify = LocalNotification(
|
||||||
title: notification.title,
|
title: notification.title,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user