修复点击"今天"按钮无动画:scrollToPage 改为 animateScrollToPage
LaunchedEffect(selectedDate) 用无动画的 scrollToPage 抢先跳转, 导致 onToday 里的 animateScrollToPage 被取消。统一由 LaunchedEffect 处理滚动,onToday 只需 selectDate。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
917ba2125f
commit
996d8c104f
@ -132,7 +132,7 @@ fun CalendarMonthView(
|
|||||||
today.year, today.month.number
|
today.year, today.month.number
|
||||||
)
|
)
|
||||||
if (targetPage != pagerState.currentPage) {
|
if (targetPage != pagerState.currentPage) {
|
||||||
pagerState.scrollToPage(targetPage)
|
pagerState.animateScrollToPage(targetPage)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,14 +239,6 @@ fun CalendarMonthView(
|
|||||||
showToday = viewModel.selectedDate != today,
|
showToday = viewModel.selectedDate != today,
|
||||||
onToday = {
|
onToday = {
|
||||||
viewModel.selectDate(today)
|
viewModel.selectDate(today)
|
||||||
@Suppress("DEPRECATION") // monthNumber 无替代 API
|
|
||||||
val targetPage = yearMonthToPage(
|
|
||||||
today.year, today.month.number,
|
|
||||||
today.year, today.month.number
|
|
||||||
)
|
|
||||||
if (targetPage != pagerState.currentPage) {
|
|
||||||
coroutineScope.launch { pagerState.animateScrollToPage(targetPage) }
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
modifier = Modifier.onSizeChanged { size ->
|
modifier = Modifier.onSizeChanged { size ->
|
||||||
monthHeaderHeightPx = size.height
|
monthHeaderHeightPx = size.height
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user