diff --git a/core/src/main/kotlin/plus/rua/project/ui/CalendarMonthPage.kt b/core/src/main/kotlin/plus/rua/project/ui/CalendarMonthPage.kt index 73aca94..2834a90 100644 --- a/core/src/main/kotlin/plus/rua/project/ui/CalendarMonthPage.kt +++ b/core/src/main/kotlin/plus/rua/project/ui/CalendarMonthPage.kt @@ -15,7 +15,8 @@ import androidx.compose.runtime.produceState import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clipToBounds -import androidx.compose.ui.graphics.graphicsLayer +import androidx.compose.ui.draw.alpha +import androidx.compose.foundation.layout.offset import androidx.compose.ui.layout.onSizeChanged import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.unit.dp @@ -210,10 +211,8 @@ private fun WeekRow( if (isAnchor && phase1 >= 1f) Modifier.background(MaterialTheme.colorScheme.surface) else Modifier ) - .graphicsLayer { - translationY = yOffsetPx - this.alpha = rowAlpha - } + .offset(y = with(density) { yOffsetPx.toDp() }) + .alpha(rowAlpha) .then( if (weekIndex == 0 && rowHeightPx == 0) { Modifier.onSizeChanged { size -> diff --git a/core/src/main/kotlin/plus/rua/project/ui/CalendarMonthView.kt b/core/src/main/kotlin/plus/rua/project/ui/CalendarMonthView.kt index 3a9fc32..b259462 100644 --- a/core/src/main/kotlin/plus/rua/project/ui/CalendarMonthView.kt +++ b/core/src/main/kotlin/plus/rua/project/ui/CalendarMonthView.kt @@ -29,6 +29,7 @@ import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.offset import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.statusBarsPadding @@ -193,7 +194,7 @@ fun CalendarMonthView( modifier = Modifier .fillMaxSize() .background(MaterialTheme.colorScheme.background) - .graphicsLayer { alpha = if (layoutReady) 1f else 0f } + .alpha(if (layoutReady) 1f else 0f) ) { Column( modifier = Modifier @@ -323,7 +324,7 @@ fun CalendarMonthView( }, sharedTransitionScope = sharedScope, animatedVisibilityScope = this@AnimatedContent, - modifier = Modifier.graphicsLayer { this.alpha = crossFadeAlpha } + modifier = Modifier.alpha(crossFadeAlpha) ) } } @@ -584,8 +585,6 @@ private fun BottomCardArea( animationSpec = tween(350, delayMillis = 100, easing = FastOutSlowInEasing), label = "bottomCardSlide" ) - val slideOffsetY = with(density) { (slideProgress * 200).dp.toPx() } - // 延迟一帧显示 BottomCard,避免 AnimatedGif 和 lunar 计算阻塞首帧 var hasLoaded by remember { mutableStateOf(false) } LaunchedEffect(Unit) { @@ -609,10 +608,8 @@ private fun BottomCardArea( onExpandDragEnd = { viewModel.onExpandDragEnd() }, dragRangePx = dragRangePx, modifier = modifier - .graphicsLayer { - translationY = slideOffsetY - this.alpha = 1f - slideProgress - } + .offset(y = with(density) { (slideProgress * 200).dp }) + .alpha(1f - slideProgress) ) } } diff --git a/core/src/main/kotlin/plus/rua/project/ui/CalendarPager.kt b/core/src/main/kotlin/plus/rua/project/ui/CalendarPager.kt index 6388821..73b8a1b 100644 --- a/core/src/main/kotlin/plus/rua/project/ui/CalendarPager.kt +++ b/core/src/main/kotlin/plus/rua/project/ui/CalendarPager.kt @@ -11,7 +11,7 @@ import androidx.compose.runtime.remember import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.snapshotFlow import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.graphicsLayer +import androidx.compose.ui.draw.alpha import kotlinx.coroutines.flow.drop import kotlinx.coroutines.launch import kotlinx.datetime.LocalDate @@ -117,7 +117,7 @@ fun CalendarPager( shiftKindAt = shiftKindAt, showLegalHoliday = showLegalHoliday, onRowHeightMeasured = onRowHeightMeasured, - modifier = Modifier.graphicsLayer { this.alpha = alpha } + modifier = Modifier.alpha(alpha) ) } } \ No newline at end of file diff --git a/core/src/main/kotlin/plus/rua/project/ui/WeekPager.kt b/core/src/main/kotlin/plus/rua/project/ui/WeekPager.kt index 42d4652..602e402 100644 --- a/core/src/main/kotlin/plus/rua/project/ui/WeekPager.kt +++ b/core/src/main/kotlin/plus/rua/project/ui/WeekPager.kt @@ -13,7 +13,7 @@ import androidx.compose.runtime.getValue import androidx.compose.runtime.remember import androidx.compose.runtime.snapshotFlow import androidx.compose.ui.Modifier -import androidx.compose.ui.graphics.graphicsLayer +import androidx.compose.ui.draw.alpha import androidx.compose.ui.unit.dp import kotlinx.coroutines.flow.drop import kotlinx.datetime.DatePeriod @@ -87,7 +87,7 @@ fun WeekPager( val weekMonday = pageToWeekMonday(page, initialWeekMonday) Row( modifier = Modifier - .graphicsLayer { this.alpha = alpha } + .alpha(alpha) .fillMaxWidth() .padding(vertical = ROW_PADDING_DP.dp) ) {