Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 32e6c498 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Implement `GestureContext` for gesture transitions #MotionMechanics #STL" into main

parents c40e2aa0 edb5a8c8
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -58,8 +58,19 @@ interface GestureContext {
    val dragOffset: Float
}

/**
 * [GestureContext] with a mutable [dragOffset].
 *
 * The implementation class defines whether the [direction] is updated accordingly.
 */
interface MutableDragOffsetGestureContext : GestureContext {
    /** The gesture distance of the current gesture, in pixels. */
    override var dragOffset: Float
}

/** [GestureContext] implementation for manually set values. */
class ProvidedGestureContext(direction: InputDirection, dragOffset: Float) : GestureContext {
class ProvidedGestureContext(dragOffset: Float, direction: InputDirection) :
    MutableDragOffsetGestureContext {
    override var direction by mutableStateOf(direction)
    override var dragOffset by mutableFloatStateOf(dragOffset)
}
@@ -79,7 +90,7 @@ class DistanceGestureContext(
    initialDragOffset: Float,
    initialDirection: InputDirection,
    directionChangeSlop: Float,
) : GestureContext {
) : MutableDragOffsetGestureContext {
    init {
        require(directionChangeSlop > 0) {
            "directionChangeSlop must be greater than 0, was $directionChangeSlop"