diff --git a/ezgg_website/__init__.py b/ezgg_website/__init__.py index b491338..0d7bf8d 100644 --- a/ezgg_website/__init__.py +++ b/ezgg_website/__init__.py @@ -108,6 +108,7 @@ async def on_session_start(s: rio.Session) -> None: await s.set_title("EZ GG e.V.") # Create the Rio app +database_service = services.DatabaseService() app = rio.App( name='ezgg-website', pages=[ @@ -124,7 +125,7 @@ app = rio.App( rio.Page( name="Member", page_url='member', - build=lambda: pages.Member(services.DatabaseService()), + build=lambda: pages.Member(database_service), ), rio.Page( name="Constitution", @@ -139,7 +140,7 @@ app = rio.App( rio.Page( name="Pics", page_url='pics', - build=pages.Pics, + build=lambda: pages.Pics(database_service), ), rio.Page( name="Imprint", diff --git a/ezgg_website/pages/pics.py b/ezgg_website/pages/pics.py index 5b3939c..df698d4 100644 --- a/ezgg_website/pages/pics.py +++ b/ezgg_website/pages/pics.py @@ -1,22 +1,61 @@ from __future__ import annotations +from functools import partial from typing import * # type: ignore import rio -from from_root import from_root from .page_builder import build_page -from .. import components as comps +from .. import components as comps, services class Pics(rio.Component): - def build(self) -> rio.Component: - return build_page(rio.Column( - comps.NewsPost( - header="Galerie", - article_text=""" + def __init__(self, database_service: services.database_service.DatabaseService) -> None: + super().__init__() + self._database_service = database_service + self._active_picture: Optional[rio.URL] = None - """, - date="" + def build(self) -> rio.Component: + if self._active_picture is None: + grid = rio.Grid(row_spacing=0.4, column_spacing=0.5, margin_right=1) + for i, link in enumerate(self._database_service.get_picture_paths()): + print(i, link) + grid.add( + rio.Button( + rio.Image( + link, + height=12, + width=12 + ), + shape="rectangle", + style="plain", + on_press=partial(self.on_picture_clicked, link) + ), + row=i // 3, + column=i % 3, + ) + return build_page(grid) + return rio.Overlay( + rio.Column( + rio.Button( + rio.Image( + self._active_picture, + height="grow", + width="grow" + ), + shape="rectangle", + style="plain", + height="grow", + on_press=self.exit_overlay + ), + rio.Text("Click to exit", margin_bottom=2) ) - )) + ) + + async def on_picture_clicked(self, link_to_picture: str) -> None: + self._active_picture = link_to_picture + await self.force_refresh() + + async def exit_overlay(self) -> None: + self._active_picture = None + await self.force_refresh() diff --git a/ezgg_website/services/database_service.py b/ezgg_website/services/database_service.py index b19d1a2..8e3eb08 100644 --- a/ezgg_website/services/database_service.py +++ b/ezgg_website/services/database_service.py @@ -1,3 +1,4 @@ +import rio from from_root import from_root from ezgg_website.components import MemberInfo @@ -63,3 +64,34 @@ class DatabaseService: contact_steam=None ) ] + + def get_picture_paths(self) -> list[rio.URL]: + return [ + # BK-LAN 18 + rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=c345a1b8-0c74-4d8f-8f3d-c747d04c2c12&photo_nr=1"), + rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=c345a1b8-0c74-4d8f-8f3d-c747d04c2c12&photo_nr=2"), + rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=c345a1b8-0c74-4d8f-8f3d-c747d04c2c12&photo_nr=3"), + rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=c345a1b8-0c74-4d8f-8f3d-c747d04c2c12&photo_nr=4"), + rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=c345a1b8-0c74-4d8f-8f3d-c747d04c2c12&photo_nr=5"), + rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=c345a1b8-0c74-4d8f-8f3d-c747d04c2c12&photo_nr=6"), + + # BL 46 + rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=4abbc55b-fc19-445a-9f84-b07c8d4ced12&photo_nr=1"), + rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=4abbc55b-fc19-445a-9f84-b07c8d4ced12&photo_nr=2"), + rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=4abbc55b-fc19-445a-9f84-b07c8d4ced12&photo_nr=3"), + rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=4abbc55b-fc19-445a-9f84-b07c8d4ced12&photo_nr=4"), + rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=4abbc55b-fc19-445a-9f84-b07c8d4ced12&photo_nr=5"), + rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=4abbc55b-fc19-445a-9f84-b07c8d4ced12&photo_nr=6"), + + # BL 45 + rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=d4c862f1-65cd-4051-9525-8be408ef80a8&photo_nr=1"), + rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=d4c862f1-65cd-4051-9525-8be408ef80a8&photo_nr=2"), + rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=d4c862f1-65cd-4051-9525-8be408ef80a8&photo_nr=3"), + rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=d4c862f1-65cd-4051-9525-8be408ef80a8&photo_nr=4"), + rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=d4c862f1-65cd-4051-9525-8be408ef80a8&photo_nr=5"), + rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=d4c862f1-65cd-4051-9525-8be408ef80a8&photo_nr=6"), + + # BL 42 + rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=235bf57f-c65c-4b5f-8029-061775eeec45&photo_nr=1"), + rio.URL("https://verwaltung.ezgg-ev.de/adm_program/modules/photos/photo_show.php?photo_uuid=235bf57f-c65c-4b5f-8029-061775eeec45&photo_nr=2") + ]