Better Expantion
This commit is contained in:
1 parent
fbb68326f8
commit
236b7ac992
1 file changed
+37
-16
@@ -39,7 +39,7 @@ class ExpandableNotificationGroup(Box):
|
|||||||
|
|
||||||
# Ensure we start in collapsed state
|
# Ensure we start in collapsed state
|
||||||
self.collapsed_eventbox.set_visible(True)
|
self.collapsed_eventbox.set_visible(True)
|
||||||
self.expanded_revealer.set_reveal_child(False)
|
self.expanded_container.set_visible(False)
|
||||||
|
|
||||||
def create_collapsed_state(self):
|
def create_collapsed_state(self):
|
||||||
from widgets.custom_image import CustomImage
|
from widgets.custom_image import CustomImage
|
||||||
@@ -214,15 +214,15 @@ class ExpandableNotificationGroup(Box):
|
|||||||
self.create_expanded_state()
|
self.create_expanded_state()
|
||||||
|
|
||||||
def create_expanded_state(self):
|
def create_expanded_state(self):
|
||||||
self.expanded_box = Box(
|
# Create main expanded container
|
||||||
name="notification-group-expanded",
|
self.expanded_container = Box(
|
||||||
|
name="notification-group-expanded-container",
|
||||||
orientation="v",
|
orientation="v",
|
||||||
spacing=5,
|
spacing=0,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Header with app name and controls
|
# Header with app name and controls (this won't animate)
|
||||||
# App name and show less button
|
self.header_content = Box(
|
||||||
header_content = Box(
|
|
||||||
orientation="h",
|
orientation="h",
|
||||||
h_expand=True,
|
h_expand=True,
|
||||||
children=[
|
children=[
|
||||||
@@ -254,22 +254,35 @@ class ExpandableNotificationGroup(Box):
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|
||||||
self.expanded_box.add(header_content)
|
# Box for individual notifications (this will animate)
|
||||||
|
self.notifications_list = Box(
|
||||||
|
name="notification-group-notifications",
|
||||||
|
orientation="v",
|
||||||
|
spacing=5,
|
||||||
|
)
|
||||||
|
|
||||||
# Individual notifications
|
# Add individual notifications to the list
|
||||||
for notification in self.notifications:
|
for notification in self.notifications:
|
||||||
notification_widget = NotificationCenterWidget(notification=notification)
|
notification_widget = NotificationCenterWidget(notification=notification)
|
||||||
self.expanded_box.add(notification_widget)
|
self.notifications_list.add(notification_widget)
|
||||||
|
|
||||||
# Wrap the expanded box in a revealer for smooth slide-down animation
|
# Wrap only the notifications list in a revealer for animation
|
||||||
self.expanded_revealer = Revealer(
|
self.expanded_revealer = Revealer(
|
||||||
child=self.expanded_box,
|
child=self.notifications_list,
|
||||||
transition_type="slide-down",
|
transition_type="slide-down",
|
||||||
transition_duration=300,
|
transition_duration=300,
|
||||||
child_revealed=False,
|
child_revealed=False,
|
||||||
)
|
)
|
||||||
|
|
||||||
self.add(self.expanded_revealer)
|
# Add header (static) and revealer (animated) to container
|
||||||
|
self.expanded_container.add(self.header_content)
|
||||||
|
self.expanded_container.add(self.expanded_revealer)
|
||||||
|
|
||||||
|
# Add the container to the main group
|
||||||
|
self.add(self.expanded_container)
|
||||||
|
|
||||||
|
# Hide the entire expanded container initially
|
||||||
|
self.expanded_container.set_visible(False)
|
||||||
|
|
||||||
def _get_notification_pixbuf(self, notification):
|
def _get_notification_pixbuf(self, notification):
|
||||||
# Use the same logic as NotificationWidget
|
# Use the same logic as NotificationWidget
|
||||||
@@ -306,16 +319,24 @@ class ExpandableNotificationGroup(Box):
|
|||||||
"""Expand to show all notifications in this group with slide-down animation"""
|
"""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_revealer.set_reveal_child(True)
|
self.expanded_container.set_visible(True)
|
||||||
|
# Small delay to ensure container is visible before starting animation
|
||||||
|
GLib.timeout_add(10, lambda: self.expanded_revealer.set_reveal_child(True))
|
||||||
logger.debug(f"Expanded notification group: {self.app_name}")
|
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"""
|
"""Collapse to show only the summary notification with slide-up animation"""
|
||||||
self.is_expanded = False
|
self.is_expanded = False
|
||||||
self.expanded_revealer.set_reveal_child(False)
|
self.expanded_revealer.set_reveal_child(False)
|
||||||
# Use a timeout to hide the collapsed state after animation completes
|
# Hide the expanded container after animation completes and show collapsed state
|
||||||
GLib.timeout_add(310, lambda: self.collapsed_eventbox.set_visible(True))
|
GLib.timeout_add(310, self._complete_collapse)
|
||||||
logger.debug(f"Collapsed notification group: {self.app_name}")
|
logger.debug(f"Collapsed notification group: {self.app_name}")
|
||||||
|
|
||||||
|
def _complete_collapse(self):
|
||||||
|
"""Complete the collapse animation by hiding expanded container and showing collapsed"""
|
||||||
|
self.expanded_container.set_visible(False)
|
||||||
|
self.collapsed_eventbox.set_visible(True)
|
||||||
|
return False # Don't repeat timeout
|
||||||
|
|
||||||
def close_all(self, *args):
|
def close_all(self, *args):
|
||||||
# Close all notifications in this group
|
# Close all notifications in this group
|
||||||
|
|||||||
Reference in new issue
Block a user