refactor: use ui.py and remove unused imports
This commit is contained in:
@@ -6,9 +6,7 @@ from typing import TYPE_CHECKING
|
||||
|
||||
from textual import work
|
||||
from textual.app import App, ComposeResult
|
||||
from textual.containers import Container, Horizontal, ScrollableContainer
|
||||
from textual.events import Key
|
||||
from textual.screen import ModalScreen
|
||||
from textual.widgets import DataTable, Footer, Header, ProgressBar, Static
|
||||
from textual.worker import get_current_worker
|
||||
|
||||
@@ -22,38 +20,12 @@ from .table_utils import (
|
||||
filter_unfinished_items,
|
||||
format_item_as_row,
|
||||
)
|
||||
from .ui import HelpScreen
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from textual.widgets._data_table import ColumnKey
|
||||
|
||||
|
||||
class HelpScreen(ModalScreen):
|
||||
"""Help screen displaying all available keybindings."""
|
||||
|
||||
BINDINGS = [("escape", "dismiss", "Close"), ("?", "dismiss", "Close")]
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
with Container(id="help_container"):
|
||||
yield Static("Key Bindings", id="help_title")
|
||||
with ScrollableContainer(id="help_content"):
|
||||
bindings = self.app.BINDINGS
|
||||
for binding in bindings:
|
||||
if isinstance(binding, tuple):
|
||||
key, action, description = binding
|
||||
else:
|
||||
key = binding.key
|
||||
description = binding.description
|
||||
key_display = key.replace(
|
||||
"ctrl+", "^").replace("left", "←").replace("right", "→").replace("space", "Space").replace("enter", "Enter")
|
||||
with Horizontal(classes="help_row"):
|
||||
yield Static(f"[bold #f9e2af]{key_display}[/]", classes="help_key")
|
||||
yield Static(description, classes="help_action")
|
||||
yield Static("Press [bold #f9e2af]?[/] or [bold #f9e2af]Escape[/] to close", id="help_footer")
|
||||
|
||||
def action_dismiss(self) -> None:
|
||||
self.dismiss()
|
||||
|
||||
|
||||
class Auditui(App):
|
||||
"""Main application class for the Audible TUI app."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user