add placeholder pages, cleanup imports and set window titles dynamically

This commit is contained in:
David Rodenkirchen 2024-08-24 09:13:32 +02:00
parent 446956f721
commit f2dfaa78f3
5 changed files with 104 additions and 18 deletions

View File

@ -1,10 +1,8 @@
from __future__ import annotations
import logging
from pathlib import Path
from typing import * # type: ignore
import rio
from rio import App, Theme, Color, Font, Page
from from_root import from_root
from src.ez_lan_manager import pages, init_services
@ -12,32 +10,90 @@ from src.ez_lan_manager import pages, init_services
logger = logging.getLogger(__name__.split(".")[-1])
if __name__ == "__main__":
theme = rio.Theme.from_colors(
primary_color=rio.Color.from_hex("ffffff"),
secondary_color=rio.Color.from_hex("018786"),
neutral_color=rio.Color.from_hex("1e1e1e"),
background_color=rio.Color.from_hex("121212"),
hud_color=rio.Color.from_hex("02dac5"),
text_color=rio.Color.from_hex("018786"),
theme = Theme.from_colors(
primary_color=Color.from_hex("ffffff"),
secondary_color=Color.from_hex("018786"),
neutral_color=Color.from_hex("1e1e1e"),
background_color=Color.from_hex("121212"),
hud_color=Color.from_hex("02dac5"),
text_color=Color.from_hex("018786"),
mode="dark",
corner_radius_small=0,
corner_radius_medium=0,
corner_radius_large=0,
font=rio.Font(from_root("src/ez_lan_manager/assets/fonts/joystix.otf"))
font=Font(from_root("src/ez_lan_manager/assets/fonts/joystix.otf"))
)
app = rio.App(
name='',
services = init_services()
app = App(
name="EZ LAN Manager",
pages=[
rio.Page(
Page(
name="News",
page_url='',
page_url="",
build=pages.NewsPage,
),
Page(
name="News",
page_url="news",
build=pages.NewsPage,
),
Page(
name="Overview",
page_url="overview",
build=lambda: pages.PlaceholderPage(placeholder_name="LAN Übersicht"),
),
Page(
name="BuyTicket",
page_url="buy_ticket",
build=lambda: pages.PlaceholderPage(placeholder_name="Tickets kaufen"),
),
Page(
name="SeatingPlan",
page_url="seating",
build=lambda: pages.PlaceholderPage(placeholder_name="Sitzplan"),
),
Page(
name="Catering",
page_url="catering",
build=lambda: pages.PlaceholderPage(placeholder_name="Catering"),
),
Page(
name="Guests",
page_url="guests",
build=lambda: pages.PlaceholderPage(placeholder_name="Teilnehmer"),
),
Page(
name="Tournaments",
page_url="tournaments",
build=lambda: pages.PlaceholderPage(placeholder_name="Turniere"),
),
Page(
name="FAQ",
page_url="faq",
build=lambda: pages.PlaceholderPage(placeholder_name="FAQ"),
),
Page(
name="RulesGTC",
page_url="rules-gtc",
build=lambda: pages.PlaceholderPage(placeholder_name="Regeln & AGB"),
),
Page(
name="Contact",
page_url="contact",
build=lambda: pages.PlaceholderPage(placeholder_name="Kontakt"),
),
Page(
name="Imprint",
page_url="imprint",
build=lambda: pages.PlaceholderPage(placeholder_name="Impressum & DSGVO"),
)
],
theme=theme,
assets_dir=Path(__file__).parent / "assets",
default_attachments=init_services()
default_attachments=services,
on_session_start= lambda s: s.set_title(services[2].get_lan_info().name)
)
app.run_as_web_server()

View File

@ -44,7 +44,7 @@ class DesktopNavigation(Component):
DesktopNavigationButton("Teilnehmer", "./guests"),
DesktopNavigationButton("Turniere", "./tournaments"),
DesktopNavigationButton("FAQ", "./faq"),
DesktopNavigationButton("Regeln & AGB", "./rules-and-agb"),
DesktopNavigationButton("Regeln & AGB", "./rules-gtc"),
Spacer(min_height=1),
DesktopNavigationButton("Die EZ GG e.V.", "https://ezgg-ev.de/about", open_new_tab=True),
DesktopNavigationButton("Kontakt", "./contact"),

View File

@ -1,9 +1,14 @@
from rio import Text, Column, Rectangle, TextStyle, Component
from rio import Text, Column, Rectangle, TextStyle, Component, event
from src.ez_lan_manager import ConfigurationService
from src.ez_lan_manager.components.NewsPost import NewsPost
from src.ez_lan_manager.pages import BasePage
class NewsPage(Component):
@event.on_populate
async def on_populate(self) -> None:
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - Neuigkeiten")
def build(self) -> Component:
return BasePage(
content=Column(

View File

@ -0,0 +1,24 @@
from rio import Column, Component, event
from src.ez_lan_manager import ConfigurationService
from src.ez_lan_manager.components.NewsPost import NewsPost
from src.ez_lan_manager.pages import BasePage
class PlaceholderPage(Component):
placeholder_name: str
@event.on_populate
async def on_populate(self) -> None:
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - {self.placeholder_name}")
def build(self) -> Component:
return BasePage(
content=Column(
NewsPost(
title="Platzhalter",
text=f"Dies ist die Platzhalterseite für {self.placeholder_name}.",
date="99.99.9999"
),
align_y=0,
)
)

View File

@ -1,2 +1,3 @@
from .BasePage import BasePage
from .NewsPage import NewsPage
from .PlaceholderPage import PlaceholderPage