Skip to content
This repository was archived by the owner on Sep 5, 2023. It is now read-only.

Commit a831de7

Browse files
committed
desktop pager fixed
1 parent 1622354 commit a831de7

File tree

3 files changed

+7
-15
lines changed

3 files changed

+7
-15
lines changed

buildSrc/src/main/kotlin/ProjectConfig.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ object ProjectConfig {
55

66
object Info {
77
val group : String = "com.vanpra"
8-
val version : String = "1.0.2"
8+
val version : String = "1.0.3"
99
}
1010
}

datetime/src/desktopMain/kotlin/com/vanpra/composematerialdialogs/datetime/DesktopUtils.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,16 @@ internal fun Color.toAwtColor(): Int {
7070
actual class PlatformPagerState(val listState : LazyListState) {
7171
var internalPageCount: Int = 0
7272
internal set
73-
actual var currentPage: Int by mutableStateOf(0)
73+
actual var currentPage: Int = listState.firstVisibleItemIndex
74+
internal set
7475

7576
actual suspend fun scrollToPage(page: Int, pageOffset: Float) {
77+
currentPage = page
7678
listState.scrollToItem(page)
7779
}
7880

7981
actual suspend fun animateScrollToPage(page: Int, pageOffset: Float) {
82+
currentPage = page
8083
listState.animateScrollToItem(page)
8184
}
8285
}

datetime/src/desktopMain/kotlin/com/vanpra/composematerialdialogs/datetime/PlatformHorizontalPager.kt

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,11 @@ actual fun PlatformHorizontalPager(
3535
) {
3636
state.internalPageCount = count
3737

38-
val listState = rememberLazyListState()
3938
val isVertical = false
4039
val reverseLayout = false
4140
val contentPadding = PaddingValues(0.dp)
4241
val horizontalAlignment = Alignment.CenterHorizontally
4342
val itemSpacing = 0.dp
44-
val scope = object : PlatformPagerScope{
45-
46-
}
4743

4844
// We only consume nested flings in the main-axis, allowing cross-axis flings to propagate
4945
// as normal
@@ -53,7 +49,7 @@ actual fun PlatformHorizontalPager(
5349
)
5450

5551
LazyRow(
56-
state = listState,
52+
state = state.listState,
5753
verticalAlignment = verticalAlignment,
5854
horizontalArrangement = Arrangement.spacedBy(itemSpacing, horizontalAlignment),
5955
reverseLayout = reverseLayout,
@@ -74,14 +70,7 @@ actual fun PlatformHorizontalPager(
7470
.fillParentMaxWidth()
7571
.wrapContentSize()
7672
) {
77-
content(scope,page)
78-
}
79-
}
80-
}
81-
LazyRow(modifier = modifier, verticalAlignment = verticalAlignment) {
82-
items(count) { index ->
83-
Box(Modifier.fillMaxWidth()) {
84-
content(object : PlatformPagerScope {}, index)
73+
content(object : PlatformPagerScope{},page)
8574
}
8675
}
8776
}

0 commit comments

Comments
 (0)