diff --git a/DevLog/Resource/Localizable.xcstrings b/DevLog/Resource/Localizable.xcstrings index 97a40473..5de1745e 100644 --- a/DevLog/Resource/Localizable.xcstrings +++ b/DevLog/Resource/Localizable.xcstrings @@ -979,57 +979,6 @@ } } }, - "profile_weekday_fri" : { - "extractionState" : "manual", - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Fri" - } - }, - "ko" : { - "stringUnit" : { - "state" : "translated", - "value" : "금" - } - } - } - }, - "profile_weekday_mon" : { - "extractionState" : "manual", - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Mon" - } - }, - "ko" : { - "stringUnit" : { - "state" : "translated", - "value" : "월" - } - } - } - }, - "profile_weekday_wed" : { - "extractionState" : "manual", - "localizations" : { - "en" : { - "stringUnit" : { - "state" : "translated", - "value" : "Wed" - } - }, - "ko" : { - "stringUnit" : { - "state" : "translated", - "value" : "수" - } - } - } - }, "profile_year" : { "extractionState" : "manual", "localizations" : { diff --git a/DevLog/UI/Profile/HeatmapView.swift b/DevLog/UI/Profile/HeatmapView.swift index 35ac46b3..617d11d5 100644 --- a/DevLog/UI/Profile/HeatmapView.swift +++ b/DevLog/UI/Profile/HeatmapView.swift @@ -21,77 +21,21 @@ struct HeatmapView: View { weekCounts: quarter.months.map(\.weeks.count) ) - HStack(alignment: .top, spacing: 0) { - weekdayLabel(layout: layout) - HStack(alignment: .top, spacing: layout.monthSpacing) { - ForEach(quarter.months) { month in - MonthCompactHeatmapView( - month: month, - maxCount: maxCount, - layout: layout, - selectedActivityKinds: selectedActivityKinds, - selectedDay: selectedDay, - onSelectDay: onSelectDay - ) - } + HStack(alignment: .top, spacing: layout.monthSpacing) { + ForEach(quarter.months) { month in + MonthCompactHeatmapView( + month: month, + maxCount: maxCount, + layout: layout, + selectedActivityKinds: selectedActivityKinds, + selectedDay: selectedDay, + onSelectDay: onSelectDay + ) } } .padding(.vertical, 2) } - @ViewBuilder - private func weekdayLabel(layout: HeatmapLayout) -> some View { - let labels: [Int: String] = [ - 2: String(localized: "profile_weekday_mon"), - 4: String(localized: "profile_weekday_wed"), - 6: String(localized: "profile_weekday_fri") - ] - let orderedWeekdays = Array(1...7) - let labelFontSize = smallestWeekdayLabelFontSize( - labels: Array(labels.values), - layout: layout - ) - - VStack(alignment: .leading, spacing: layout.cellSpacing) { - ForEach(orderedWeekdays, id: \.self) { weekday in - if let label = labels[weekday] { - Text(label) - .font(.system(size: labelFontSize)) - .allowsTightening(true) - .foregroundStyle(.secondary) - .frame( - width: layout.cellSize, - height: layout.cellSize, - alignment: .leading - ) - } else { - Color.clear - .frame( - width: layout.cellSize, - height: layout.cellSize - ) - } - } - } - .padding(.top, layout.weekdayTopPadding) - } - - private func smallestWeekdayLabelFontSize(labels: [String], layout: HeatmapLayout) -> CGFloat { - let captionFont = UIFont.preferredFont(forTextStyle: .caption2) - let availableWidth = max(layout.cellSize, 1) - - let fittedSizes = labels.map { label in - let textWidth = max( - (label as NSString).size(withAttributes: [.font: captionFont]).width, - 1 - ) - let widthRatio = availableWidth / textWidth - return captionFont.pointSize * min(widthRatio, 1) - } - - return max((fittedSizes.min() ?? captionFont.pointSize).rounded(.down), 1) - } - private var availableWidth: CGFloat { // ProfileView의 바깥 가로 패딩(16)과 히트맵 카드 내부 패딩(12)을 합한 값 let horizontalPadding: CGFloat = 16 + 12 @@ -135,18 +79,13 @@ private struct HeatmapLayout { let monthTitleSpacing: CGFloat = 6 init(availableWidth: CGFloat, weekCounts: [Int]) { - let sanitizedWeekCounts = weekCounts.filter { 0 < $0 } - let totalColumns = max(sanitizedWeekCounts.reduce(0, +), 1) - let totalColumnSpacings = sanitizedWeekCounts.reduce(0) { partialResult, count in + let totalColumns = max(weekCounts.reduce(0, +), 1) + let totalColumnSpacings = weekCounts.reduce(0) { partialResult, count in partialResult + max(count - 1, 0) } - let fixedWidth = monthSpacing * CGFloat(max(sanitizedWeekCounts.count - 1, 0)) + let fixedWidth = monthSpacing * CGFloat(max(weekCounts.count - 1, 0)) + cellSpacing * CGFloat(totalColumnSpacings) - cellSize = max(0, availableWidth - fixedWidth) / CGFloat(totalColumns + 1) - } - - var weekdayTopPadding: CGFloat { - cellSize + monthTitleSpacing + cellSize = max(0, availableWidth - fixedWidth) / CGFloat(totalColumns) } var cellCornerRadius: CGFloat {