from typing import Optional

from rio import Component, Row, Text, TextStyle, Color


class TournamentDetailsInfoRow(Component):
    key: str
    value: str
    key_color: Optional[Color] = None
    value_color: Optional[Color] = None


    def build(self) -> Component:
        return Row(
            Text(
                text=self.key,
                style=TextStyle(
                    fill=self.key_color if self.key_color is not None else self.session.theme.background_color,
                    font_size=1
                ),
                margin_bottom=0.5,
                align_x=0
            ),
            Text(
                text=self.value,
                style=TextStyle(
                    fill=self.value_color if self.value_color is not None else self.session.theme.background_color,
                    font_size=1
                ),
                margin_bottom=0.5,
                align_x=1
            ),
            margin_left=4,
            margin_right=4
        )
