Skip to content

Commit 5c4742b

Browse files
authored
Merge pull request #963 from arkivanov/ChildPages-docs
Add docs for ChildPages composable functions
2 parents e7eade5 + 5dc0985 commit 5c4742b

File tree

1 file changed

+46
-2
lines changed
  • extensions-compose/src/commonMain/kotlin/com/arkivanov/decompose/extensions/compose/pages

1 file changed

+46
-2
lines changed

extensions-compose/src/commonMain/kotlin/com/arkivanov/decompose/extensions/compose/pages/ChildPages.kt

Lines changed: 46 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,17 @@ import com.arkivanov.decompose.value.Value
2020

2121
/**
2222
* Displays a list of pages represented by [ChildPages].
23+
*
24+
* @param pages an observable [ChildPages] to be displayed.
25+
* @param onPageSelected a callback called when the selected page changes, e.g. by swiping the pager.
26+
* The corresponding [ChildPages][com.arkivanov.decompose.router.pages.ChildPages] navigation model
27+
* should be updated to reflect the change, usually by calling
28+
* [PagesNavigator#select][com.arkivanov.decompose.router.pages.select].
29+
* @param modifier a [Modifier] to be applied to the underlying pager.
30+
* @param scrollAnimation a [PagesScrollAnimation] to be used for pager scrolling when the
31+
* selected page changes.
32+
* @param key a stable and unique key representing the child.
33+
* @param pageContent a composable function that displays the provided child.
2334
*/
2435
@Composable
2536
fun <C : Any, T : Any> ChildPages(
@@ -44,6 +55,17 @@ fun <C : Any, T : Any> ChildPages(
4455

4556
/**
4657
* Displays a list of pages represented by [ChildPages].
58+
*
59+
* @param pages an observable [ChildPages] to be displayed.
60+
* @param onPageSelected a callback called when the selected page changes, e.g. by swiping the pager.
61+
* The corresponding [ChildPages][com.arkivanov.decompose.router.pages.ChildPages] navigation model
62+
* should be updated to reflect the change, usually by calling
63+
* [PagesNavigator#select][com.arkivanov.decompose.router.pages.select].
64+
* @param modifier a [Modifier] to be applied to the underlying pager.
65+
* @param scrollAnimation a [PagesScrollAnimation] to be used for pager scrolling when the
66+
* selected page changes.
67+
* @param key a stable and unique key representing the child.
68+
* @param pageContent a composable function that displays the provided child.
4769
*/
4870
@ExperimentalDecomposeApi
4971
@Composable
@@ -53,7 +75,7 @@ fun <C : Any, T : Any> ChildPages(
5375
modifier: Modifier = Modifier,
5476
scrollAnimation: PagesScrollAnimation = PagesScrollAnimation.Disabled,
5577
pager: ChildPagesPager = defaultHorizontalPager(),
56-
key: (Child<C, T>) -> Any = Child<*, *>::keyHashString,
78+
key: (Child<C, T>) -> Any = Child<*, *>::key,
5779
pageContent: @Composable PagerScope.(index: Int, page: T, PagerState) -> Unit,
5880
) {
5981
val state by pages.subscribeAsState()
@@ -71,6 +93,17 @@ fun <C : Any, T : Any> ChildPages(
7193

7294
/**
7395
* Displays a list of pages represented by [ChildPages].
96+
*
97+
* @param pages [ChildPages] to be displayed.
98+
* @param onPageSelected a callback called when the selected page changes, e.g. by swiping the pager.
99+
* The corresponding [ChildPages][com.arkivanov.decompose.router.pages.ChildPages] navigation model
100+
* should be updated to reflect the change, usually by calling
101+
* [PagesNavigator#select][com.arkivanov.decompose.router.pages.select].
102+
* @param modifier a [Modifier] to be applied to the underlying pager.
103+
* @param scrollAnimation a [PagesScrollAnimation] to be used for pager scrolling when the
104+
* selected page changes.
105+
* @param key a stable and unique key representing the child.
106+
* @param pageContent a composable function that displays the provided child.
74107
*/
75108
@Composable
76109
fun <C : Any, T : Any> ChildPages(
@@ -95,6 +128,17 @@ fun <C : Any, T : Any> ChildPages(
95128

96129
/**
97130
* Displays a list of pages represented by [ChildPages].
131+
*
132+
* @param pages [ChildPages] to be displayed.
133+
* @param onPageSelected a callback called when the selected page changes, e.g. by swiping the pager.
134+
* The corresponding [ChildPages][com.arkivanov.decompose.router.pages.ChildPages] navigation model
135+
* should be updated to reflect the change, usually by calling
136+
* [PagesNavigator#select][com.arkivanov.decompose.router.pages.select].
137+
* @param modifier a [Modifier] to be applied to the underlying pager.
138+
* @param scrollAnimation a [PagesScrollAnimation] to be used for pager scrolling when the
139+
* selected page changes.
140+
* @param key a stable and unique key representing the child.
141+
* @param pageContent a composable function that displays the provided child.
98142
*/
99143
@ExperimentalDecomposeApi
100144
@Composable
@@ -104,7 +148,7 @@ fun <C : Any, T : Any> ChildPages(
104148
modifier: Modifier = Modifier,
105149
scrollAnimation: PagesScrollAnimation = PagesScrollAnimation.Disabled,
106150
pager: ChildPagesPager = defaultHorizontalPager(),
107-
key: (Child<C, T>) -> Any = Child<*, *>::keyHashString,
151+
key: (Child<C, T>) -> Any = Child<*, *>::key,
108152
pageContent: @Composable PagerScope.(index: Int, page: T, PagerState) -> Unit,
109153
) {
110154
val selectedIndex = pages.selectedIndex.coerceAtLeast(0)

0 commit comments

Comments
 (0)