Reorganize project structure
This commit is contained in:
4
checkaddy_app/screens/__init__.py
Normal file
4
checkaddy_app/screens/__init__.py
Normal file
@@ -0,0 +1,4 @@
|
||||
from .github_repo import GithubRepositoryScreen
|
||||
from .help import HelpScreen
|
||||
|
||||
__all__ = ["HelpScreen", "GithubRepositoryScreen"]
|
||||
40
checkaddy_app/screens/github_repo.py
Normal file
40
checkaddy_app/screens/github_repo.py
Normal file
@@ -0,0 +1,40 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Optional
|
||||
|
||||
from textual import on
|
||||
from textual.app import ComposeResult
|
||||
from textual.containers import Container, Horizontal
|
||||
from textual.screen import ModalScreen
|
||||
from textual.widgets import Button, Static
|
||||
|
||||
|
||||
class GithubRepositoryScreen(ModalScreen[Optional[str]]):
|
||||
def __init__(self, repository_url: str) -> None:
|
||||
super().__init__()
|
||||
self.repository_url = repository_url
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
with Container(id="github-dialog"):
|
||||
yield Static("Open Github repository", id="github-title")
|
||||
yield Static("Choose what to do with the repository URL:", id="github-body")
|
||||
yield Static(self.repository_url, id="github-url")
|
||||
with Horizontal(id="github-buttons"):
|
||||
yield Button("Open in browser", id="github-open", variant="primary")
|
||||
yield Button("Copy to clipboard", id="github-copy")
|
||||
yield Button("Cancel", id="github-cancel")
|
||||
|
||||
def on_mount(self) -> None:
|
||||
self.query_one("#github-open", Button).focus()
|
||||
|
||||
@on(Button.Pressed, "#github-open")
|
||||
def handle_open(self) -> None:
|
||||
self.dismiss("open")
|
||||
|
||||
@on(Button.Pressed, "#github-copy")
|
||||
def handle_copy(self) -> None:
|
||||
self.dismiss("copy")
|
||||
|
||||
@on(Button.Pressed, "#github-cancel")
|
||||
def handle_cancel(self) -> None:
|
||||
self.dismiss(None)
|
||||
37
checkaddy_app/screens/help.py
Normal file
37
checkaddy_app/screens/help.py
Normal file
@@ -0,0 +1,37 @@
|
||||
from __future__ import annotations
|
||||
|
||||
from textual import on
|
||||
from textual.app import ComposeResult
|
||||
from textual.containers import Container
|
||||
from textual.screen import ModalScreen
|
||||
from textual.widgets import Button, Static
|
||||
|
||||
|
||||
class HelpScreen(ModalScreen[None]):
|
||||
def compose(self) -> ComposeResult:
|
||||
with Container(id="help-dialog"):
|
||||
yield Static("Keyboard shortcuts", id="help-title")
|
||||
yield Static(
|
||||
"Enter runs validation and lookup\n"
|
||||
"Tab / Shift+Tab moves focus through controls\n"
|
||||
"Ctrl+L clears the form\n"
|
||||
"Ctrl+J toggles the JSON panel\n"
|
||||
"Ctrl+O opens explorer for current result\n"
|
||||
"Ctrl+G opens repository actions\n"
|
||||
"Ctrl+1/2/3 focuses network/address/lookup\n"
|
||||
"Alt+B / Alt+T selects previous / next network\n"
|
||||
"Ctrl+Left / Ctrl+Right also cycles network\n"
|
||||
"Ctrl+P opens command palette\n"
|
||||
"F1 opens help\n"
|
||||
"Q or Ctrl+C exits\n\n"
|
||||
"Only public addresses are supported. Never paste private keys or seed phrases.",
|
||||
id="help-body",
|
||||
)
|
||||
yield Button("Close", id="help-close", variant="primary")
|
||||
|
||||
def on_mount(self) -> None:
|
||||
self.query_one("#help-close", Button).focus()
|
||||
|
||||
@on(Button.Pressed, "#help-close")
|
||||
def handle_close(self) -> None:
|
||||
self.dismiss(None)
|
||||
Reference in New Issue
Block a user