mirror of
https://github.com/fankes/pagecurl-multiplatform.git
synced 2025-09-05 10:15:30 +08:00
Add dynamic max support
This commit is contained in:
37
README.md
37
README.md
@@ -46,13 +46,12 @@ dependencies {
|
||||
### Use in Composable
|
||||
|
||||
The `PageCurl` has 2 mandatory arguments:
|
||||
* **state** - The state of the PageCurl. Use it to programmatically change the current page or observe changes, and to configure shadow, back-page and interactions.
|
||||
* **content** - The content lambda to provide the page composable. Receives the page number.
|
||||
* **count** - The count of pages.
|
||||
* **content** - The content lambda to provide the page composable. Receives the page number.
|
||||
|
||||
```
|
||||
val pages = listOf("One", "Two", "Three")
|
||||
val state = rememberPageCurlState(max = pages.size)
|
||||
PageCurl(state = state) { index ->
|
||||
PageCurl(count = pages.size) { index ->
|
||||
Box(
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier = Modifier
|
||||
@@ -67,6 +66,36 @@ PageCurl(state = state) { index ->
|
||||
}
|
||||
```
|
||||
|
||||
Optionally `state` could be provided to observe and manage PageCurl state.
|
||||
* **state** - The state of the PageCurl. Use it to programmatically change the current page or observe changes, and to configure shadow, back-page and interactions.
|
||||
```
|
||||
Column {
|
||||
val scope = rememberCoroutineScope()
|
||||
val state = rememberPageCurlState()
|
||||
Button(onClick = { scope.launch { state.next() } }) {
|
||||
Text(text = "Next")
|
||||
}
|
||||
|
||||
val pages = listOf("One", "Two", "Three")
|
||||
PageCurl(
|
||||
count = pages.size,
|
||||
state = state,
|
||||
) { index ->
|
||||
Box(
|
||||
contentAlignment = Alignment.Center,
|
||||
modifier = Modifier
|
||||
.background(MaterialTheme.colors.background)
|
||||
.fillMaxSize()
|
||||
) {
|
||||
Text(
|
||||
text = pages[index],
|
||||
style = MaterialTheme.typography.h1,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
See Demo application and [examples](demo/src/main/kotlin/eu/wewox/pagecurl/screens) for more usage examples.
|
||||
|
||||
https://user-images.githubusercontent.com/20944869/185782671-2861c2ed-c033-4318-bf12-1d8db74fc8b5.mp4
|
||||
|
Reference in New Issue
Block a user