feat: FAB 菜单添加"显示调休"切换,修复个人排班标记样式

- CalendarViewModel 新增 toggleShowLegalHoliday() 方法
- FAB 菜单新增"显示调休"选项,选中高亮反馈开关状态
- DayCell 修复 showLegalHoliday=true 时个人排班标记样式:
  从"浅色背景+浅色文字"改为"accent 色实心胶囊+白色文字"
  默认模式(showLegalHoliday=false)恢复为无背景、直接浮于单元格

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
xfy 2026-05-24 19:57:43 +08:00
parent 8e65ae6f94
commit 7f639f6c24
3 changed files with 29 additions and 2 deletions

View File

@ -186,6 +186,13 @@ class CalendarViewModel(
}
}
/**
* 切换法定调休角标显示
*/
fun toggleShowLegalHoliday() {
_showLegalHoliday.value = !_showLegalHoliday.value
}
/**
* 从年视图选择月份后返回月视图
*/

View File

@ -388,6 +388,19 @@ fun CalendarMonthView(
color = MaterialTheme.colorScheme.outlineVariant,
modifier = Modifier.padding(horizontal = 8.dp)
)
MenuItem(
text = "显示调休",
selected = showLegalHoliday,
onClick = {
isMenuExpanded = false
viewModel.toggleShowLegalHoliday()
}
)
HorizontalDivider(
thickness = 1.dp,
color = MaterialTheme.colorScheme.outlineVariant,
modifier = Modifier.padding(horizontal = 8.dp)
)
MenuItem(
text = "关于",
selected = false,

View File

@ -13,6 +13,7 @@ import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
@ -244,6 +245,12 @@ fun DayCell(
} else {
Modifier.padding(top = 1.dp, end = 2.dp)
}
val shiftBackground = if (showLegalHoliday) {
Modifier.background(
shiftAccentColor.copy(alpha = shiftAlpha),
RoundedCornerShape(4.dp)
)
} else Modifier
Text(
text = shiftLabel,
color = shiftFgColor.copy(alpha = shiftAlpha),
@ -253,9 +260,9 @@ fun DayCell(
modifier = Modifier
.align(shiftAlignment)
.zIndex(1f)
.background(MaterialTheme.colorScheme.background)
.then(shiftBackground)
.then(shiftPadding)
.padding(horizontal = 2.dp)
.padding(horizontal = 3.dp, vertical = 1.dp)
)
}
if (showLegalHoliday && holidayBadge != null) {