Loading packages/SystemUI/compose/scene/src/com/android/compose/nestedscroll/LargeTopAppBarNestedScrollConnection.kt +2 −2 Original line number Diff line number Diff line Loading @@ -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]. Loading packages/SystemUI/compose/scene/tests/src/com/android/compose/nestedscroll/LargeTopAppBarNestedScrollConnectionTest.kt +0 −35 Original line number Diff line number Diff line Loading @@ -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) Loading Loading
packages/SystemUI/compose/scene/src/com/android/compose/nestedscroll/LargeTopAppBarNestedScrollConnection.kt +2 −2 Original line number Diff line number Diff line Loading @@ -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]. Loading
packages/SystemUI/compose/scene/tests/src/com/android/compose/nestedscroll/LargeTopAppBarNestedScrollConnectionTest.kt +0 −35 Original line number Diff line number Diff line Loading @@ -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) Loading