Skip to content

Commit

Permalink
Add beyondViewportPageCount and friends to PagerScreen (#2230)
Browse files Browse the repository at this point in the history
  • Loading branch information
yschimke authored May 8, 2024
1 parent d892aca commit 0dabc24
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 4 deletions.
4 changes: 2 additions & 2 deletions compose-layout/api/current.api
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,15 @@ package com.google.android.horologist.compose.pager {
}

public final class PagerScreenKt {
method @androidx.compose.runtime.Composable public static void PagerScreen(optional androidx.compose.ui.Modifier modifier, androidx.compose.foundation.pager.PagerState state, kotlin.jvm.functions.Function1<? super java.lang.Integer,kotlin.Unit> content);
method @androidx.compose.runtime.Composable public static void PagerScreen(androidx.compose.foundation.pager.PagerState state, optional androidx.compose.ui.Modifier modifier, optional int beyondViewportPageCount, optional boolean userScrollEnabled, optional boolean reverseLayout, optional kotlin.jvm.functions.Function1<? super java.lang.Integer,?>? key, optional androidx.compose.ui.input.nestedscroll.NestedScrollConnection pageNestedScrollConnection, kotlin.jvm.functions.Function1<? super java.lang.Integer,kotlin.Unit> content);
}

public final class VerticalPageIndicatorKt {
method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void VerticalPageIndicator(androidx.wear.compose.material.PageIndicatorState pageIndicatorState, optional androidx.compose.ui.Modifier modifier, optional int indicatorStyle, optional long selectedColor, optional long unselectedColor, optional float indicatorSize, optional float spacing, optional androidx.compose.ui.graphics.Shape indicatorShape);
}

public final class VerticalPagerScreenKt {
method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void VerticalPagerScreen(androidx.compose.foundation.pager.PagerState state, optional androidx.compose.ui.Modifier modifier, kotlin.jvm.functions.Function1<? super java.lang.Integer,kotlin.Unit> content);
method @androidx.compose.runtime.Composable @com.google.android.horologist.annotations.ExperimentalHorologistApi public static void VerticalPagerScreen(androidx.compose.foundation.pager.PagerState state, optional androidx.compose.ui.Modifier modifier, optional int beyondViewportPageCount, optional boolean userScrollEnabled, optional boolean reverseLayout, optional kotlin.jvm.functions.Function1<? super java.lang.Integer,?>? key, optional androidx.compose.ui.input.nestedscroll.NestedScrollConnection pageNestedScrollConnection, kotlin.jvm.functions.Function1<? super java.lang.Integer,kotlin.Unit> content);
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,11 @@
package com.google.android.horologist.compose.pager

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.PagerDefaults
import androidx.compose.foundation.pager.PagerState
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
Expand All @@ -31,6 +33,7 @@ import androidx.compose.runtime.derivedStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
import androidx.compose.ui.platform.LocalConfiguration
import androidx.wear.compose.foundation.ExperimentalWearFoundationApi
import androidx.wear.compose.foundation.HierarchicalFocusCoordinator
Expand All @@ -46,9 +49,17 @@ import com.google.android.horologist.compose.layout.PagerScaffold
*/
@Composable
public fun PagerScreen(
modifier: Modifier = Modifier,
state: PagerState,
content: @Composable ((Int) -> Unit),
modifier: Modifier = Modifier,
beyondViewportPageCount: Int = 0,
userScrollEnabled: Boolean = true,
reverseLayout: Boolean = false,
key: ((index: Int) -> Any)? = null,
pageNestedScrollConnection: NestedScrollConnection = PagerDefaults.pageNestedScrollConnection(
state,
Orientation.Horizontal,
),
content: @Composable (Int) -> Unit,
) {
PagerScaffold(
modifier = Modifier.fillMaxSize(),
Expand All @@ -57,6 +68,11 @@ public fun PagerScreen(
HorizontalPager(
modifier = modifier,
state = state,
beyondViewportPageCount = beyondViewportPageCount,
userScrollEnabled = userScrollEnabled,
reverseLayout = reverseLayout,
key = key,
pageNestedScrollConnection = pageNestedScrollConnection,
flingBehavior = HorizontalPagerDefaults.flingParams(state),
) { page ->
ClippedBox(state) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@
package com.google.android.horologist.compose.pager

import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.gestures.Orientation
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.pager.PagerDefaults
import androidx.compose.foundation.pager.PagerState
import androidx.compose.foundation.pager.VerticalPager
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.input.nestedscroll.NestedScrollConnection
import androidx.compose.ui.unit.dp
import androidx.wear.compose.foundation.ExperimentalWearFoundationApi
import androidx.wear.compose.foundation.rememberActiveFocusRequester
Expand All @@ -45,6 +48,14 @@ import com.google.android.horologist.compose.rotaryinput.rotaryWithPager
public fun VerticalPagerScreen(
state: PagerState,
modifier: Modifier = Modifier,
beyondViewportPageCount: Int = 0,
userScrollEnabled: Boolean = true,
reverseLayout: Boolean = false,
key: ((index: Int) -> Any)? = null,
pageNestedScrollConnection: NestedScrollConnection = PagerDefaults.pageNestedScrollConnection(
state,
Orientation.Vertical,
),
content: @Composable ((Int) -> Unit),
) {
ScreenScaffold(
Expand All @@ -61,6 +72,11 @@ public fun VerticalPagerScreen(
.fillMaxSize()
.rotaryWithPager(state, rememberActiveFocusRequester()),
state = state,
beyondViewportPageCount = beyondViewportPageCount,
userScrollEnabled = userScrollEnabled,
reverseLayout = reverseLayout,
key = key,
pageNestedScrollConnection = pageNestedScrollConnection,
flingBehavior = HorizontalPagerDefaults.flingParams(state),
) { page ->
ClippedBox(state) {
Expand Down

0 comments on commit 0dabc24

Please sign in to comment.