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

Commit 6ff074b1 authored by Omar Miatello's avatar Omar Miatello Committed by Android (Google) Code Review
Browse files

Merge "STL improve large appbar demo experience" into main

parents 936b76d3 cb488d98
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -48,8 +48,8 @@ fun LargeTopAppBarNestedScrollConnection(
        orientation = Orientation.Vertical,
        // When swiping up, the LargeTopAppBar will shrink (to [minHeight]) and the content will
        // expand. Then, you can then scroll down the content.
        canStartPreScroll = { offsetAvailable, offsetBeforeStart, _ ->
            offsetAvailable < 0 && offsetBeforeStart == 0f && height() > minHeight()
        canStartPreScroll = { offsetAvailable, _, _ ->
            offsetAvailable < 0 && height() > minHeight()
        },
        // When swiping down, the content will scroll up until it reaches the top. Then, the
        // LargeTopAppBar will expand until it reaches its [maxHeight].
+0 −35
Original line number Diff line number Diff line
@@ -70,41 +70,6 @@ class LargeTopAppBarNestedScrollConnectionTest(testCase: TestCase) {
        assertThat(height).isEqualTo(0f)
    }

    @Test
    fun onScrollUpAfterContentScrolled_ignoreUpEvent() {
        val scrollConnection = buildScrollConnection(heightRange = 0f..2f)
        height = 1f

        // scroll down consumed by a child
        scrollConnection.scroll(available = Offset(0f, 1f), consumedByScroll = Offset(0f, 1f))

        val offsetConsumed =
            scrollConnection.onPreScroll(available = Offset(x = 0f, y = -1f), source = scrollSource)

        // It should ignore all onPreScroll events
        assertThat(offsetConsumed).isEqualTo(Offset.Zero)
        assertThat(height).isEqualTo(1f)
    }

    @Test
    fun onScrollUpAfterContentReturnedToZero_consumeHeight() {
        val scrollConnection = buildScrollConnection(heightRange = 0f..2f)
        height = 1f

        // scroll down consumed by a child
        scrollConnection.scroll(available = Offset(0f, 1f), consumedByScroll = Offset(0f, 1f))

        // scroll up consumed by a child, the child is in its original position
        scrollConnection.scroll(available = Offset(0f, -1f), consumedByScroll = Offset(0f, -1f))

        val offsetConsumed =
            scrollConnection.onPreScroll(available = Offset(x = 0f, y = -1f), source = scrollSource)

        // It should ignore all onPreScroll events
        assertThat(offsetConsumed).isEqualTo(Offset(0f, -1f))
        assertThat(height).isEqualTo(0f)
    }

    @Test
    fun onScrollUp_consumeDownToMin() {
        val scrollConnection = buildScrollConnection(heightRange = 0f..2f)