from flut._flut.engine import FlutRealtimeObject
from flut.dart import Duration
from flut.flutter.animation.curves import Curve, Curves


class ScrollPosition(FlutRealtimeObject):
    def __init__(self, oid: int):
        super().__init__("ScrollPosition", oid=oid)

    @property
    def pixels(self) -> float:
        return self._get("pixels")

    @property
    def minScrollExtent(self) -> float:
        return self._get("minScrollExtent")

    @property
    def maxScrollExtent(self) -> float:
        return self._get("maxScrollExtent")

    @property
    def viewportDimension(self) -> float:
        return self._get("viewportDimension")

    @property
    def hasContentDimensions(self) -> bool:
        return self._get("hasContentDimensions")

    @property
    def hasPixels(self) -> bool:
        return self._get("hasPixels")

    @property
    def atEdge(self) -> bool:
        return self._get("atEdge")

    def jumpTo(self, offset: float):
        self._call_void("jumpTo", offset=offset)

    def animateTo(self, offset: float, duration: Duration, curve: Curve = Curves.easeInOut):
        self._call_void(
            "animateTo",
            offset=offset,
            duration=duration._flut_pack(),
            curve=curve._flut_pack(),
        )
