fix(周视图): 圆径按内容高度适配,修"上露星期、下漏圆点" #6

用户反馈:周视图圆的上沿包进了"一"(星期标签),下沿却把事件点漏在外面。

## 根因
周条加了星期标签后,内容实际高度约 147px:
  星期 10px字号 ≈ 28
  日期框 24vp    ≈ 72
  农历 9px字号   ≈ 27
  事件点 3.5vp   ≈ 11
  3 个间隙       ≈ 9
  合计           ≈ 147px

而圆固定 46vp = 138px ⇒ **内容比圆高 9px**。
Stack 的 alignContent 默认居中,导致内容上下对称溢出:
上面露出星期标签,下面漏掉事件点。

## 修法
圆径按内容取,不搞一刀切:
  · 周条(showWeekLabel=true,内容≈147px)→ 54vp(≈162px)
  · 月视图(无星期标签,内容≈118px)      → 46vp(≈138px)
同时 Stack 显式 alignContent(Alignment.Center),避免内容高于圆时对齐跑偏。

## 验证(真机 dump 实测)
  圆范围 y 495~664(169px)
  星期"一"  y 497~534  圆内 ✓
  日期"2"   y 537~612  圆内 ✓
  农历"廿四" y 615~648  圆内 ✓
  事件点×7  y 651~662  圆内 ✓

## 教训
Stack 里"固定尺寸的装饰元素"(圆)+ "不定高的内容"(文字块)组合时,
圆径必须 >= 内容高度,否则内容一定溢出。
这类问题看截图不容易发现(因为溢出部分常被裁掉或重叠),
**必须 dump 出两者的 bounds 做数值比对**才准。
This commit is contained in:
2026-11-02 22:08:29 +08:00
parent 2cc3b1ba42
commit ddaf41fee8
+11 -5
View File
@@ -3311,20 +3311,26 @@ struct Index {
*/
@Builder
dayCellCircle(cell: MonthCell, showWeekLabel: boolean = false) {
Stack() {
// 显式 Center:Stack 默认虽也居中,但内容高于圆时对齐行为容易偏,
// 写死更可控(周条曾是"上露星期、下漏圆点")。
Stack({ alignContent: Alignment.Center }) {
// ⭐ TODAY_RING 底层圆:选中用实蓝,今天用淡蓝,尺寸一致。
// 原来今天只在日期数字上贴了个 24×24 的小圈,选中却是 46vp 大圆,
// 同一天"选不选中"看起来像两种东西。现在两者尺寸统一。
// ⭐ RING_FIT 圆径必须**按内容高度**取,不能一刀切。
// 周条比月历多一行"星期标签",内容约 147px;圆固定 46vp(138px) 时
// 就会上露"一"、下漏事件点。周条用 54vp(≈162px) 才包得住。
// 月视图没有星期标签、内容约 118px,46vp 刚好。
if (cell.dateMs === this.selectedDate) {
Column()
.width(this.wideLayout ? 40 : 46)
.height(this.wideLayout ? 40 : 46)
.width(showWeekLabel ? 54 : (this.wideLayout ? 40 : 46))
.height(showWeekLabel ? 54 : (this.wideLayout ? 40 : 46))
.borderRadius('50%')
.backgroundColor($r('app.color.selected_bg'))
} else if (cell.isToday) {
Column()
.width(this.wideLayout ? 40 : 46)
.height(this.wideLayout ? 40 : 46)
.width(showWeekLabel ? 54 : (this.wideLayout ? 40 : 46))
.height(showWeekLabel ? 54 : (this.wideLayout ? 40 : 46))
.borderRadius('50%')
.backgroundColor($r('app.color.today_bg'))
}