💄 Clear tray number when click from it
This commit is contained in:
parent
3f82c06ff8
commit
11627e2455
@ -369,6 +369,7 @@ class _AppSplashScreenState extends State<_AppSplashScreen> with TrayListener {
|
||||
@override
|
||||
void onTrayIconMouseDown() {
|
||||
if (Platform.isWindows) {
|
||||
context.read<NotificationProvider>().clearTray();
|
||||
appWindow.show();
|
||||
} else {
|
||||
trayManager.popUpContextMenu();
|
||||
@ -380,6 +381,7 @@ class _AppSplashScreenState extends State<_AppSplashScreen> with TrayListener {
|
||||
if (Platform.isWindows) {
|
||||
trayManager.popUpContextMenu();
|
||||
} else {
|
||||
context.read<NotificationProvider>().clearTray();
|
||||
appWindow.show();
|
||||
}
|
||||
}
|
||||
|
@ -73,6 +73,7 @@ class NotificationProvider extends ChangeNotifier {
|
||||
}
|
||||
|
||||
int showingCount = 0;
|
||||
int showingTrayCount = 0;
|
||||
List<SnNotification> notifications = List.empty(growable: true);
|
||||
|
||||
void listen() {
|
||||
@ -81,6 +82,7 @@ class NotificationProvider extends ChangeNotifier {
|
||||
final notification = SnNotification.fromJson(event.payload!);
|
||||
if (showingCount < 0) showingCount = 0;
|
||||
showingCount++;
|
||||
showingTrayCount++;
|
||||
notifications.add(notification);
|
||||
Future.delayed(const Duration(seconds: 3), () {
|
||||
if (showingCount >= 0) showingCount--;
|
||||
@ -94,6 +96,11 @@ class NotificationProvider extends ChangeNotifier {
|
||||
});
|
||||
}
|
||||
|
||||
void clearTray() {
|
||||
showingTrayCount = 0;
|
||||
updateTray();
|
||||
}
|
||||
|
||||
void updateTray() {
|
||||
if (kIsWeb || Platform.isAndroid || Platform.isIOS) return;
|
||||
if (notifications.isEmpty) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user