From 7eaeae2e2636440f9e3bf12f5a92761e8630060d Mon Sep 17 00:00:00 2001 From: opficdev Date: Sun, 29 Nov 2026 23:04:11 +0900 Subject: [PATCH] =?UTF-8?q?ui:=20=EB=84=93=EC=9D=80=20=EC=B0=BD=EC=9D=98?= =?UTF-8?q?=20=EA=B3=A0=EB=A5=B4=EB=8A=94=20=ED=99=94=EB=A9=B4=EC=9D=84=20?= =?UTF-8?q?=EB=B2=84=ED=8A=BC=20=EC=95=84=EB=9E=98=20=EC=A7=81=EC=A0=91=20?= =?UTF-8?q?=EA=B7=B8=EB=A6=B0=20=ED=8C=90=EC=9C=BC=EB=A1=9C=20=ED=91=9C?= =?UTF-8?q?=EC=8B=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../HomeTab/Sources/Home/HomeFeature.swift | 2 +- .../HomeTab/Sources/Home/HomeView.swift | 10 +- .../Component/CompositionContainer.swift | 102 +++++++++++++----- .../Sources/Extension/View+Sheet.swift | 3 +- .../Sources/Profile/ActivityCard.swift | 6 +- .../Sources/Profile/ProfileView.swift | 6 +- 6 files changed, 89 insertions(+), 40 deletions(-) diff --git a/Application/Presentation/HomeTab/Sources/Home/HomeFeature.swift b/Application/Presentation/HomeTab/Sources/Home/HomeFeature.swift index 96a5ad61..c307f736 100644 --- a/Application/Presentation/HomeTab/Sources/Home/HomeFeature.swift +++ b/Application/Presentation/HomeTab/Sources/Home/HomeFeature.swift @@ -39,7 +39,7 @@ struct HomeFeature { var isTodoCategoryExpanded = false var isNetworkConnected = true var selectedTodoCategory: TodoCategory? - // 홈 제목 줄 아래 보이는 높이, 새로 만들기 팝오버가 화면 밖으로 넘치지 않게 사용 + // 홈 제목 줄 아래 보이는 높이, 새로 만들기 판이 화면 밖으로 넘치지 않게 사용 var visibleHeight = CGFloat.infinity // 새로 만들기 시트 목록 높이, 시트를 내용 높이에 맞추는 데 사용 var contentPickerHeight = CGFloat.zero diff --git a/Application/Presentation/HomeTab/Sources/Home/HomeView.swift b/Application/Presentation/HomeTab/Sources/Home/HomeView.swift index 4ee61c9c..4977c966 100644 --- a/Application/Presentation/HomeTab/Sources/Home/HomeView.swift +++ b/Application/Presentation/HomeTab/Sources/Home/HomeView.swift @@ -112,12 +112,10 @@ public struct HomeView: View { .sharedBackgroundHidden() } } - // 좁은 창은 새로 만들기를 시트로, 칸으로 나눈 화면은 만들기 버튼 옆 팝오버로 표시 - // 버튼 옆으로 붙으면 위쪽이 상태 표시 영역에 가려지므로 버튼 아래로 표시 + // 좁은 창은 새로 만들기를 시트로, 칸으로 나눈 화면은 만들기 버튼 아래 판으로 표시 .compositionPicker( isPresented: $store.showContentPicker, isActive: isSelected, - arrowEdge: .top, maxHeight: min(640, store.visibleHeight) ) { HomeContentPicker(store: store) { store.send(.view(.tapTodoCategory($0))) } @@ -428,7 +426,7 @@ private struct HomeTodoCategoryLink: View { // 새로 만들기 화면 // 위쪽 닫기 버튼과 제목 줄, 작은 제목 아래 구분선으로 나눈 TODO 카테고리와 새 개발 목표 배치 -// 좁은 창은 시트, 사이드바가 있는 iPad 창은 손가락 크기 팝오버, Mac은 Mac 크기 팝오버 모양 +// 좁은 창은 시트, 사이드바가 있는 iPad 창은 손가락 크기 판, Mac은 Mac 크기 판 모양 private struct HomeContentPicker: View { @Environment(\.isiOSAppOnMac) private var isiOSAppOnMac @Environment(\.usesPaneLayout) private var usesPaneLayout @@ -443,7 +441,7 @@ private struct HomeContentPicker: View { VStack(spacing: 0) { if isiOSAppOnMac || usesPaneLayout { - // 팝오버와 Mac은 X 닫기 버튼과 가운데 제목 + // 판과 Mac은 X 닫기 버튼과 가운데 제목 ZStack { Text("home_create_title", bundle: PresentationResources.bundle) .font(isiOSAppOnMac ? .system(size: 14 * scale, weight: .bold) : .adaptive(.headline).bold()) @@ -537,7 +535,7 @@ private struct HomeContentPicker: View { } // 작은 제목 아래 바탕과 테두리 없이 행 사이 구분선으로 나눈 묶음 - // 시트는 이름 앞에서 시작하는 구분선, 팝오버는 행 폭 전체 구분선 + // 시트는 이름 앞에서 시작하는 구분선, 판은 행 폭 전체 구분선 private func section(_ header: Text, @ViewBuilder content: () -> Content) -> some View { VStack(alignment: .leading, spacing: 0) { header diff --git a/Application/Presentation/PresentationShared/Sources/Common/Component/CompositionContainer.swift b/Application/Presentation/PresentationShared/Sources/Common/Component/CompositionContainer.swift index e1992513..7d33cf64 100644 --- a/Application/Presentation/PresentationShared/Sources/Common/Component/CompositionContainer.swift +++ b/Application/Presentation/PresentationShared/Sources/Common/Component/CompositionContainer.swift @@ -96,25 +96,23 @@ public extension View { } // 고르는 화면 - // 좁은 창은 시트로 띄우고, 칸으로 나눈 화면은 compositionPickerAnchor를 붙인 버튼 옆 팝오버로 띄움 - // maxHeight가 없으면 팝오버를 내용 높이에 맞춤 + // 좁은 창은 시트로 띄우고, 칸으로 나눈 화면은 compositionPickerAnchor를 붙인 버튼 아래에 직접 그린 판으로 띄움 + // maxHeight가 없으면 판을 내용 높이에 맞춤 func compositionPicker( isPresented: Binding, isActive: Bool = true, - arrowEdge: Edge? = nil, maxHeight: CGFloat? = nil, @ViewBuilder content: @escaping () -> Content ) -> some View { modifier(CompositionPickerModifier( isPresented: isPresented, isActive: isActive, - arrowEdge: arrowEdge, maxHeight: maxHeight, picker: content )) } - // 바깥의 compositionPicker가 칸으로 나눈 화면에서 띄우는 팝오버를 붙일 버튼 + // 바깥의 compositionPicker가 칸으로 나눈 화면에서 띄우는 판을 붙일 버튼 func compositionPickerAnchor() -> some View { modifier(CompositionPickerAnchorModifier()) } @@ -356,10 +354,9 @@ private struct CompositionSheetModifier - let arrowEdge: Edge? let maxHeight: CGFloat? let content: () -> AnyView } @@ -380,12 +377,11 @@ private struct CompositionPickerModifier: ViewModifier { @State private var layout = LiveLayout() let isPresented: Binding let isActive: Bool - let arrowEdge: Edge? let maxHeight: CGFloat? let picker: () -> Picker func body(content: Content) -> some View { - // 창 폭이 바뀌어 팝오버와 시트를 오가면 같은 상태를 바뀐 쪽에 다시 그리고, 빠지는 쪽의 늦은 닫힘은 거름 + // 창 폭이 바뀌어 판과 시트를 오가면 같은 상태를 바뀐 쪽에 다시 그리고, 빠지는 쪽의 늦은 닫힘은 거름 let layout = layout.update(usesPaneLayout: usesPaneLayout) let sheetBinding = Binding( get: { !layout.usesPaneLayout && isPresented.wrappedValue }, @@ -395,7 +391,7 @@ private struct CompositionPickerModifier: ViewModifier { } } ) - let popoverBinding = Binding( + let panelBinding = Binding( get: { layout.usesPaneLayout && isPresented.wrappedValue }, set: { value in if layout.usesPaneLayout { @@ -411,8 +407,7 @@ private struct CompositionPickerModifier: ViewModifier { .environment( \.compositionPicker, CompositionPickerContent( - isPresented: popoverBinding.activePresentation(when: isActive), - arrowEdge: arrowEdge, + isPresented: panelBinding.activePresentation(when: isActive), maxHeight: maxHeight ) { AnyView(picker()) @@ -423,26 +418,83 @@ private struct CompositionPickerModifier: ViewModifier { private struct CompositionPickerAnchorModifier: ViewModifier { @Environment(\.compositionPicker) private var picker + @State private var anchor = CGRect.zero func body(content: Content) -> some View { + let isPresented = picker?.isPresented ?? .constant(false) + content - .popover(isPresented: picker?.isPresented ?? .constant(false), arrowEdge: picker?.arrowEdge) { - if let picker { - Group { - // 화면이 낮거나 Duo 접는 선에 걸리면 팝오버 높이를 줄이고 목록을 스크롤 - if let maxHeight = picker.maxHeight { - picker.content() - .frame(width: 320 * AdaptiveSize.boardScale) - .frame(minHeight: 0, idealHeight: maxHeight, maxHeight: maxHeight) - } else { + .onGeometryChange(for: CGRect.self) { proxy in + proxy.frame(in: .global) + } action: { frame in + anchor = frame + } + // 시스템 팝오버 대신 탭 바, 사이드바까지 덮는 투명한 자리에 판을 직접 그림 + .modifier( + ProminentPresentation( + item: Binding( + get: { isPresented.wrappedValue ? SheetPresence() : nil }, + set: { isPresented.wrappedValue = $0 != nil } + ) + ) { _, _, dismiss in + if let picker { + CompositionPickerPanel(anchor: anchor, maxHeight: picker.maxHeight, dismiss: dismiss) { picker.content() - .frame(width: 320 * AdaptiveSize.boardScale) - .fixedSize(horizontal: false, vertical: true) } } - .presentationBackground(Color.secondaryBackground) - .presentationCompactAdaptation(.popover) } + ) + } +} + +// OS와 상관없이 같은 모양으로 버튼 아래에 직접 그리는 화살표 없는 판 +private struct CompositionPickerPanel: View { + @Environment(\.colorScheme) private var colorScheme + let anchor: CGRect + let maxHeight: CGFloat? + let dismiss: () -> Void + @ViewBuilder let content: Content + + var body: some View { + let width = 320 * AdaptiveSize.boardScale + let spacing = CGFloat(6) + let margin = CGFloat(16) + + ZStack(alignment: .topLeading) { + Color.clear + .contentShape(.rect) + .ignoresSafeArea() + .onTapGesture { + dismiss() + } + + GeometryReader { proxy in + let frame = proxy.frame(in: .global) + // 버튼 가운데 아래에 두고, 창 끝에 걸리면 여백 안쪽으로 밀어 넣음 + let leading = min(max(anchor.midX - width / 2 - frame.minX, margin), frame.width - width - margin) + let top = anchor.maxY - frame.minY + spacing + let available = max(frame.height - top - margin, 0) + + Group { + // 화면이 낮으면 판 높이를 줄이고 목록을 스크롤 + if let maxHeight { + content + .frame(height: min(maxHeight, available)) + } else { + content + .fixedSize(horizontal: false, vertical: true) + } + } + .frame(width: width) + .background(Color.secondaryBackground) + .clipShape(.rect(cornerRadius: CornerRadius.dialog)) + .overlay { + RoundedRectangle(cornerRadius: CornerRadius.dialog) + .strokeBorder(Color.separator) + } + .shadow(color: Color.black.opacity(colorScheme == .dark ? 0.5 : 0.12), radius: 30, y: 24) + .offset(x: leading, y: top) } + } } } diff --git a/Application/Presentation/PresentationShared/Sources/Extension/View+Sheet.swift b/Application/Presentation/PresentationShared/Sources/Extension/View+Sheet.swift index 730b50fd..f3b9e1ec 100644 --- a/Application/Presentation/PresentationShared/Sources/Extension/View+Sheet.swift +++ b/Application/Presentation/PresentationShared/Sources/Extension/View+Sheet.swift @@ -56,7 +56,8 @@ public extension View { } } -private struct SheetPresence: Identifiable { +// 참거짓 표시 상태를 ProminentPresentation의 항목으로 바꾼 값 +struct SheetPresence: Identifiable { var id: Bool { true } } diff --git a/Application/Presentation/ProfileTab/Sources/Profile/ActivityCard.swift b/Application/Presentation/ProfileTab/Sources/Profile/ActivityCard.swift index 37ed1cdd..6b221fab 100644 --- a/Application/Presentation/ProfileTab/Sources/Profile/ActivityCard.swift +++ b/Application/Presentation/ProfileTab/Sources/Profile/ActivityCard.swift @@ -93,7 +93,7 @@ struct ActivityCard: View { .foregroundStyle(Color.label) } .buttonStyle(.plain) - // 칸으로 나눈 화면은 분기 선택을 시트 대신 버튼 옆 팝오버로 표시 + // 칸으로 나눈 화면은 분기 선택을 시트 대신 버튼 아래 판으로 표시 .compositionPickerAnchor() Spacer() Button { @@ -212,7 +212,7 @@ struct QuarterPickerSheet: View { @Bindable var store: StoreOf var body: some View { - // 칸으로 나눈 iPad 화면의 팝오버도 Mac과 같은 배치, 크기만 손가락 기준 + // 칸으로 나눈 iPad 화면의 판도 Mac과 같은 배치, 크기만 손가락 기준 if isiOSAppOnMac || usesPaneLayout { desktopContent } else { @@ -220,7 +220,7 @@ struct QuarterPickerSheet: View { } } - // Mac·iPad 넓은 화면 분기 선택 팝오버 + // Mac, iPad 넓은 화면 분기 선택 판 // 위쪽 제목·완료 줄, 바탕 없는 연도 행, 1~4분기 두 줄 격자 배치 private var desktopContent: some View { VStack(spacing: 0) { diff --git a/Application/Presentation/ProfileTab/Sources/Profile/ProfileView.swift b/Application/Presentation/ProfileTab/Sources/Profile/ProfileView.swift index 6a07532b..6b143b6e 100644 --- a/Application/Presentation/ProfileTab/Sources/Profile/ProfileView.swift +++ b/Application/Presentation/ProfileTab/Sources/Profile/ProfileView.swift @@ -15,7 +15,6 @@ public struct ProfileView: View { @Environment(\.windowControlsInset) private var windowControlsInset @Environment(\.usesPaneLayout) private var usesPaneLayout @Environment(\.deviceType) private var deviceType - @Environment(\.isiOSAppOnMac) private var isiOSAppOnMac @State private var store: StoreOf @Bindable private var settingsStore: StoreOf private let isSelected: Bool @@ -132,11 +131,10 @@ public struct ProfileView: View { settingsStore.send(.startObserving) } .prominentAlert(store, state: \.alert, action: \.alert) - // 좁은 창은 분기 선택을 시트로, 칸으로 나눈 화면은 분기 표시 옆 팝오버로 표시하고 Mac은 분기 표시 아래로 표시 + // 좁은 창은 분기 선택을 시트로, 칸으로 나눈 화면은 분기 표시 아래 판으로 표시 .compositionPicker( isPresented: $store.showQuarterPicker, - isActive: isSelected, - arrowEdge: isiOSAppOnMac ? .top : nil + isActive: isSelected ) { QuarterPickerSheet(store: store) }