style: 代码清理 — 移除未使用的 import 和变量

- Platform.android.kt: 移除未使用的 kotlinx.coroutines.launch import
  和未使用的 scope 变量
- CalendarMonthView.kt: 移除未使用的 density 变量
- App.kt: 格式化缩进

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
xfy 2026-05-19 18:29:41 +08:00
parent c651a74b9f
commit e5ce11128a
3 changed files with 14 additions and 6 deletions

View File

@ -4,7 +4,6 @@ import android.os.Build
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.rememberCoroutineScope import androidx.compose.runtime.rememberCoroutineScope
import kotlinx.coroutines.CancellationException import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.launch
class AndroidPlatform : Platform { class AndroidPlatform : Platform {
override val name: String = "Android ${Build.VERSION.SDK_INT}" override val name: String = "Android ${Build.VERSION.SDK_INT}"
@ -24,7 +23,7 @@ actual fun PredictiveBackHandler(
onCancel: () -> Unit onCancel: () -> Unit
) { ) {
if (Build.VERSION.SDK_INT >= 34) { if (Build.VERSION.SDK_INT >= 34) {
val scope = rememberCoroutineScope() rememberCoroutineScope()
androidx.activity.compose.PredictiveBackHandler(enabled) { progress -> androidx.activity.compose.PredictiveBackHandler(enabled) { progress ->
try { try {
progress.collect { backEvent -> progress.collect { backEvent ->

View File

@ -57,11 +57,17 @@ fun App() {
if (targetState.ordinal > initialState.ordinal) { if (targetState.ordinal > initialState.ordinal) {
// 正向导航:新页面从右侧滑入覆盖,旧页面略微左移+淡出 // 正向导航:新页面从右侧滑入覆盖,旧页面略微左移+淡出
(slideInHorizontally { it } + fadeIn()) togetherWith (slideInHorizontally { it } + fadeIn()) togetherWith
(slideOutHorizontally { -it / 4 } + fadeOut()) (slideOutHorizontally { -it / 4 } + fadeOut())
} else { } else {
// 返回导航:新页面从左侧滑入,旧页面向右侧滑出 // 返回导航:新页面从左侧滑入,旧页面向右侧滑出
(slideInHorizontally(animationSpec = tween(250)) { -it } + fadeIn(animationSpec = tween(250))) togetherWith (slideInHorizontally(animationSpec = tween(250)) { -it } + fadeIn(
(slideOutHorizontally(animationSpec = tween(250)) { it } + fadeOut(animationSpec = tween(250))) animationSpec = tween(
250
)
)) togetherWith
(slideOutHorizontally(animationSpec = tween(250)) { it } + fadeOut(
animationSpec = tween(250)
))
} }
}, },
modifier = Modifier.fillMaxSize() modifier = Modifier.fillMaxSize()
@ -71,6 +77,7 @@ fun App() {
modifier = Modifier, modifier = Modifier,
onNavigateToAbout = { currentScreen = Screen.About } onNavigateToAbout = { currentScreen = Screen.About }
) )
Screen.About -> { Screen.About -> {
PredictiveBackHandler( PredictiveBackHandler(
enabled = backProgress == 0f, enabled = backProgress == 0f,
@ -88,6 +95,7 @@ fun App() {
} }
) )
} }
Screen.Licenses -> { Screen.Licenses -> {
PredictiveBackHandler( PredictiveBackHandler(
enabled = backProgress == 0f, enabled = backProgress == 0f,

View File

@ -89,7 +89,7 @@ fun CalendarMonthView(
@Suppress("DEPRECATION") // monthNumber 无替代 APIkotlinx-datetime 尚未提供新接口 @Suppress("DEPRECATION") // monthNumber 无替代 APIkotlinx-datetime 尚未提供新接口
val currentMonth by remember { derivedStateOf { viewModel.selectedDate.month.number } } val currentMonth by remember { derivedStateOf { viewModel.selectedDate.month.number } }
val density = LocalDensity.current LocalDensity.current
var rowHeightPx by remember { mutableIntStateOf(0) } var rowHeightPx by remember { mutableIntStateOf(0) }
var screenWidthPx by remember { mutableIntStateOf(0) } var screenWidthPx by remember { mutableIntStateOf(0) }
@ -448,6 +448,7 @@ private fun CalendarPagerArea(
weekMonday weekMonday
} }
} }
else -> weekMonday else -> weekMonday
} }
viewModel.selectDate(date) viewModel.selectDate(date)