Co-authored-by: David Rodenkirchen <drodenkirchen@linetco.com> Reviewed-on: Vereins-IT/ez-lan-manager#1
97 lines
3.4 KiB
Python
97 lines
3.4 KiB
Python
from typing import Optional, Callable
|
|
|
|
from rio import Component, Column, Text, TextStyle, Button, Spacer, Row, ProgressCircle
|
|
|
|
|
|
class SeatingPurchaseBox(Component):
|
|
show: bool
|
|
seat_id: str
|
|
is_loading: bool
|
|
confirm_cb: Callable
|
|
cancel_cb: Callable
|
|
error_msg: Optional[str] = None
|
|
success_msg: Optional[str] = None
|
|
|
|
def build(self) -> Component:
|
|
if not self.show:
|
|
return Spacer()
|
|
if self.is_loading:
|
|
return Column(
|
|
ProgressCircle(
|
|
color="secondary",
|
|
align_x=0.5,
|
|
margin_top=2,
|
|
margin_bottom=2
|
|
),
|
|
min_height=10
|
|
)
|
|
|
|
if self.success_msg:
|
|
return Column(
|
|
Text(f"{self.success_msg}", margin=1, style=TextStyle(fill=self.session.theme.success_color, font_size=1.1),
|
|
overflow="wrap", justify="center"),
|
|
Row(
|
|
Button(
|
|
Text("Zurück",
|
|
margin=1,
|
|
style=TextStyle(fill=self.session.theme.success_color, font_size=1.1),
|
|
overflow="wrap",
|
|
justify="center"
|
|
),
|
|
shape="rounded",
|
|
style="plain-text",
|
|
on_press=self.cancel_cb
|
|
)
|
|
),
|
|
min_height=10
|
|
)
|
|
|
|
if self.error_msg:
|
|
return Column(
|
|
Text(f"{self.error_msg}", margin=1, style=TextStyle(fill=self.session.theme.danger_color, font_size=1.1),
|
|
overflow="wrap", justify="center"),
|
|
Row(
|
|
Button(
|
|
Text("Zurück",
|
|
margin=1,
|
|
style=TextStyle(fill=self.session.theme.danger_color, font_size=1.1),
|
|
overflow="wrap",
|
|
justify="center"
|
|
),
|
|
shape="rounded",
|
|
style="plain-text",
|
|
on_press=self.cancel_cb
|
|
)
|
|
),
|
|
min_height=10
|
|
)
|
|
|
|
return Column(
|
|
Text(f"Sitzplatz {self.seat_id} verbindlich buchen?", margin=1, style=TextStyle(fill=self.session.theme.neutral_color, font_size=1.4), overflow="wrap", justify="center"),
|
|
Row(
|
|
Button(
|
|
Text("Nein",
|
|
margin=1,
|
|
style=TextStyle(fill=self.session.theme.danger_color, font_size=1.1),
|
|
overflow="wrap",
|
|
justify="center"
|
|
),
|
|
shape="rounded",
|
|
style="plain-text",
|
|
on_press=self.cancel_cb
|
|
),
|
|
Button(
|
|
Text("Ja",
|
|
margin=1,
|
|
style=TextStyle(fill=self.session.theme.success_color, font_size=1.1),
|
|
overflow="wrap",
|
|
justify="center"
|
|
),
|
|
shape="rounded",
|
|
style="minor",
|
|
on_press=self.confirm_cb
|
|
)
|
|
),
|
|
min_height=10
|
|
)
|