working email headers display

This commit is contained in:
Tim Bendt
2025-05-01 12:31:10 -04:00
parent 1f75a03553
commit 0c756b55e9
4 changed files with 18 additions and 5 deletions

View File

@@ -56,6 +56,7 @@ class EmailViewerApp(App):
CSS_PATH = "email_viewer.tcss" CSS_PATH = "email_viewer.tcss"
folder = reactive("INBOX") folder = reactive("INBOX")
markdown: Reactive[str] = reactive("Loading...") markdown: Reactive[str] = reactive("Loading...")
header_expanded = False
def get_system_commands(self, screen: Screen) -> Iterable[SystemCommand]: def get_system_commands(self, screen: Screen) -> Iterable[SystemCommand]:
yield from super().get_system_commands(screen) yield from super().get_system_commands(screen)
@@ -75,6 +76,7 @@ class EmailViewerApp(App):
Binding("e", "archive", "Archive message"), Binding("e", "archive", "Archive message"),
Binding("o", "open", "Open message", show=False), Binding("o", "open", "Open message", show=False),
Binding("q", "quit", "Quit application"), Binding("q", "quit", "Quit application"),
Binding("h", "toggle_header", "Toggle Envelope Header"),
Binding("t", "create_task", "Create Task") Binding("t", "create_task", "Create Task")
] ]
@@ -162,6 +164,13 @@ class EmailViewerApp(App):
"""Display a status message using the built-in notify function.""" """Display a status message using the built-in notify function."""
self.notify(message, title="Status", severity=severity, timeout=1, markup=True) self.notify(message, title="Status", severity=severity, timeout=1, markup=True)
def action_toggle_header(self) -> None:
"""Toggle the visibility of the EnvelopeHeader panel."""
header = self.query_one(EnvelopeHeader)
header.styles.height = "1" if self.header_expanded else "auto"
self.header_expanded = not self.header_expanded
def action_next(self) -> None: def action_next(self) -> None:
action_next(self) action_next(self)

View File

@@ -24,10 +24,11 @@ StatusTitle {
EnvelopeHeader { EnvelopeHeader {
width: 100%; width: 100%;
height: auto; height: 1;
background: $panel; background: $panel;
} }
#main_content { #main_content {
padding: 1 2; padding: 1 2;
} }

View File

@@ -8,16 +8,19 @@ class EnvelopeHeader(Static):
from_ = Reactive("") from_ = Reactive("")
to = Reactive("") to = Reactive("")
date = Reactive("") date = Reactive("")
cc = Reactive("")
bcc = Reactive("")
"""Header for the email viewer.""" """Header for the email viewer."""
def on_mount(self) -> None: def on_mount(self) -> None:
"""Mount the header.""" """Mount the header."""
def render(self) -> RenderResult: def render(self) -> RenderResult:
return f"[b][dim]Subject:[/dim] {self.subject}[/] \r\n" \ return f"[b]{self.subject}[/b] [dim]({self.date})[/] \r\n" \
f"[dim]From:[/dim] {self.from_} \r\n" \ f"[dim]From:[/dim] {self.from_} [dim]To:[/dim] {self.to} \r\n" \
f"[dim]To:[/dim] {self.to} \r\n" \ f"[dim]Date:[/dim] {self.date} \r\n" \
f"[dim]Date:[/dim] {self.date}" f"[dim]CC:[/dim] {self.cc} \r\n" \
f"[dim]BCC:[/dim] {self.bcc} \r\n" \