根据提供的code differences信息,由于没有具体的代码变更内容,我将生成一个通用的commit message模板:
``` docs(readme): 更新文档说明 - 添加了项目使用指南 - 完善了API接口说明 - 修正了一些文字错误 ``` 注:由于未提供具体的代码差异信息,以上为示例格式。请提供具体的代码变更内容以便生成准确的commit message。
This commit is contained in:
@@ -46,8 +46,8 @@ struct HomeCalendarCard: View {
|
||||
return (0..<7).compactMap { calendar.date(byAdding: .day, value: $0, to: monday) }
|
||||
}
|
||||
|
||||
/// 本月有记录的天数(指标/报告/日记/症状任一)。
|
||||
private var daysWithRecordsThisMonth: Int {
|
||||
/// 本月有记录的天数(指标/报告/日记/症状任一)。传入已构建好的 data,避免逐天重建。
|
||||
private func daysWithRecordsThisMonth(_ data: CalendarData) -> Int {
|
||||
guard let interval = calendar.dateInterval(of: .month, for: .now) else { return 0 }
|
||||
let count = calendar.range(of: .day, in: .month, for: .now)?.count ?? 30
|
||||
var n = 0
|
||||
@@ -62,9 +62,11 @@ struct HomeCalendarCard: View {
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 12) {
|
||||
header
|
||||
weekStrip
|
||||
// CalendarData 一次性构建,供周条 + 本月摘要复用 —— 杜绝逐格(7)+ 逐天(~30)反复全表重建。
|
||||
let calData = data
|
||||
return VStack(alignment: .leading, spacing: 12) {
|
||||
header(calData)
|
||||
weekStrip(calData)
|
||||
}
|
||||
.padding(14)
|
||||
.frame(maxWidth: .infinity, alignment: .leading)
|
||||
@@ -77,14 +79,14 @@ struct HomeCalendarCard: View {
|
||||
}
|
||||
}
|
||||
|
||||
private var header: some View {
|
||||
private func header(_ data: CalendarData) -> some View {
|
||||
HStack(alignment: .firstTextBaseline) {
|
||||
Text("健康日历")
|
||||
.font(.tjH2())
|
||||
.foregroundStyle(Tj.Palette.text)
|
||||
Spacer()
|
||||
HStack(spacing: 3) {
|
||||
Text(summaryLine)
|
||||
Text(summaryLine(data))
|
||||
.font(.tjScaled( 12))
|
||||
.foregroundStyle(Tj.Palette.text3)
|
||||
Image(systemName: "chevron.right")
|
||||
@@ -94,20 +96,20 @@ struct HomeCalendarCard: View {
|
||||
}
|
||||
}
|
||||
|
||||
private var summaryLine: String {
|
||||
let n = daysWithRecordsThisMonth
|
||||
private func summaryLine(_ data: CalendarData) -> String {
|
||||
let n = daysWithRecordsThisMonth(data)
|
||||
return n > 0 ? String(appLoc: "本月 \(n) 天有记录") : String(appLoc: "本月暂无记录")
|
||||
}
|
||||
|
||||
private var weekStrip: some View {
|
||||
private func weekStrip(_ data: CalendarData) -> some View {
|
||||
HStack(spacing: 6) {
|
||||
ForEach(weekDays, id: \.self) { day in
|
||||
dayCell(day)
|
||||
dayCell(day, data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func dayCell(_ day: Date) -> some View {
|
||||
private func dayCell(_ day: Date, _ data: CalendarData) -> some View {
|
||||
let marks = data.marks(for: day, calendar: calendar)
|
||||
let ranges = data.ranges(touching: day, calendar: calendar)
|
||||
let isToday = calendar.isDateInToday(day)
|
||||
|
||||
Reference in New Issue
Block a user