Added Expand Animations

This commit is contained in:
tr1x_em committed 2025-08-09 21:17:15 +05:30
1 parent 318e78443a
commit fbb68326f8
1 file changed
+27 -8
+27 -8
View File
@@ -1,6 +1,7 @@
from fabric.widgets.centerbox import CenterBox from fabric.widgets.centerbox import CenterBox
from loguru import logger from loguru import logger
from collections import defaultdict from collections import defaultdict
from gi.repository import GLib
from fabric.widgets.box import Box from fabric.widgets.box import Box
from fabric.widgets.button import Button from fabric.widgets.button import Button
@@ -28,11 +29,18 @@ class ExpandableNotificationGroup(Box):
self.app_name = app_name self.app_name = app_name
self.notifications = notifications self.notifications = notifications
self.is_expanded = False self.is_expanded = False # Always start collapsed
# Create collapsed state (shows only latest notification) # Create collapsed state first (shows only latest notification)
self.create_collapsed_state() self.create_collapsed_state()
# Create expanded state (hidden initially)
self.create_expanded_state()
# Ensure we start in collapsed state
self.collapsed_eventbox.set_visible(True)
self.expanded_revealer.set_reveal_child(False)
def create_collapsed_state(self): def create_collapsed_state(self):
from widgets.custom_image import CustomImage from widgets.custom_image import CustomImage
@@ -210,11 +218,9 @@ class ExpandableNotificationGroup(Box):
name="notification-group-expanded", name="notification-group-expanded",
orientation="v", orientation="v",
spacing=5, spacing=5,
visible=False,
) )
# Header with app name and controls # Header with app name and controls
# App name and show less button # App name and show less button
header_content = Box( header_content = Box(
orientation="h", orientation="h",
@@ -255,7 +261,15 @@ class ExpandableNotificationGroup(Box):
notification_widget = NotificationCenterWidget(notification=notification) notification_widget = NotificationCenterWidget(notification=notification)
self.expanded_box.add(notification_widget) self.expanded_box.add(notification_widget)
self.add(self.expanded_box) # Wrap the expanded box in a revealer for smooth slide-down animation
self.expanded_revealer = Revealer(
child=self.expanded_box,
transition_type="slide-down",
transition_duration=300,
child_revealed=False,
)
self.add(self.expanded_revealer)
def _get_notification_pixbuf(self, notification): def _get_notification_pixbuf(self, notification):
# Use the same logic as NotificationWidget # Use the same logic as NotificationWidget
@@ -289,14 +303,19 @@ class ExpandableNotificationGroup(Box):
return True return True
def expand(self, *args): def expand(self, *args):
"""Expand to show all notifications in this group with slide-down animation"""
self.is_expanded = True self.is_expanded = True
self.collapsed_eventbox.set_visible(False) self.collapsed_eventbox.set_visible(False)
self.expanded_box.set_visible(True) self.expanded_revealer.set_reveal_child(True)
logger.debug(f"Expanded notification group: {self.app_name}")
def collapse(self, *args): def collapse(self, *args):
"""Collapse to show only the summary notification with slide-up animation"""
self.is_expanded = False self.is_expanded = False
self.collapsed_eventbox.set_visible(True) self.expanded_revealer.set_reveal_child(False)
self.expanded_box.set_visible(False) # Use a timeout to hide the collapsed state after animation completes
GLib.timeout_add(310, lambda: self.collapsed_eventbox.set_visible(True))
logger.debug(f"Collapsed notification group: {self.app_name}")
def close_all(self, *args): def close_all(self, *args):
# Close all notifications in this group # Close all notifications in this group