Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 26 additions & 5 deletions Sources/PokeTokenBar/UI/PopoverView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ struct PopoverView: View {
.font(.caption)
.monospacedDigit()
Spacer()
(Text("\(l.reset) ") + Text(end, style: .relative))
(Text("\(l.reset) ") + Text(end, style: .relative) + resetClockSuffix(end))
.font(.caption)
.foregroundStyle(.tertiary)
}
Expand Down Expand Up @@ -445,7 +445,7 @@ struct PopoverView: View {
.monospacedDigit()
.foregroundStyle(limitColor(utilization))
if let reset = bucket.resetDate {
Text("· \(reset, style: .relative)")
resetLabel(reset)
.font(.caption)
.foregroundStyle(.tertiary)
}
Expand Down Expand Up @@ -513,6 +513,27 @@ struct PopoverView: View {
return store.limitDisplayMode == .remaining ? l.percentRemaining(text) : text
}

/// 리셋이 이 창 안(≤ 6h)이거나 오늘이면 벽시계 접미사를 "HH:mm" 만으로 짧게 낸다.
/// 그 밖(주간 한도 등 며칠 뒤)이면 요일·일자를 붙여 "HH:mm" 만으로 생기는 오해를 막는다.
/// 어느 쪽이든 접미사는 항상 붙는다 — 프로바이더 리터럴 분기 없이 리셋 근접도만 본다
/// (확장 규약: 플랫폼 종속 분기 금지).
private static let resetClockWindow: TimeInterval = 6 * 3600

/// 카운트다운 뒤에 붙는 절대 리셋 시각 " (…)". 오늘 안이거나 ≤ 6h 면 시:분만,
/// 며칠 뒤(주간 한도 등)면 요일·일자까지 — "in 2 days, 9 hr" 만으론 언제 풀리는지 감이 안 와서다.
/// 요일명은 팝오버 로케일(companion.language)로 현지화하고, 시각은 항상 24시간 표기.
private func resetClockSuffix(_ reset: Date) -> Text {
let f = DateFormatter()
f.locale = companion.language.displayLocale
let nearby = Calendar.current.isDateInToday(reset)
|| reset.timeIntervalSinceNow <= Self.resetClockWindow
f.setLocalizedDateFormatFromTemplate(nearby ? "HHmm" : "EEEEdHHmm")
return Text(" (\(f.string(from: reset)))")
}
private func resetLabel(_ reset: Date) -> Text {
Text("· \(reset, style: .relative)") + resetClockSuffix(reset)
}

@ViewBuilder
private func limitRow(name: String, window: LimitWindow?) -> some View {
if let window, let utilization = window.utilization {
Expand All @@ -526,7 +547,7 @@ struct PopoverView: View {
.monospacedDigit()
.foregroundStyle(limitColor(utilization))
if let reset = window.resetDate {
Text("· \(reset, style: .relative)")
resetLabel(reset)
.font(.caption)
.foregroundStyle(.tertiary)
}
Expand Down Expand Up @@ -665,7 +686,7 @@ struct PopoverView: View {
.monospacedDigit()
.foregroundStyle(limitColor(utilization))
if let reset = window.resetDate {
Text("· \(reset, style: .relative)")
resetLabel(reset)
.font(.caption)
.foregroundStyle(.tertiary)
}
Expand Down Expand Up @@ -694,7 +715,7 @@ struct PopoverView: View {
.font(.callout)
.monospacedDigit()
.foregroundStyle(limitColor(utilization))
Text("· \(limit.resetDate, style: .relative)")
resetLabel(limit.resetDate)
.font(.caption)
.foregroundStyle(.tertiary)
}
Expand Down