From 1182ea82b537c62f98347fced2066a22d74c4ec8 Mon Sep 17 00:00:00 2001 From: kitcat-s Date: Tue, 28 Oct 2025 10:29:26 +0900 Subject: [PATCH 1/3] =?UTF-8?q?refactor:=20=EC=BD=94=EB=93=9C=20=EC=A0=95?= =?UTF-8?q?=EB=A6=AC=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iCo/Features/Dashboard/View/DashboardView.swift | 12 ++++++------ .../Features/Dashboard/View/RecommendCoinView.swift | 1 + .../Dashboard/View/RecommendHeaderView.swift | 5 ++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/AIProject/iCo/Features/Dashboard/View/DashboardView.swift b/AIProject/iCo/Features/Dashboard/View/DashboardView.swift index 20dab407..bda3126f 100644 --- a/AIProject/iCo/Features/Dashboard/View/DashboardView.swift +++ b/AIProject/iCo/Features/Dashboard/View/DashboardView.swift @@ -112,12 +112,6 @@ struct DashboardView: View { } } -#Preview { - DashboardView() - .environmentObject(ThemeManager()) - .environmentObject(RecommendCoinViewModel()) -} - /// scrollOffset을 구하기 위한 PreferenceKey private struct ScrollOffsetPreferenceKey: PreferenceKey { static var defaultValue: CGFloat { .zero } @@ -126,3 +120,9 @@ private struct ScrollOffsetPreferenceKey: PreferenceKey { value += nextValue() } } + +#Preview { + DashboardView() + .environmentObject(ThemeManager()) + .environmentObject(RecommendCoinViewModel()) +} diff --git a/AIProject/iCo/Features/Dashboard/View/RecommendCoinView.swift b/AIProject/iCo/Features/Dashboard/View/RecommendCoinView.swift index 5e6bb56f..366a5985 100644 --- a/AIProject/iCo/Features/Dashboard/View/RecommendCoinView.swift +++ b/AIProject/iCo/Features/Dashboard/View/RecommendCoinView.swift @@ -17,6 +17,7 @@ struct RecommendCoinView: View { ZStack(alignment: .top) { VStack(alignment: .center, spacing: CardConst.headerContentSpacing) { RecommendHeaderView() + .frame(height: CardConst.headerHeight) recommendContentView() .frame(minHeight: CardConst.cardHeight) diff --git a/AIProject/iCo/Features/Dashboard/View/RecommendHeaderView.swift b/AIProject/iCo/Features/Dashboard/View/RecommendHeaderView.swift index 87a5d130..375b81ed 100644 --- a/AIProject/iCo/Features/Dashboard/View/RecommendHeaderView.swift +++ b/AIProject/iCo/Features/Dashboard/View/RecommendHeaderView.swift @@ -19,14 +19,13 @@ struct RecommendHeaderView: View { imageColor: .white, fontColor: .white ) - - Spacer() } - .frame(height: CardConst.headerHeight) } } #Preview() { RecommendCoinView() .environmentObject(RecommendCoinViewModel()) + .environmentObject(ThemeManager()) + .background(.black.opacity(0.2)) } From 658bafe42b2a12f2c292274e5868819ca0dd60a4 Mon Sep 17 00:00:00 2001 From: kitcat-s Date: Tue, 28 Oct 2025 10:33:23 +0900 Subject: [PATCH 2/3] =?UTF-8?q?fix:=20Subheader=20=ED=85=8D=EC=8A=A4?= =?UTF-8?q?=ED=8A=B8=EA=B0=80=20=ED=94=84=EB=A0=88=EC=9E=84=EC=9D=84=20?= =?UTF-8?q?=EB=84=98=EC=96=B4=EA=B0=80=EB=8F=84=20=EC=9E=98=EB=A6=AC?= =?UTF-8?q?=EC=A7=80=20=EC=95=8A=EB=8F=84=EB=A1=9D=20fixedSize=20=EC=84=A4?= =?UTF-8?q?=EC=A0=95=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AIProject/iCo/Features/Base/SubheaderView.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/AIProject/iCo/Features/Base/SubheaderView.swift b/AIProject/iCo/Features/Base/SubheaderView.swift index 16d4ba7b..287d1727 100644 --- a/AIProject/iCo/Features/Base/SubheaderView.swift +++ b/AIProject/iCo/Features/Base/SubheaderView.swift @@ -40,6 +40,7 @@ struct SubheaderView: View { .font(.ico15) .foregroundStyle(fontColor) .lineSpacing(6) + .fixedSize(horizontal: false, vertical: true) } } .frame(maxWidth: .infinity, alignment: .leading) From bc88d5783cd08839cfd7c68cc3fb8cf036c7c962 Mon Sep 17 00:00:00 2001 From: kitcat-s Date: Tue, 28 Oct 2025 10:55:00 +0900 Subject: [PATCH 3/3] =?UTF-8?q?feat:=20typeSize=EC=97=90=20=EB=94=B0?= =?UTF-8?q?=EB=9D=BC=20=ED=97=A4=EB=8D=94=20=EB=86=92=EC=9D=B4=EB=A5=BC=20?= =?UTF-8?q?=EB=B3=80=EA=B2=BD=ED=95=98=EB=8A=94=20=EA=B3=84=EC=82=B0=20?= =?UTF-8?q?=EC=86=8D=EC=84=B1=20=EC=B6=94=EA=B0=80=ED=95=98=EA=B8=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Dashboard/View/CoinCarouselView.swift | 2 +- .../Dashboard/View/DashboardView.swift | 24 +++++++++++++++---- .../Dashboard/View/RecommendCoinView.swift | 6 +++-- .../Dashboard/View/RecommendHeaderView.swift | 2 +- 4 files changed, 25 insertions(+), 9 deletions(-) diff --git a/AIProject/iCo/Features/Dashboard/View/CoinCarouselView.swift b/AIProject/iCo/Features/Dashboard/View/CoinCarouselView.swift index 2af31f26..854dd362 100644 --- a/AIProject/iCo/Features/Dashboard/View/CoinCarouselView.swift +++ b/AIProject/iCo/Features/Dashboard/View/CoinCarouselView.swift @@ -233,6 +233,6 @@ extension CoinCarouselView { } #Preview { - RecommendCoinView() + RecommendCoinView(headerHeight: 140) .environmentObject(RecommendCoinViewModel()) } diff --git a/AIProject/iCo/Features/Dashboard/View/DashboardView.swift b/AIProject/iCo/Features/Dashboard/View/DashboardView.swift index bda3126f..a4c3eff7 100644 --- a/AIProject/iCo/Features/Dashboard/View/DashboardView.swift +++ b/AIProject/iCo/Features/Dashboard/View/DashboardView.swift @@ -12,17 +12,25 @@ import SwiftUI /// 관심 코인 기반 추천, AI 브리핑으로 구성합니다. struct DashboardView: View { @Environment(\.horizontalSizeClass) var hSizeClass + @Environment(\.dynamicTypeSize) var typeSize @Namespace var coordinateSpaceName: Namespace.ID /// 스크롤의 위치를 저장하는 상태 변수 @State var scrollOffset: CGFloat = 0 /// 상단 여백을 저장하는 상태 변수: onAppear에서 실제 높이를 계산함 @State var topInset: CGFloat = 0 + @State var currentTypeSize: DynamicTypeSize = .medium - /// 배경색의 높이를 저장하는 계산 속성: 헤더의 높이 + 여백 + 카드의 높이 / 2 + 상단 여백 - /// 배경이 카드의 중앙까지만 깔리게 해야 하는데 뷰가 여러 계층으로 나눠져있어서 각 컴포넌트의 높이를 계산해서 사용함 - var gradientHeight: CGFloat { - CardConst.headerHeight + CardConst.headerContentSpacing + (CardConst.cardHeight / 2) + topInset + /// 다이나믹 폰트 적용 후 헤더 컨텐츠 크기가 커질 때 + /// 헤더 사이즈를 유동적으로 조정하기 위해 사용하는 계산 속성 + /// 헤더뷰와 배경 그래디언트 크기에도 영향을 주기 때문에 + /// 여기에서 계산 후 헤더뷰에게 전파 + var dynamicHeaderHeight: CGFloat { + switch typeSize { + case .xSmall, .small, .medium: CardConst.headerHeight + case .large, .xLarge, .xxLarge, .xxxLarge: CardConst.headerHeight * 1.1 + default: CardConst.headerHeight * 1.4 + } } var body: some View { @@ -30,11 +38,17 @@ struct DashboardView: View { /// 쫀득한 효과를 더 드라마틱하게 보여주기 위해 스크롤 위치의 1.2배만큼 늘리기 let extraHeight = max(0, -scrollOffset * 1.2) + /// 배경색의 높이를 저장하는 계산 속성: 헤더의 높이 + 여백 + 카드의 높이 / 2 + 상단 여백 + /// 배경이 카드의 중앙까지만 깔리게 해야 하는데 뷰가 여러 계층으로 나눠져있어서 각 컴포넌트의 높이를 계산해서 사용함 + var gradientHeight: CGFloat { + dynamicHeaderHeight + CardConst.headerContentSpacing + (CardConst.cardHeight / 2) + topInset + } + GeometryReader { outerProxy in NavigationStack { ScrollView { VStack { - RecommendCoinView() + RecommendCoinView(headerHeight: dynamicHeaderHeight) AIBriefingView() } .padding(.top, topInset) diff --git a/AIProject/iCo/Features/Dashboard/View/RecommendCoinView.swift b/AIProject/iCo/Features/Dashboard/View/RecommendCoinView.swift index 366a5985..63cd0059 100644 --- a/AIProject/iCo/Features/Dashboard/View/RecommendCoinView.swift +++ b/AIProject/iCo/Features/Dashboard/View/RecommendCoinView.swift @@ -12,12 +12,14 @@ import SwiftUI /// 컨텐츠 뷰에 코인 추천 상태별로 알맞은 뷰를 뿌려줍니다. struct RecommendCoinView: View { @StateObject private var viewModel = RecommendCoinViewModel() + + let headerHeight: CGFloat var body: some View { ZStack(alignment: .top) { VStack(alignment: .center, spacing: CardConst.headerContentSpacing) { RecommendHeaderView() - .frame(height: CardConst.headerHeight) + .frame(height: headerHeight) recommendContentView() .frame(minHeight: CardConst.cardHeight) @@ -70,7 +72,7 @@ struct RecommendCoinView: View { } #Preview { - RecommendCoinView() + RecommendCoinView(headerHeight: 140) .environmentObject(RecommendCoinViewModel()) } diff --git a/AIProject/iCo/Features/Dashboard/View/RecommendHeaderView.swift b/AIProject/iCo/Features/Dashboard/View/RecommendHeaderView.swift index 375b81ed..ead4a141 100644 --- a/AIProject/iCo/Features/Dashboard/View/RecommendHeaderView.swift +++ b/AIProject/iCo/Features/Dashboard/View/RecommendHeaderView.swift @@ -24,7 +24,7 @@ struct RecommendHeaderView: View { } #Preview() { - RecommendCoinView() + RecommendCoinView(headerHeight: 140) .environmentObject(RecommendCoinViewModel()) .environmentObject(ThemeManager()) .background(.black.opacity(0.2))