from flut._flut.engine import FlutImmutableObject, FlutStaticObject
from flut._flut.runtime import _flut_unpack_optional_field
from flut.dart.ui import Size
from flut.flutter.painting import EdgeInsets


class MediaQueryData(FlutImmutableObject):

    def __init__(
        self,
        size: Size = None,
        padding: EdgeInsets = None,
        viewInsets: EdgeInsets = None,
        viewPadding: EdgeInsets = None,
        devicePixelRatio: float = 1.0,
    ):
        super().__init__("MediaQueryData")
        self.size = size if size is not None else Size(0, 0)
        self.padding = padding if padding is not None else EdgeInsets(0, 0, 0, 0)
        self.viewInsets = viewInsets if viewInsets is not None else EdgeInsets(0, 0, 0, 0)
        self.viewPadding = viewPadding if viewPadding is not None else EdgeInsets(0, 0, 0, 0)
        self.devicePixelRatio = devicePixelRatio

    @staticmethod
    def _flut_unpack(data: dict) -> "MediaQueryData":
        return MediaQueryData(
            size=_flut_unpack_optional_field(data, "size"),
            padding=_flut_unpack_optional_field(data, "padding"),
            viewInsets=_flut_unpack_optional_field(data, "viewInsets"),
            viewPadding=_flut_unpack_optional_field(data, "viewPadding"),
            devicePixelRatio=_flut_unpack_optional_field(data, "devicePixelRatio"),
        )


class MediaQuery(FlutStaticObject):

    @staticmethod
    def of(context) -> MediaQueryData:
        return FlutStaticObject._static_call("MediaQuery", "of", context)