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

Commit edb5a8c8 authored by Mike Schneider's avatar Mike Schneider
Browse files

Implement `GestureContext` for gesture transitions #MotionMechanics #STL

Flag: com.android.systemui.scene_container
Bug: 388464679
Test: atest DistanceGestureContextTest
Change-Id: I8e3586d07d0fb7b261f4b5d5cc1574e5d3c56f5a
parent 9142dc1d
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"