add seating plan legend, improve ui
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
from typing import Optional
|
||||
|
||||
from from_root import from_root
|
||||
from rio import Text, Column, TextStyle, Component, event, PressEvent, ProgressCircle, Row, Image, Button, Spacer
|
||||
|
||||
from src.ez_lan_manager import ConfigurationService, SeatingService, TicketingService
|
||||
from src.ez_lan_manager import ConfigurationService, SeatingService, TicketingService, UserService
|
||||
from src.ez_lan_manager.components.MainViewContentBox import MainViewContentBox
|
||||
from src.ez_lan_manager.components.SeatingPlan import SeatingPlan
|
||||
from src.ez_lan_manager.components.SeatingPlan import SeatingPlan, SeatingPlanLegend
|
||||
from src.ez_lan_manager.components.SeatingPlanInfoBox import SeatingPlanInfoBox
|
||||
from src.ez_lan_manager.pages import BasePage
|
||||
from src.ez_lan_manager.types.Seat import Seat
|
||||
from src.ez_lan_manager.types.SessionStorage import SessionStorage
|
||||
from src.ez_lan_manager.types.User import User
|
||||
|
||||
|
||||
class SeatingPlanPage(Component):
|
||||
@@ -17,11 +18,21 @@ class SeatingPlanPage(Component):
|
||||
current_seat_occupant: Optional[str] = None
|
||||
current_seat_price: int = 0
|
||||
current_seat_is_blocked: bool = False
|
||||
user: Optional[User] = None
|
||||
user_has_seat: bool = False
|
||||
|
||||
@event.on_populate
|
||||
async def on_populate(self) -> None:
|
||||
await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - Sitzplan")
|
||||
self.seating_info = await self.session[SeatingService].get_seating()
|
||||
self.user = await self.session[UserService].get_user(self.session[SessionStorage].user_id)
|
||||
user_has_seat = False
|
||||
for seat in self.seating_info:
|
||||
if not seat.user or not self.user:
|
||||
continue
|
||||
if seat.user.user_id == self.user.user_id:
|
||||
user_has_seat = True
|
||||
self.user_has_seat = user_has_seat
|
||||
|
||||
async def on_seat_clicked(self, seat_id: str, _: PressEvent) -> None:
|
||||
seat = next(filter(lambda s: s.seat_id == seat_id, self.seating_info), None)
|
||||
@@ -38,15 +49,32 @@ class SeatingPlanPage(Component):
|
||||
self.current_seat_occupant = None
|
||||
|
||||
def build(self) -> Component:
|
||||
if not self.seating_info:
|
||||
return BasePage(
|
||||
content=Column(
|
||||
MainViewContentBox(
|
||||
ProgressCircle(
|
||||
color="secondary",
|
||||
align_x=0.5,
|
||||
margin_top=2,
|
||||
margin_bottom=2
|
||||
)
|
||||
),
|
||||
align_y=0
|
||||
)
|
||||
)
|
||||
return BasePage(
|
||||
content=Column(
|
||||
MainViewContentBox(
|
||||
SeatingPlanInfoBox(seat_id=self.current_seat_id, seat_occupant=self.current_seat_occupant, seat_price=self.current_seat_price,
|
||||
is_blocked=self.current_seat_is_blocked, user_has_seat=self.user_has_seat)
|
||||
),
|
||||
MainViewContentBox(
|
||||
SeatingPlan(seat_clicked_cb=self.on_seat_clicked, seating_info=self.seating_info) if self.seating_info else
|
||||
Column(ProgressCircle(color=self.session.theme.secondary_color, margin=3), Text("Sitzplan wird geladen", style=TextStyle(fill=self.session.theme.neutral_color), align_x=0.5, margin=1))
|
||||
),
|
||||
MainViewContentBox(
|
||||
SeatingPlanInfoBox(seat_id=self.current_seat_id, seat_occupant=self.current_seat_occupant, seat_price=self.current_seat_price,
|
||||
is_blocked=self.current_seat_is_blocked)
|
||||
SeatingPlanLegend(),
|
||||
),
|
||||
align_y=0
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user