from typing import override
from flut._flut.engine import FlutEnumObject, FlutImmutableObject
from flut.dart.ui import Color


class BorderStyle(FlutEnumObject):
    solid: "BorderStyle"
    none: "BorderStyle"


class _BorderSide(FlutImmutableObject):
    def __init__(
        self,
        *,
        color: Color = Color(0xFF000000),
        width: float = 1.0,
        style: BorderStyle = BorderStyle.solid,
    ):
        super().__init__("BorderSide")
        self.color = color
        self.width = width
        self.style = style

    @override
    def _flut_pack(self) -> dict:
        result = self._flut_base_props()
        result["color"] = self.color._flut_pack()
        result["width"] = self.width
        result["style"] = self.style._flut_pack()
        return result


class BorderSide(_BorderSide):
    none = _BorderSide(color=Color(0xFF000000), width=0.0, style=BorderStyle.none)


class Border(FlutImmutableObject):
    def __init__(
        self,
        *,
        top: BorderSide = BorderSide.none,
        right: BorderSide = BorderSide.none,
        bottom: BorderSide = BorderSide.none,
        left: BorderSide = BorderSide.none,
    ):
        super().__init__("Border")
        self.top = top
        self.right = right
        self.bottom = bottom
        self.left = left

    @staticmethod
    def all(*, width: float = 1.0, color: Color = Color(0xFF000000)):
        side = BorderSide(color=color, width=width)
        return Border(top=side, right=side, bottom=side, left=side)

    @override
    def _flut_pack(self) -> dict:
        result = self._flut_base_props()
        result["top"] = self.top._flut_pack()
        result["right"] = self.right._flut_pack()
        result["bottom"] = self.bottom._flut_pack()
        result["left"] = self.left._flut_pack()
        return result
