首页任务选择改为两步式圆角弹层;新增按钮深色高对比;统计目标文案与热力图自适应

This commit is contained in:
XIGE
2026-11-28 07:29:37 +08:00
parent d57de2d3f5
commit ec21b3cc0a
14 changed files with 330 additions and 40 deletions

View File

@@ -109,7 +109,7 @@ class HeatmapView @JvmOverloads constructor(
private val cellPaint = Paint(Paint.ANTI_ALIAS_FLAG)
private val textPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
textSize = context.spf(9f)
textSize = context.spf(10f)
color = context.col(R.color.text_tertiary)
textAlign = Paint.Align.RIGHT
}
@@ -145,18 +145,19 @@ class HeatmapView @JvmOverloads constructor(
override fun onDraw(canvas: Canvas) {
if (days.isEmpty()) return
val labelW = context.dpf(16f)
val labelW = context.dpf(18f)
val gap = context.dpf(3f)
val top = context.dpf(2f)
val firstMs = Dates.dayStartOfKey(days.first().key)
val startCol = weekdayIndex(firstMs) // 第一列从周一算起,前面留空
val totalCells = startCol + days.size
val cols = (totalCells + 6) / 7
val cellW = (width - labelW - gap * (cols - 1)) / cols
// 高度也要参与取小:宽屏时按宽度算出的格子会把第 7 行挤出可视区
val cellH = (height - top - gap * 6) / 7f
val cell = minOf(cellW.toFloat(), cellH, context.dpf(15f))
val radius = cell * 0.28f
// 格边长同时受宽和高约束,取消过去的 15dp 硬上限:
// 同一屏宽下尽量把格子铺到右侧,不在末尾留大片空白。
val cellH = (height - gap * 6f - context.dpf(8f)) / 7f
val cell = minOf(cellW.toFloat(), cellH).coerceAtLeast(context.dpf(6f))
val top = ((height - (cell * 7f + gap * 6f)) / 2f).coerceAtLeast(context.dpf(2f))
val radius = cell * 0.24f
val rect = RectF()
days.forEachIndexed { i, d ->
@@ -170,11 +171,11 @@ class HeatmapView @JvmOverloads constructor(
canvas.drawRoundRect(rect, radius, radius, cellPaint)
}
// 只在周一/三/五标字,避免七行小字糊在一起
val labels = mapOf(0 to "一", 2 to "三", 4 to "五")
labels.forEach { (row, s) ->
val y = top + row * (cell + gap) + cell * 0.78f
canvas.drawText(s, labelW - context.dpf(4f), y, textPaint)
// 只标一/三/五/日四行,既不漏掉周末,也不会七行小字糊在一起
val baseline = cell / 2f + context.spf(10f) * 0.35f
for (row in listOf(0, 2, 4, 6)) {
val y = top + row * (cell + gap) + baseline
canvas.drawText(Dates.weekdayShort(row), labelW - context.dpf(3f), y, textPaint)
}
}
}