Skip to content

Commit 40c4d12

Browse files
authored
[#414] 앱 쪽 히트맵에서 요일 레이블을 제거한다 (#429)
* ui: 요일 라벨 제거 * chore: l10n 키 제거 * refactor: 히트맵 주차 수 계산에서 불필요한 필터링 제거
1 parent 0e198c3 commit 40c4d12

2 files changed

Lines changed: 14 additions & 126 deletions

File tree

DevLog/Resource/Localizable.xcstrings

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -979,57 +979,6 @@
979979
}
980980
}
981981
},
982-
"profile_weekday_fri" : {
983-
"extractionState" : "manual",
984-
"localizations" : {
985-
"en" : {
986-
"stringUnit" : {
987-
"state" : "translated",
988-
"value" : "Fri"
989-
}
990-
},
991-
"ko" : {
992-
"stringUnit" : {
993-
"state" : "translated",
994-
"value" : "금"
995-
}
996-
}
997-
}
998-
},
999-
"profile_weekday_mon" : {
1000-
"extractionState" : "manual",
1001-
"localizations" : {
1002-
"en" : {
1003-
"stringUnit" : {
1004-
"state" : "translated",
1005-
"value" : "Mon"
1006-
}
1007-
},
1008-
"ko" : {
1009-
"stringUnit" : {
1010-
"state" : "translated",
1011-
"value" : "월"
1012-
}
1013-
}
1014-
}
1015-
},
1016-
"profile_weekday_wed" : {
1017-
"extractionState" : "manual",
1018-
"localizations" : {
1019-
"en" : {
1020-
"stringUnit" : {
1021-
"state" : "translated",
1022-
"value" : "Wed"
1023-
}
1024-
},
1025-
"ko" : {
1026-
"stringUnit" : {
1027-
"state" : "translated",
1028-
"value" : "수"
1029-
}
1030-
}
1031-
}
1032-
},
1033982
"profile_year" : {
1034983
"extractionState" : "manual",
1035984
"localizations" : {

DevLog/UI/Profile/HeatmapView.swift

Lines changed: 14 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -21,77 +21,21 @@ struct HeatmapView: View {
2121
weekCounts: quarter.months.map(\.weeks.count)
2222
)
2323

24-
HStack(alignment: .top, spacing: 0) {
25-
weekdayLabel(layout: layout)
26-
HStack(alignment: .top, spacing: layout.monthSpacing) {
27-
ForEach(quarter.months) { month in
28-
MonthCompactHeatmapView(
29-
month: month,
30-
maxCount: maxCount,
31-
layout: layout,
32-
selectedActivityKinds: selectedActivityKinds,
33-
selectedDay: selectedDay,
34-
onSelectDay: onSelectDay
35-
)
36-
}
24+
HStack(alignment: .top, spacing: layout.monthSpacing) {
25+
ForEach(quarter.months) { month in
26+
MonthCompactHeatmapView(
27+
month: month,
28+
maxCount: maxCount,
29+
layout: layout,
30+
selectedActivityKinds: selectedActivityKinds,
31+
selectedDay: selectedDay,
32+
onSelectDay: onSelectDay
33+
)
3734
}
3835
}
3936
.padding(.vertical, 2)
4037
}
4138

42-
@ViewBuilder
43-
private func weekdayLabel(layout: HeatmapLayout) -> some View {
44-
let labels: [Int: String] = [
45-
2: String(localized: "profile_weekday_mon"),
46-
4: String(localized: "profile_weekday_wed"),
47-
6: String(localized: "profile_weekday_fri")
48-
]
49-
let orderedWeekdays = Array(1...7)
50-
let labelFontSize = smallestWeekdayLabelFontSize(
51-
labels: Array(labels.values),
52-
layout: layout
53-
)
54-
55-
VStack(alignment: .leading, spacing: layout.cellSpacing) {
56-
ForEach(orderedWeekdays, id: \.self) { weekday in
57-
if let label = labels[weekday] {
58-
Text(label)
59-
.font(.system(size: labelFontSize))
60-
.allowsTightening(true)
61-
.foregroundStyle(.secondary)
62-
.frame(
63-
width: layout.cellSize,
64-
height: layout.cellSize,
65-
alignment: .leading
66-
)
67-
} else {
68-
Color.clear
69-
.frame(
70-
width: layout.cellSize,
71-
height: layout.cellSize
72-
)
73-
}
74-
}
75-
}
76-
.padding(.top, layout.weekdayTopPadding)
77-
}
78-
79-
private func smallestWeekdayLabelFontSize(labels: [String], layout: HeatmapLayout) -> CGFloat {
80-
let captionFont = UIFont.preferredFont(forTextStyle: .caption2)
81-
let availableWidth = max(layout.cellSize, 1)
82-
83-
let fittedSizes = labels.map { label in
84-
let textWidth = max(
85-
(label as NSString).size(withAttributes: [.font: captionFont]).width,
86-
1
87-
)
88-
let widthRatio = availableWidth / textWidth
89-
return captionFont.pointSize * min(widthRatio, 1)
90-
}
91-
92-
return max((fittedSizes.min() ?? captionFont.pointSize).rounded(.down), 1)
93-
}
94-
9539
private var availableWidth: CGFloat {
9640
// ProfileView의 바깥 가로 패딩(16)과 히트맵 카드 내부 패딩(12)을 합한 값
9741
let horizontalPadding: CGFloat = 16 + 12
@@ -135,18 +79,13 @@ private struct HeatmapLayout {
13579
let monthTitleSpacing: CGFloat = 6
13680

13781
init(availableWidth: CGFloat, weekCounts: [Int]) {
138-
let sanitizedWeekCounts = weekCounts.filter { 0 < $0 }
139-
let totalColumns = max(sanitizedWeekCounts.reduce(0, +), 1)
140-
let totalColumnSpacings = sanitizedWeekCounts.reduce(0) { partialResult, count in
82+
let totalColumns = max(weekCounts.reduce(0, +), 1)
83+
let totalColumnSpacings = weekCounts.reduce(0) { partialResult, count in
14184
partialResult + max(count - 1, 0)
14285
}
143-
let fixedWidth = monthSpacing * CGFloat(max(sanitizedWeekCounts.count - 1, 0))
86+
let fixedWidth = monthSpacing * CGFloat(max(weekCounts.count - 1, 0))
14487
+ cellSpacing * CGFloat(totalColumnSpacings)
145-
cellSize = max(0, availableWidth - fixedWidth) / CGFloat(totalColumns + 1)
146-
}
147-
148-
var weekdayTopPadding: CGFloat {
149-
cellSize + monthTitleSpacing
88+
cellSize = max(0, availableWidth - fixedWidth) / CGFloat(totalColumns)
15089
}
15190

15291
var cellCornerRadius: CGFloat {

0 commit comments

Comments
 (0)