add seating plan legend, improve ui

This commit is contained in:
David Rodenkirchen
2024-09-06 12:22:40 +02:00
parent c7c7cc7964
commit 871d8d6a3d
4 changed files with 115 additions and 9 deletions
+60 -1
View File
@@ -1,6 +1,6 @@
from typing import Callable
from rio import Component, Rectangle, Grid
from rio import Component, Rectangle, Grid, Column, Row, Text, TextStyle, Color
from src.ez_lan_manager.components.SeatingPlanPixels import SeatPixel, WallPixel, InvisiblePixel, TextPixel
from src.ez_lan_manager.types.Seat import Seat
@@ -8,6 +8,65 @@ from src.ez_lan_manager.types.Seat import Seat
MAX_GRID_WIDTH_PIXELS = 34
MAX_GRID_HEIGHT_PIXELS = 45
class SeatingPlanLegend(Component):
def build(self) -> Component:
return Column(
Text("Legende", style=TextStyle(fill=self.session.theme.neutral_color), justify="center", margin=1),
Row(
Text("L = Luxus Platz", justify="center", style=TextStyle(fill=self.session.theme.neutral_color)),
Text("N = Normaler Platz", justify="center", style=TextStyle(fill=self.session.theme.neutral_color)),
),
Row(
Rectangle(
content=Column(
Text(f"Freier Platz", style=TextStyle(fill=self.session.theme.primary_color, font_size=0.7), align_x=0.5, selectable=False),
Text(f"", style=TextStyle(fill=self.session.theme.primary_color, font_size=0.9), align_x=0.5,
selectable=False, wrap=True)
),
min_width=1,
min_height=1,
fill=self.session.theme.success_color,
grow_x=False,
grow_y=False,
hover_fill=self.session.theme.success_color,
transition_time=0.4,
ripple=True
),
Rectangle(
content=Column(
Text(f"Belegter Platz", style=TextStyle(fill=self.session.theme.primary_color, font_size=0.7), align_x=0.5, selectable=False),
Text(f"", style=TextStyle(fill=self.session.theme.primary_color, font_size=0.9), align_x=0.5,
selectable=False, wrap=True)
),
min_width=1,
min_height=1,
fill=self.session.theme.danger_color,
grow_x=False,
grow_y=False,
hover_fill=self.session.theme.danger_color,
transition_time=0.4,
ripple=True
),
Rectangle(
content=Column(
Text(f"Eigener Platz", style=TextStyle(fill=self.session.theme.primary_color, font_size=0.7), align_x=0.5, selectable=False),
Text(f"", style=TextStyle(fill=self.session.theme.primary_color, font_size=0.9), align_x=0.5,
selectable=False, wrap=True)
),
min_width=1,
min_height=1,
fill=Color.from_hex("800080"),
grow_x=False,
grow_y=False,
hover_fill=Color.from_hex("800080"),
transition_time=0.4,
ripple=True
),
margin=1,
spacing=1
)
)
class SeatingPlan(Component):
seat_clicked_cb: Callable
@@ -10,6 +10,7 @@ class SeatingPlanInfoBox(Component):
seat_occupant: Optional[str] = None
seat_price: int = 0
is_blocked: bool = False
user_has_seat: bool = False
def build(self) -> Component:
if self.is_blocked:
@@ -22,5 +23,20 @@ class SeatingPlanInfoBox(Component):
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), wrap=True, justify="center"),
Button(Text(f"Buchen ({AccountingService.make_euro_string_from_int(self.seat_price)})", margin=1, style=TextStyle(fill=self.session.theme.neutral_color, font_size=1.1), wrap=True, justify="center"), shape="rounded", style="major", color="secondary", margin=1, grow_y=False), min_height=10
Button(
Text(
f"Buchen ({AccountingService.make_euro_string_from_int(self.seat_price)})",
margin=1,
style=TextStyle(fill=self.session.theme.neutral_color, font_size=1.1),
wrap=True,
justify="center"
),
shape="rounded",
style="major",
color="secondary",
margin=1,
grow_y=False,
is_sensitive=not self.user_has_seat
),
min_height=10
)
@@ -1,6 +1,6 @@
from functools import partial
from rio import Component, Text, Icon, TextStyle, Rectangle, Spacer, Color, MouseEventListener
from rio import Component, Text, Icon, TextStyle, Rectangle, Spacer, Color, MouseEventListener, Column
from typing import Optional, Callable
from src.ez_lan_manager.types.Seat import Seat
@@ -22,7 +22,10 @@ class SeatPixel(Component):
def build(self) -> Component:
return MouseEventListener(
content=Rectangle(
content=Text(self.seat_id, style=TextStyle(fill=self.session.theme.primary_color, font_size=0.7), align_x=0.5, selectable=False),
content=Column(
Text(f"{self.seat_id}", style=TextStyle(fill=self.session.theme.primary_color, font_size=0.7), align_x=0.5, selectable=False),
Text(f"{self.seat.category[0]}", style=TextStyle(fill=self.session.theme.primary_color, font_size=0.9), align_x=0.5, selectable=False, wrap=True)
),
min_width=1,
min_height=1,
fill=self.determine_color(),