add seating plan v2 (missing booking)

This commit is contained in:
David Rodenkirchen
2024-09-05 01:07:51 +02:00
parent acf458d629
commit c7c7cc7964
5 changed files with 136 additions and 50 deletions
@@ -1,21 +1,39 @@
from rio import Component, Text, Icon, TextStyle, Rectangle, Spacer, Color
from typing import Optional
from functools import partial
from rio import Component, Text, Icon, TextStyle, Rectangle, Spacer, Color, MouseEventListener
from typing import Optional, Callable
from src.ez_lan_manager.types.Seat import Seat
from src.ez_lan_manager.types.SessionStorage import SessionStorage
class SeatPixel(Component):
seat_id: str
on_press_cb: Callable
seat: Seat
def determine_color(self) -> Color:
if self.seat.user is not None and self.seat.user.user_id == self.session[SessionStorage].user_id:
return Color.from_hex("800080")
elif self.seat.is_blocked or self.seat.user is not None:
return self.session.theme.danger_color
return self.session.theme.success_color
def build(self) -> Component:
return Rectangle(
content=Text(self.seat_id, style=TextStyle(fill=self.session.theme.primary_color, font_size=0.7), align_x=0.5),
min_width=1,
min_height=1,
fill=self.session.theme.success_color,
hover_stroke_width = 0.1,
grow_x=True,
grow_y=True,
hover_fill=self.session.theme.hud_color,
transition_time=0.4
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),
min_width=1,
min_height=1,
fill=self.determine_color(),
hover_stroke_width = 0.1,
grow_x=True,
grow_y=True,
hover_fill=self.session.theme.hud_color,
transition_time=0.4,
ripple=True
),
on_press=partial(self.on_press_cb, self.seat_id)
)
class TextPixel(Component):
@@ -25,7 +43,7 @@ class TextPixel(Component):
def build(self) -> Component:
if self.text is not None:
content = Text(self.text, style=TextStyle(fill=self.session.theme.neutral_color, font_size=1), align_x=0.5)
content = Text(self.text, style=TextStyle(fill=self.session.theme.neutral_color, font_size=1), align_x=0.5, selectable=False)
elif self.icon_name is not None:
content = Icon(self.icon_name, fill=self.session.theme.neutral_color)
else:
@@ -40,8 +58,8 @@ class TextPixel(Component):
hover_stroke_width = None if self.no_outline else 0.1,
grow_x=True,
grow_y=True,
hover_fill=None if self.no_outline else self.session.theme.hud_color,
transition_time=0.4
hover_fill=None,
ripple=True
)
class WallPixel(Component):