Widget configuration — delete the multi-slot pickers entirely -------------------------------------------------------------- Every home/lock widget exposed 3–4 separate entity slots (action1–4, goal1–4, quest1–4, secondGoal) regardless of family, cluttering the long-press config screen with slots a given size never renders. Replaced that with a single anchor selection per widget that self-configures by size family (the view already prefixes by family; providers now build the candidate list from one selection): - ActionRun (A): one anchor Action → fills following actions (main-tab order) up to the family's count. - GoalBars (B): one anchor Goal → fills following goals up to the count. - QuestRing (C): one Goal → renders that goal's quests, sized by family. - GoalQuestGrid (D): one Goal (dropped secondGoal) → its quests; large now shows up to 16 rings of the single goal. - Stats: one anchor Action → plus following actions on the same chart. New WidgetStore helpers actionsFrom/goalsFrom/questsOfGoal centralize the "anchor + following / goal's quests" logic; the None sentinel is ignored gracefully so clearing falls back to sensible defaults. No @Model, timeline, or reload/sync logic touched. Floating radial menu (iPhone) — performance + glassmorphism ----------------------------------------------------------- Each of the ~7 icons and ~7 labels had its own .ultraThinMaterial, so the expanded menu ran ~15 separate blur passes that re-rendered every frame as content scrolled behind them — the source of the progressive frame drops. Now a single unified glass dome (one DomeShape filled with .ultraThinMaterial) sits behind the whole fan and is the only blur; icons are lightweight symbols (only the current tab gets a solid green chip) and labels are plain text with a legibility shadow. The dome is styled per glassmorphism: a soft white top-to-bottom gradient overlay, a thin white.opacity(0.2) border, and a soft shadow; the FAB gets the same gradient/border treatment. Animation is snappier and lighter: the per-item implicit spring animations with staggered delays are gone — one withAnimation(.easeOut ~0.24 open / .easeIn ~0.18 close) drives the whole fan, and the press style uses a short easeOut instead of a spring. Verified in the simulator: build succeeds; the expanded menu renders the single glass dome with all tabs and no crash (light/dark, expanded/collapsed); the refactored C/D widgets render from a single selected goal, self-sized by family. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_013yKDMhuF39GVYy3FMcGHh7
189 lines
7.7 KiB
Swift
189 lines
7.7 KiB
Swift
//
|
|
// WidgetPreviewScreen.swift
|
|
// Haru_Danim
|
|
//
|
|
// DEBUG 전용: 위젯 뷰들을 앱 안에서 실제 크기로 렌더링해 검증하는 화면.
|
|
// 런치 인자 `-widgetPreview YES`(홈 위젯) / `-widgetPreview lock`(잠금화면)으로 진입.
|
|
// (시뮬레이터 홈 화면에 위젯을 자동으로 추가할 방법이 없어 만든 검증 도구)
|
|
//
|
|
|
|
#if DEBUG
|
|
import SwiftUI
|
|
import WidgetKit
|
|
|
|
struct WidgetPreviewScreen: View {
|
|
let showLock: Bool
|
|
|
|
@State private var actionEntry: ActionRunEntry?
|
|
@State private var goalBarsEntry: GoalBarsEntry?
|
|
@State private var questRingEntry: QuestRingEntry?
|
|
@State private var gridEntry: GoalQuestGridEntry?
|
|
@State private var statsEntrySmall: StatsChartEntry?
|
|
@State private var statsEntryMedium: StatsChartEntry?
|
|
@State private var lockEntries: [(String, LockGoalEntry)] = []
|
|
|
|
var body: some View {
|
|
ScrollViewReader { proxy in
|
|
ScrollView {
|
|
VStack(alignment: .leading, spacing: 16) {
|
|
if showLock {
|
|
lockSection
|
|
} else {
|
|
homeSection
|
|
}
|
|
}
|
|
.padding()
|
|
}
|
|
.background {
|
|
Color(white: 0.9).ignoresSafeArea()
|
|
}
|
|
.onAppear {
|
|
load()
|
|
// -widgetPreviewScroll B|C|D|S → 해당 섹션으로 자동 스크롤
|
|
if let anchor = UserDefaults.standard.string(forKey: "widgetPreviewScroll") {
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + 1.5) {
|
|
withAnimation { proxy.scrollTo(anchor, anchor: .top) }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private func load() {
|
|
// -premium 런치 인자가 PremiumGate 캐시에 반영되도록 매니저를 먼저 초기화
|
|
_ = PremiumManager.shared
|
|
if showLock {
|
|
var gauge = LockGoalConfigIntent()
|
|
gauge.style = .gauge
|
|
var number = LockGoalConfigIntent()
|
|
number.style = .number
|
|
var dots = LockGoalConfigIntent()
|
|
dots.style = .dots
|
|
lockEntries = [
|
|
("gauge", LockGoalProvider.makeEntry(gauge)),
|
|
("number", LockGoalProvider.makeEntry(number)),
|
|
("dots", LockGoalProvider.makeEntry(dots)),
|
|
]
|
|
} else {
|
|
actionEntry = ActionRunProvider.makeEntry(ActionRunConfigIntent())
|
|
goalBarsEntry = GoalBarsProvider.makeEntry(GoalBarsConfigIntent())
|
|
questRingEntry = QuestRingProvider.makeEntry(QuestRingConfigIntent())
|
|
gridEntry = GoalQuestGridProvider.makeEntry(GoalQuestGridConfigIntent())
|
|
let statsConfig = StatsChartConfigIntent()
|
|
statsEntrySmall = StatsChartProvider.makeEntry(statsConfig, family: .systemSmall)
|
|
statsEntryMedium = StatsChartProvider.makeEntry(statsConfig, family: .systemMedium)
|
|
}
|
|
}
|
|
|
|
// MARK: 홈 위젯
|
|
|
|
@ViewBuilder
|
|
private var homeSection: some View {
|
|
if let entry = actionEntry {
|
|
row("A 행동 실행 · 소형/중형") {
|
|
widgetBox(.systemSmall) { ActionRunWidgetView(previewFamily: .systemSmall, entry: entry) }
|
|
widgetBox(.systemMedium) { ActionRunWidgetView(previewFamily: .systemMedium, entry: entry) }
|
|
}
|
|
row("A 행동 실행 · 대형") {
|
|
widgetBox(.systemLarge) { ActionRunWidgetView(previewFamily: .systemLarge, entry: entry) }
|
|
}
|
|
}
|
|
if let entry = goalBarsEntry {
|
|
row("B 목표 진행률 · 소형/중형") {
|
|
widgetBox(.systemSmall) { GoalBarsWidgetView(previewFamily: .systemSmall, entry: entry) }
|
|
widgetBox(.systemMedium) { GoalBarsWidgetView(previewFamily: .systemMedium, entry: entry) }
|
|
}
|
|
.id("B")
|
|
}
|
|
if let entry = questRingEntry {
|
|
row("C 다짐 진행률 · 소형/중형") {
|
|
widgetBox(.systemSmall) { QuestRingWidgetView(previewFamily: .systemSmall, entry: entry) }
|
|
widgetBox(.systemMedium) { QuestRingWidgetView(previewFamily: .systemMedium, entry: entry) }
|
|
}
|
|
.id("C")
|
|
}
|
|
if let entry = gridEntry {
|
|
row("D 다짐 현황 · 소형/중형") {
|
|
widgetBox(.systemSmall) { GoalQuestGridWidgetView(previewFamily: .systemSmall, entry: entry) }
|
|
widgetBox(.systemMedium) { GoalQuestGridWidgetView(previewFamily: .systemMedium, entry: entry) }
|
|
}
|
|
.id("D")
|
|
row("D 다짐 현황 · 대형") {
|
|
widgetBox(.systemLarge) { GoalQuestGridWidgetView(previewFamily: .systemLarge, entry: entry) }
|
|
}
|
|
}
|
|
if let small = statsEntrySmall, let medium = statsEntryMedium {
|
|
row("통계 · 소형/중형") {
|
|
widgetBox(.systemSmall) { StatsChartWidgetView(previewFamily: .systemSmall, entry: small) }
|
|
widgetBox(.systemMedium) { StatsChartWidgetView(previewFamily: .systemMedium, entry: medium) }
|
|
}
|
|
.id("S")
|
|
}
|
|
}
|
|
|
|
// MARK: 잠금화면 위젯
|
|
|
|
@ViewBuilder
|
|
private var lockSection: some View {
|
|
ForEach(lockEntries, id: \.0) { name, entry in
|
|
row("잠금화면 · \(name)") {
|
|
ZStack {
|
|
Color.black
|
|
LockGoalWidgetView(previewFamily: .accessoryCircular, entry: entry)
|
|
.foregroundStyle(.white)
|
|
}
|
|
.frame(width: 72, height: 72)
|
|
.clipShape(Circle())
|
|
ZStack {
|
|
Color.black
|
|
LockGoalWidgetView(previewFamily: .accessoryRectangular, entry: entry)
|
|
.foregroundStyle(.white)
|
|
.padding(6)
|
|
}
|
|
.frame(width: 172, height: 76)
|
|
.clipShape(RoundedRectangle(cornerRadius: 16))
|
|
}
|
|
}
|
|
if let entry = lockEntries.first?.1 {
|
|
row("잠금화면 · inline") {
|
|
ZStack {
|
|
Color.black
|
|
LockGoalWidgetView(previewFamily: .accessoryInline, entry: entry)
|
|
.foregroundStyle(.white)
|
|
}
|
|
.frame(width: 230, height: 32)
|
|
.clipShape(Capsule())
|
|
}
|
|
}
|
|
}
|
|
|
|
// MARK: 레이아웃 헬퍼
|
|
|
|
private func row(_ title: String, @ViewBuilder content: () -> some View) -> some View {
|
|
VStack(alignment: .leading, spacing: 6) {
|
|
Text(title)
|
|
.font(.caption.weight(.semibold))
|
|
.foregroundStyle(.secondary)
|
|
VStack(alignment: .leading, spacing: 12, content: content)
|
|
}
|
|
}
|
|
|
|
private func widgetBox(_ family: WidgetFamily, @ViewBuilder content: () -> some View) -> some View {
|
|
let size: CGSize = switch family {
|
|
case .systemMedium: CGSize(width: 338, height: 158)
|
|
case .systemLarge: CGSize(width: 338, height: 354)
|
|
default: CGSize(width: 158, height: 158)
|
|
}
|
|
// containerBackground는 실제 위젯 컨텍스트 밖에서는 무시되므로
|
|
// 미리보기 박스가 앱 테마 배경/컬러 스킴을 직접 재현한다
|
|
// contentMarginsDisabled 적용 후에는 위젯 뷰가 여백을 스스로 관리한다
|
|
return content()
|
|
.frame(width: size.width, height: size.height)
|
|
.background(AppTheme.background)
|
|
.environment(\.colorScheme, WidgetAppearance.appScheme)
|
|
.clipShape(RoundedRectangle(cornerRadius: 22, style: .continuous))
|
|
.shadow(color: .black.opacity(0.08), radius: 6, y: 2)
|
|
}
|
|
}
|
|
#endif
|