♻️ refactor(notification): improve notification animation and limit count

This commit is contained in:
sankalp committed 2025-08-01 09:57:52 +05:45
1 parent 0b89e9852a
commit 8dd1656fc2
5 files changed
+61 -14

No files matched your search

+13 -3
View File
@@ -28,7 +28,7 @@ NOTIFICATION_IMAGE_SIZE = 48
# Improved animation smoothness and consistent behavior for rapid notifications.
def smooth_revealer_animation(revealer: SlideRevealer, duration: int = 250):
def smooth_revealer_animation(revealer: SlideRevealer, duration: int = 600):
revealer.duration = duration
@@ -207,7 +207,7 @@ class NotificationRevealer(SlideRevealer):
super().__init__(
child=self.event_box,
direction="right",
duration=250,
duration=600,
)
smooth_revealer_animation(self)
@@ -283,6 +283,7 @@ class ModusNoti(Window):
self.notifications = Box(
v_expand=True,
h_expand=True,
title="Notification Center",
style="margin: 1px 0px 1px 1px;",
orientation="v",
spacing=5,
@@ -317,8 +318,17 @@ class ModusNoti(Window):
current_children.insert(0, new_box)
self.notifications.children = current_children
# This ensures each notification's container is fully laid out before animation
if len(current_children) >= 4:
# Animate close for the oldest notification if we exceed the limit
oldest_notification = current_children[-1]
if hasattr(oldest_notification, 'notification'):
# Trigger the close animation by closing the underlying notification
# This will use the same slide animation as auto-dismiss (left-to-right)
oldest_notification.notification.close("expired")
current_children.pop()
def start_animation():
if new_box.get_parent(): # Only animate if still in the tree
new_box.reveal()
+4 -4
View File
@@ -15,7 +15,7 @@ class BluetoothIndicator(Box):
self.bluetooth = BluetoothClient()
self.bt_icon = Svg(
name="bt-icon",
size=20,
size=25,
svg_file=get_relative_path(
"../../../config/assets/icons/applets/bluetooth-clear.svg"
),
@@ -211,15 +211,15 @@ class NetworkIndicator(Box):
elif primary_device == "wired" and self.network_service.ethernet_device:
ethernet = self.network_service.ethernet_device
if ethernet.internet == "activated":
icon_file = "ethernet.svg"
icon_file = "network-wired.svg"
tooltip = "Ethernet connected"
if hasattr(ethernet, "speed") and ethernet.speed > 0:
tooltip += f" ({ethernet.speed} Mbps)"
elif ethernet.internet == "activating":
icon_file = "wifi-clear.svg"
icon_file = "network-wired.svg"
tooltip = "Ethernet connecting..."
else:
icon_file = "wifi-off-clear.svg"
icon_file = "network-wired-offline.svg"
tooltip = "Ethernet disconnected"
self.network_icon.set_from_file(