from rio import Column, Component, event, Text, TextStyle, Row

from src.ezgg_lan_manager.components.AdminNavigationCard import AdminNavigationCard
from src.ezgg_lan_manager.components.MainViewContentBox import MainViewContentBox
from src.ezgg_lan_manager.services.ConfigurationService import ConfigurationService


class AdminNavigationPage(Component):
    @event.on_populate
    async def on_populate(self) -> None:
        await self.session.set_title(f"{self.session[ConfigurationService].get_lan_info().name} - Admin")

    def build(self) -> Component:
        return Column(
            MainViewContentBox(
                Text(
                    text="Admin",
                    style=TextStyle(
                        fill=self.session.theme.background_color,
                        font_size=1.2
                    ),
                    margin_top=2,
                    margin_bottom=2,
                    align_x=0.5
                )
            ),
            MainViewContentBox(
                Column(
                    Row(
                        AdminNavigationCard(icon_name="material/supervised_user_circle", display_text="Nutzer", target_url="manage-users"),
                        AdminNavigationCard(icon_name="material/fastfood", display_text="Catering", target_url="manage-catering"),
                        spacing=1
                    ),
                    Row(
                        AdminNavigationCard(icon_name="material/text_ad", display_text="News", target_url="manage-news"),
                        AdminNavigationCard(icon_name="material/trophy", display_text="Turniere", target_url="manage-tournaments"),
                        spacing=1
                    ),
                    margin=1,
                    spacing=1
                )
            ),
            align_y=0
        )
