Skip to content

Commit

Permalink
Initial WIP implementation of notification support
Browse files Browse the repository at this point in the history
  • Loading branch information
gizmo385 committed Nov 22, 2024
1 parent 2e71c4f commit 1a5595c
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions lazy_github/ui/screens/primary.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
from typing import NamedTuple

from httpx import HTTPError
from textual import work
from textual import notifications, work
from textual.app import ComposeResult
from textual.command import Hit, Hits, Provider
from textual.containers import Container
from textual.containers import Container, Horizontal
from textual.reactive import reactive
from textual.screen import Screen
from textual.types import IgnoreReturnCallbackType
Expand Down Expand Up @@ -51,17 +51,44 @@ def render(self):
return "No repository selected"


class UnreadNotifications(Widget):
notification_count: reactive[int | None] = reactive(None)

def render(self):
if self.notification_count is None:
return ""
else:
count = f"{self.notification_count}+" if self.notification_count >= 30 else str(self.notification_count)
return f"[red]• Unread Notifications: {count}[/red]"


class LazyGithubStatusSummary(Container):
DEFAULT_CSS = """
LazyGithubStatusSummary {
max-height: 3;
width: 100%;
max-width: 100%;
layout: horizontal;
border: solid $secondary;
}
CurrentlySelectedRepo {
max-width: 50%;
height: 100%;
content-align: left middle;
}
UnreadNotifications {
height: 100%;
max-width: 50%;
content-align: right middle;
}
"""

def compose(self):
yield CurrentlySelectedRepo(id="currently_selected_repo")
with Horizontal():
yield CurrentlySelectedRepo(id="currently_selected_repo")
yield UnreadNotifications(id="unread_notifications")


class SelectionDetailsContainer(LazyGithubContainer):
Expand Down

0 comments on commit 1a5595c

Please sign in to comment.