building out ui, still not done
This commit is contained in:
@@ -4,6 +4,8 @@ from textual.widgets import Input, Select, LoadingIndicator, Static
|
||||
from textual.containers import HorizontalGroup, ScrollableContainer
|
||||
from textual.app import ComposeResult
|
||||
|
||||
from screens.repo_view_screen import RepoViewScreen
|
||||
|
||||
from human_readable import time_delta
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
@@ -38,9 +40,11 @@ class SearchResult(HorizontalGroup):
|
||||
self.is_fork = repo_data["fork"]
|
||||
self.updated_at = datetime.fromisoformat(repo_data["updated_at"]).replace(tzinfo=None)
|
||||
|
||||
|
||||
|
||||
def compose(self) -> ComposeResult:
|
||||
updated_string = time_delta(datetime.now() - self.updated_at)
|
||||
yield Static(f"[@click='view_user({self.author["id"]})']{self.author["login"]}[/] / [@click=view_repo('')]{self.repo_name}[/]{' [d]\[[cyan]fork[/]]' if self.is_fork else ''}\n{self.description}\n[d]Updated {updated_string} ago")
|
||||
yield Static(f"[@click='view_user({self.author["id"]})']{self.author["login"]}[/] / [@click='screen.view_repo(\"{self.author["login"]}\",\"{self.repo_name}\")']{self.repo_name}[/]{' [d]\[[cyan]fork[/]]' if self.is_fork else ''}\n{self.description}\n[d]Updated {updated_string} ago")
|
||||
|
||||
class SearchScreen(Screen):
|
||||
DEFAULT_CSS = """
|
||||
@@ -58,6 +62,9 @@ class SearchScreen(Screen):
|
||||
}
|
||||
}
|
||||
"""
|
||||
|
||||
def action_view_repo(self, author: str, repo_name: str):
|
||||
self.app.switch_screen(RepoViewScreen(author, repo_name))
|
||||
|
||||
def action_search_query(self):
|
||||
query_input = self.query_one("#query")
|
||||
|
||||
Reference in New Issue
Block a user