from flut._flut.engine import FlutImmutableObject
from flut._flut.runtime import _flut_unpack_optional_field, _flut_unpack_required_field
from flut.dart.ui import Offset
from flut.flutter.gestures.velocity_tracker import Velocity


class DragStartDetails(FlutImmutableObject):
    def __init__(
        self,
        *,
        globalPosition=Offset(),
        localPosition=None,
    ):
        super().__init__("DragStartDetails")
        self.globalPosition = globalPosition
        self.localPosition = localPosition

    @staticmethod
    def _flut_unpack(data: dict) -> "DragStartDetails":
        return DragStartDetails(
            globalPosition=_flut_unpack_required_field(data, "globalPosition"),
            localPosition=_flut_unpack_optional_field(data, "localPosition"),
        )


class DragUpdateDetails(FlutImmutableObject):
    def __init__(
        self,
        *,
        globalPosition,
        localPosition=None,
        delta=Offset(),
    ):
        super().__init__("DragUpdateDetails")
        self.globalPosition = globalPosition
        self.localPosition = localPosition
        self.delta = delta

    @staticmethod
    def _flut_unpack(data: dict) -> "DragUpdateDetails":
        return DragUpdateDetails(
            globalPosition=_flut_unpack_required_field(data, "globalPosition"),
            localPosition=_flut_unpack_optional_field(data, "localPosition"),
            delta=_flut_unpack_required_field(data, "delta"),
        )


class DragEndDetails(FlutImmutableObject):

    def __init__(
        self,
        *,
        globalPosition=Offset(),
        localPosition=None,
        velocity=Velocity.zero,
        primaryVelocity=None,
    ):
        super().__init__("DragEndDetails")
        self.globalPosition = globalPosition
        self.localPosition = localPosition
        self.velocity = velocity
        self.primaryVelocity = primaryVelocity

    @staticmethod
    def _flut_unpack(data: dict) -> "DragEndDetails":
        return DragEndDetails(
            globalPosition=_flut_unpack_required_field(data, "globalPosition"),
            localPosition=_flut_unpack_optional_field(data, "localPosition"),
            velocity=_flut_unpack_required_field(data, "velocity"),
            primaryVelocity=_flut_unpack_optional_field(data, "primaryVelocity"),
        )
