Co-authored-by: David Rodenkirchen <drodenkirchen@linetco.com> Reviewed-on: Vereins-IT/ez-lan-manager#1
47 lines
2.0 KiB
Python
47 lines
2.0 KiB
Python
from typing import Optional, Callable
|
|
|
|
from rio import Component, Column, Text, TextStyle, Button, Spacer
|
|
|
|
|
|
class SeatingPlanInfoBox(Component):
|
|
show: bool
|
|
purchase_cb: Callable
|
|
is_booking_blocked: bool
|
|
seat_id: Optional[str] = None
|
|
seat_occupant: Optional[str] = None
|
|
seat_price: int = 0
|
|
is_blocked: bool = False
|
|
|
|
|
|
def build(self) -> Component:
|
|
if not self.show:
|
|
return Spacer()
|
|
if self.is_blocked:
|
|
return Column(Text(f"Sitzplatz gesperrt", margin=1, style=TextStyle(fill=self.session.theme.neutral_color, font_size=1.4), overflow="wrap", justify="center"), min_height=10)
|
|
if self.seat_id is None and self.seat_occupant is None:
|
|
return Column(Text(f"Sitzplatz auswählen...", margin=1, style=TextStyle(fill=self.session.theme.neutral_color), overflow="wrap", justify="center"), min_height=10)
|
|
return Column(
|
|
Text(f"Dieser Sitzplatz ({self.seat_id}) ist gebucht von:", margin=1, style=TextStyle(fill=self.session.theme.neutral_color), overflow="wrap", justify="center"),
|
|
Text(f"{self.seat_occupant}", margin_bottom=1, style=TextStyle(fill=self.session.theme.neutral_color, font_size=1.4), overflow="wrap", justify="center"),
|
|
min_height=10
|
|
) if self.seat_id and self.seat_occupant else Column(
|
|
Text(f"Dieser Sitzplatz ({self.seat_id}) ist frei", margin=1, style=TextStyle(fill=self.session.theme.neutral_color), overflow="wrap", justify="center"),
|
|
Button(
|
|
Text(
|
|
f"Buchen",
|
|
margin=1,
|
|
style=TextStyle(fill=self.session.theme.neutral_color, font_size=1.1),
|
|
overflow="wrap",
|
|
justify="center"
|
|
),
|
|
shape="rounded",
|
|
style="major",
|
|
color="secondary",
|
|
margin=1,
|
|
grow_y=False,
|
|
is_sensitive=not self.is_booking_blocked,
|
|
on_press=self.purchase_cb
|
|
),
|
|
min_height=10
|
|
)
|