mycode/myApp/HaruDanim/Shared/Settings.swift
songyc macbook e7868f453c feat(stats): '오늘 기준' 롤링 보기 — 주간→지난 7일·월간→지난 30일 (탭·⑤ 위젯·내보내기)
- 통계 탭: 주간/월간 세그먼트 아래 '지난 7일/30일 단위로 보기' 토글(기기 로컬 stats.rollingWindow)
- StatSpan enum 불변(다짐 진행률 공유) — statsRange 헬퍼·rolling 플래그로 통계 표면만 처리
- 비교 카드 '이전 7일/30일과 비교', 화살표 7/30일 점프, 롤링 월간은 주차별 카드·주 평균 열 제외
- 위젯 ⑤: StatsChartSpan에 last7/last30 추가(소형은 last30→last7 강등), DayMath.rollingRange 공유
- 통계 내보내기: rolling 반영(제목·기간·합계 문구·last7/last30 슬러그)
- -statRolling 검증 인자, 주간·월간 롤링 화면 시뮬 확인

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01NNxA172hNDRpDsJ2qztKPf
2026-08-11 16:44:51 +09:00

162 lines
6.2 KiB
Swift

//
// Settings.swift
// Haru_Danim
//
// , (CLAUDE.md §6.6, §7)
//
import Foundation
enum SettingsKeys {
/// "light" | "dark"
static let theme = "settings.theme"
/// "ko" | "en" | "ja"
static let language = "settings.language"
/// Calendar.weekday (1= ... 7=). 2()
static let weekStartWeekday = "settings.weekStartWeekday"
/// . 0 (00:00)
static let dayStartMinutes = "settings.dayStartMinutes"
/// "latest"( ) | "earliest"( ). latest
static let liveActivityMode = "settings.liveActivityMode"
// Shared/Premium.swift PremiumGate.cacheKey (App Group defaults)
/// . 3
static let gridColumns = "settings.gridColumns"
/// () . 0 =
static let minSessionSeconds = "settings.minSessionSeconds"
/// () ( ). 0 =
static let longSessionAlertHours = "settings.longSessionAlertHours"
/// ( 1~3). AppTab rawValue
static let visibleTabs = "settings.visibleTabs"
/// . GoalCardStyle rawValue ("perQuest" | "combined")
static let goalCardStyle = "settings.goalCardStyle"
/// iPhone . NavStyle rawValue ("tabBar" | "radial"). ()
static let navStyle = "settings.navStyle"
/// . AppTab rawValue . ()
static let radialTabOrder = "settings.radialTabOrder"
/// FAB ' ' . AppTab rawValue, = . ()
static let radialDoubleTapTab = "settings.radialDoubleTapTab"
/// / ' 7/30' (1.4).
/// (standard defaults)
static let statsRollingWindow = "stats.rollingWindow"
}
/// iPhone (iPad·Mac , )
enum NavStyle: String, CaseIterable, Identifiable {
/// ( + )
case tabBar
/// (Glass Bubbles) rawValue radial
case radial
var id: String { rawValue }
var label: String {
switch self {
case .tabBar: return String(localized: "기본 하단 탭 바")
case .radial: return String(localized: "글래스 버블 메뉴")
}
}
}
/// ( )
enum GoalCardStyle: String, CaseIterable, Identifiable {
/// ( 3) //
case perQuest
/// // ()
case combined
var id: String { rawValue }
var label: String {
switch self {
case .perQuest: return String(localized: "다짐별로 각각")
case .combined: return String(localized: "전체 다짐 합산")
}
}
}
enum TabBarConfig {
/// : · · (+)
static let defaultVisibleTabs = "main,action,history"
static let maxVisible = 3
static let minVisible = 1
}
/// ()
enum LongSessionAlertOption {
static let choices: [(hours: Int, label: String)] = [
(0, String(localized: "사용 안 함")),
(1, String(localized: "1시간")),
(2, String(localized: "2시간")),
(3, String(localized: "3시간")),
(6, String(localized: "6시간")),
(12, String(localized: "12시간")),
]
}
/// ()
enum MinSessionOption {
static let choices: [(seconds: Int, label: String)] = [
(0, String(localized: "사용 안 함")),
(3, String(localized: "3초")),
(5, String(localized: "5초")),
(10, String(localized: "10초")),
(30, String(localized: "30초")),
(60, String(localized: "1분")),
]
}
enum LiveActivityMode: String, CaseIterable, Identifiable {
case latest
case earliest
var id: String { rawValue }
var label: String {
switch self {
case .latest: return String(localized: "가장 나중에 시작한 행동")
case .earliest: return String(localized: "가장 먼저 시작한 행동")
}
}
}
enum AppLanguage: String, CaseIterable, Identifiable {
case ko, en, ja
var id: String { rawValue }
var label: String {
switch self {
case .ko: return "한국어"
case .en: return "English"
case .ja: return "日本語"
}
}
}
// (FreeLimits) Shared/Premium.swift (· )
///
struct TrackingSettings {
var weekStartWeekday: Int
var dayStartMinutes: Int
static func current() -> TrackingSettings {
// App Group (· ), standard
let group = AppGroup.defaults
let standard = UserDefaults.standard
func intValue(_ key: String, default defaultValue: Int) -> Int {
(group.object(forKey: key) ?? standard.object(forKey: key)) as? Int ?? defaultValue
}
return TrackingSettings(
weekStartWeekday: intValue(SettingsKeys.weekStartWeekday, default: 2),
dayStartMinutes: intValue(SettingsKeys.dayStartMinutes, default: 0)
)
}
var calendar: Calendar {
var cal = Calendar.current
cal.firstWeekday = weekStartWeekday
return cal
}
}