working email headers display
This commit is contained in:
@@ -56,6 +56,7 @@ class EmailViewerApp(App):
|
||||
CSS_PATH = "email_viewer.tcss"
|
||||
folder = reactive("INBOX")
|
||||
markdown: Reactive[str] = reactive("Loading...")
|
||||
header_expanded = False
|
||||
|
||||
def get_system_commands(self, screen: Screen) -> Iterable[SystemCommand]:
|
||||
yield from super().get_system_commands(screen)
|
||||
@@ -75,6 +76,7 @@ class EmailViewerApp(App):
|
||||
Binding("e", "archive", "Archive message"),
|
||||
Binding("o", "open", "Open message", show=False),
|
||||
Binding("q", "quit", "Quit application"),
|
||||
Binding("h", "toggle_header", "Toggle Envelope Header"),
|
||||
Binding("t", "create_task", "Create Task")
|
||||
]
|
||||
|
||||
@@ -162,6 +164,13 @@ class EmailViewerApp(App):
|
||||
"""Display a status message using the built-in notify function."""
|
||||
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:
|
||||
action_next(self)
|
||||
|
||||
|
||||
@@ -24,10 +24,11 @@ StatusTitle {
|
||||
|
||||
EnvelopeHeader {
|
||||
width: 100%;
|
||||
height: auto;
|
||||
height: 1;
|
||||
background: $panel;
|
||||
}
|
||||
|
||||
#main_content {
|
||||
padding: 1 2;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,16 +8,19 @@ class EnvelopeHeader(Static):
|
||||
from_ = Reactive("")
|
||||
to = Reactive("")
|
||||
date = Reactive("")
|
||||
cc = Reactive("")
|
||||
bcc = Reactive("")
|
||||
|
||||
"""Header for the email viewer."""
|
||||
def on_mount(self) -> None:
|
||||
"""Mount the header."""
|
||||
|
||||
def render(self) -> RenderResult:
|
||||
return f"[b][dim]Subject:[/dim] {self.subject}[/] \r\n" \
|
||||
f"[dim]From:[/dim] {self.from_} \r\n" \
|
||||
f"[dim]To:[/dim] {self.to} \r\n" \
|
||||
f"[dim]Date:[/dim] {self.date}"
|
||||
return f"[b]{self.subject}[/b] [dim]({self.date})[/] \r\n" \
|
||||
f"[dim]From:[/dim] {self.from_} [dim]To:[/dim] {self.to} \r\n" \
|
||||
f"[dim]Date:[/dim] {self.date} \r\n" \
|
||||
f"[dim]CC:[/dim] {self.cc} \r\n" \
|
||||
f"[dim]BCC:[/dim] {self.bcc} \r\n" \
|
||||
|
||||
|
||||
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user