style: 移除班次标签背景圆,清理未使用导入
DayCell 中右上角班次("班"/"休")标签去除 surface 背景圆,
文字直接浮在单元格上,视觉更轻量。同步清理
CalendarViewModel、AnimatedGif、BottomCard 的未使用导入,
并格式化 YearGridView 与 CalendarUtilsExtraTest。
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
fae6e3eb72
commit
63da397fc9
@ -19,8 +19,6 @@ import kotlinx.datetime.minus
|
||||
import kotlinx.datetime.number
|
||||
import kotlinx.datetime.plus
|
||||
import kotlinx.datetime.todayIn
|
||||
import plus.rua.project.composeTraceBeginSection
|
||||
import plus.rua.project.composeTraceEndSection
|
||||
import plus.rua.project.ui.COLLAPSE_THRESHOLD
|
||||
import plus.rua.project.ui.FLING_VELOCITY_THRESHOLD_DP
|
||||
import kotlin.time.Clock
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
package plus.rua.project.ui
|
||||
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import com.github.panpf.sketch.AsyncImage
|
||||
|
||||
/**
|
||||
|
||||
@ -22,7 +22,6 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.clip
|
||||
import androidx.compose.ui.input.pointer.pointerInput
|
||||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import kotlinx.datetime.LocalDate
|
||||
@ -52,6 +51,7 @@ fun BottomCard(
|
||||
) {
|
||||
val density = LocalDensity.current
|
||||
val relativeDesc = relativeDayDescription(selectedDate, today)
|
||||
|
||||
@Suppress("DEPRECATION") // monthNumber 无替代 API,kotlinx-datetime 尚未提供新接口
|
||||
val solarDesc = "${selectedDate.monthNumber}月${selectedDate.day}日"
|
||||
val lunarDesc = formatLunarDate(selectedDate)
|
||||
|
||||
@ -5,7 +5,6 @@ import androidx.compose.animation.core.FastOutSlowInEasing
|
||||
import androidx.compose.animation.core.animateFloat
|
||||
import androidx.compose.animation.core.tween
|
||||
import androidx.compose.animation.core.updateTransition
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.interaction.MutableInteractionSource
|
||||
import androidx.compose.foundation.layout.Box
|
||||
@ -274,10 +273,8 @@ fun DayCell(
|
||||
}
|
||||
val shiftLabel = if (shiftKind == ShiftKind.WORK) "班" else "休"
|
||||
val shiftAlpha = if (isCurrentMonth) 1f else 0.38f
|
||||
// 右上角(默认)沿用法定调休视觉:surface 背景 + 彩色文字;
|
||||
// 右上角(默认)无背景,文字直接浮在单元格上;
|
||||
// 左上角(showLegalHoliday=true 时)用实心胶囊,与右上角法定调休区分。
|
||||
val shiftBgColor =
|
||||
if (showLegalHoliday) shiftAccentColor else MaterialTheme.colorScheme.surface
|
||||
val shiftFgColor = if (showLegalHoliday) shiftOnAccentColor else shiftAccentColor
|
||||
val shiftAlignment = if (showLegalHoliday) Alignment.TopStart else Alignment.TopEnd
|
||||
val shiftPadding = if (showLegalHoliday) {
|
||||
@ -295,7 +292,6 @@ fun DayCell(
|
||||
.align(shiftAlignment)
|
||||
.zIndex(1f)
|
||||
.then(shiftPadding)
|
||||
.background(shiftBgColor.copy(alpha = shiftAlpha), CircleShape)
|
||||
.padding(horizontal = 2.dp)
|
||||
)
|
||||
}
|
||||
@ -310,7 +306,6 @@ fun DayCell(
|
||||
.align(Alignment.TopEnd)
|
||||
.zIndex(1f)
|
||||
.padding(top = 1.dp, end = 2.dp)
|
||||
.background(MaterialTheme.colorScheme.surface, CircleShape)
|
||||
.padding(horizontal = 2.dp)
|
||||
)
|
||||
}
|
||||
|
||||
@ -112,7 +112,11 @@ fun YearGridView(
|
||||
listOf(
|
||||
(month to true) to textMeasurer.measure(
|
||||
text,
|
||||
TextStyle(fontSize = 10.sp, color = colors.titleSelected, fontWeight = FontWeight.Bold)
|
||||
TextStyle(
|
||||
fontSize = 10.sp,
|
||||
color = colors.titleSelected,
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
),
|
||||
(month to false) to textMeasurer.measure(
|
||||
text,
|
||||
|
||||
@ -26,35 +26,50 @@ class CalendarUtilsExtraTest {
|
||||
fun calculateWeeksCountForPage_forwardOnePage_returnsNextMonthRows() {
|
||||
// From May 2026, +1 -> June 2026
|
||||
val today = LocalDate(2026, 5, 15)
|
||||
assertEquals(calculateWeeksCount(2026, 6), calculateWeeksCountForPage(START_PAGE + 1, today))
|
||||
assertEquals(
|
||||
calculateWeeksCount(2026, 6),
|
||||
calculateWeeksCountForPage(START_PAGE + 1, today)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun calculateWeeksCountForPage_backwardOnePage_returnsPreviousMonthRows() {
|
||||
// From May 2026, -1 -> April 2026
|
||||
val today = LocalDate(2026, 5, 15)
|
||||
assertEquals(calculateWeeksCount(2026, 4), calculateWeeksCountForPage(START_PAGE - 1, today))
|
||||
assertEquals(
|
||||
calculateWeeksCount(2026, 4),
|
||||
calculateWeeksCountForPage(START_PAGE - 1, today)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun calculateWeeksCountForPage_crossYearForward() {
|
||||
// From December 2026, +1 -> January 2027
|
||||
val today = LocalDate(2026, 12, 10)
|
||||
assertEquals(calculateWeeksCount(2027, 1), calculateWeeksCountForPage(START_PAGE + 1, today))
|
||||
assertEquals(
|
||||
calculateWeeksCount(2027, 1),
|
||||
calculateWeeksCountForPage(START_PAGE + 1, today)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun calculateWeeksCountForPage_crossYearBackward() {
|
||||
// From January 2026, -1 -> December 2025
|
||||
val today = LocalDate(2026, 1, 10)
|
||||
assertEquals(calculateWeeksCount(2025, 12), calculateWeeksCountForPage(START_PAGE - 1, today))
|
||||
assertEquals(
|
||||
calculateWeeksCount(2025, 12),
|
||||
calculateWeeksCountForPage(START_PAGE - 1, today)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun calculateWeeksCountForPage_twelvePagesForward_returnsSameMonthOfNextYear() {
|
||||
val today = LocalDate(2026, 5, 15)
|
||||
// +12 -> May 2027
|
||||
assertEquals(calculateWeeksCount(2027, 5), calculateWeeksCountForPage(START_PAGE + 12, today))
|
||||
assertEquals(
|
||||
calculateWeeksCount(2027, 5),
|
||||
calculateWeeksCountForPage(START_PAGE + 12, today)
|
||||
)
|
||||
}
|
||||
|
||||
// ---- relativeDayDescription ----
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user