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

Commit 53f7942d authored by Jordan Demeulenaere's avatar Jordan Demeulenaere
Browse files

Allow to define overscroll specs for overlays

Bug: 353679003
Test: Already tested through scene definitions
Flag: com.android.systemui.scene_container
Change-Id: I469d64e652004d2a04490ad2c2689174250790a6
parent ac33fc07
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -104,23 +104,23 @@ interface SceneTransitionsBuilder {
    ): TransitionSpec

    /**
     * Define the animation to be played when the [scene] is overscrolled in the given
     * Define the animation to be played when the [content] is overscrolled in the given
     * [orientation].
     *
     * The overscroll animation always starts from a progress of 0f, and reaches 1f when moving the
     * [distance] down/right, -1f when moving in the opposite direction.
     */
    fun overscroll(
        scene: SceneKey,
        content: ContentKey,
        orientation: Orientation,
        builder: OverscrollBuilder.() -> Unit,
    ): OverscrollSpec

    /**
     * Prevents overscroll the [scene] in the given [orientation], allowing ancestors to eventually
     * consume the remaining gesture.
     * Prevents overscroll the [content] in the given [orientation], allowing ancestors to
     * eventually consume the remaining gesture.
     */
    fun overscrollDisabled(scene: SceneKey, orientation: Orientation): OverscrollSpec
    fun overscrollDisabled(content: ContentKey, orientation: Orientation): OverscrollSpec
}

interface BaseTransitionBuilder : PropertyTransformationBuilder {
+7 −7
Original line number Diff line number Diff line
@@ -84,30 +84,30 @@ private class SceneTransitionsBuilderImpl : SceneTransitionsBuilder {
    }

    override fun overscroll(
        scene: SceneKey,
        content: ContentKey,
        orientation: Orientation,
        builder: OverscrollBuilder.() -> Unit
    ): OverscrollSpec {
        val impl = OverscrollBuilderImpl().apply(builder)
        check(impl.transformations.isNotEmpty()) {
            "This method does not allow empty transformations. " +
                "Use overscrollDisabled($scene, $orientation) instead."
                "Use overscrollDisabled($content, $orientation) instead."
        }
        return overscrollSpec(scene, orientation, impl)
        return overscrollSpec(content, orientation, impl)
    }

    override fun overscrollDisabled(scene: SceneKey, orientation: Orientation): OverscrollSpec {
        return overscrollSpec(scene, orientation, OverscrollBuilderImpl())
    override fun overscrollDisabled(content: ContentKey, orientation: Orientation): OverscrollSpec {
        return overscrollSpec(content, orientation, OverscrollBuilderImpl())
    }

    private fun overscrollSpec(
        scene: SceneKey,
        content: ContentKey,
        orientation: Orientation,
        impl: OverscrollBuilderImpl,
    ): OverscrollSpec {
        val spec =
            OverscrollSpecImpl(
                content = scene,
                content = content,
                orientation = orientation,
                transformationSpec =
                    TransformationSpecImpl(