Skip to content

Commit cf84f3f

Browse files
authored
Merge pull request #658 from ESTiOSAI/design/dynamic-subheader-height
[fix] 다이나믹 폰트 적용 후 Subheader 컨텐츠가 잘리는 이슈 개선
2 parents ef51beb + bc88d57 commit cf84f3f

5 files changed

Lines changed: 34 additions & 17 deletions

File tree

AIProject/iCo/Features/Base/SubheaderView.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ struct SubheaderView: View {
4040
.font(.ico15)
4141
.foregroundStyle(fontColor)
4242
.lineSpacing(6)
43+
.fixedSize(horizontal: false, vertical: true)
4344
}
4445
}
4546
.frame(maxWidth: .infinity, alignment: .leading)

AIProject/iCo/Features/Dashboard/View/CoinCarouselView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,6 @@ extension CoinCarouselView {
233233
}
234234

235235
#Preview {
236-
RecommendCoinView()
236+
RecommendCoinView(headerHeight: 140)
237237
.environmentObject(RecommendCoinViewModel())
238238
}

AIProject/iCo/Features/Dashboard/View/DashboardView.swift

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,29 +12,43 @@ import SwiftUI
1212
/// 관심 코인 기반 추천, AI 브리핑으로 구성합니다.
1313
struct DashboardView: View {
1414
@Environment(\.horizontalSizeClass) var hSizeClass
15+
@Environment(\.dynamicTypeSize) var typeSize
1516

1617
@Namespace var coordinateSpaceName: Namespace.ID
1718
/// 스크롤의 위치를 저장하는 상태 변수
1819
@State var scrollOffset: CGFloat = 0
1920
/// 상단 여백을 저장하는 상태 변수: onAppear에서 실제 높이를 계산함
2021
@State var topInset: CGFloat = 0
22+
@State var currentTypeSize: DynamicTypeSize = .medium
2123

22-
/// 배경색의 높이를 저장하는 계산 속성: 헤더의 높이 + 여백 + 카드의 높이 / 2 + 상단 여백
23-
/// 배경이 카드의 중앙까지만 깔리게 해야 하는데 뷰가 여러 계층으로 나눠져있어서 각 컴포넌트의 높이를 계산해서 사용함
24-
var gradientHeight: CGFloat {
25-
CardConst.headerHeight + CardConst.headerContentSpacing + (CardConst.cardHeight / 2) + topInset
24+
/// 다이나믹 폰트 적용 후 헤더 컨텐츠 크기가 커질 때
25+
/// 헤더 사이즈를 유동적으로 조정하기 위해 사용하는 계산 속성
26+
/// 헤더뷰와 배경 그래디언트 크기에도 영향을 주기 때문에
27+
/// 여기에서 계산 후 헤더뷰에게 전파
28+
var dynamicHeaderHeight: CGFloat {
29+
switch typeSize {
30+
case .xSmall, .small, .medium: CardConst.headerHeight
31+
case .large, .xLarge, .xxLarge, .xxxLarge: CardConst.headerHeight * 1.1
32+
default: CardConst.headerHeight * 1.4
33+
}
2634
}
2735

2836
var body: some View {
2937
/// 배경색에 Sticky 효과 적용을 위해 추가적인 높이: 스크롤 위치만큼 더해주기 위해 사용
3038
/// 쫀득한 효과를 더 드라마틱하게 보여주기 위해 스크롤 위치의 1.2배만큼 늘리기
3139
let extraHeight = max(0, -scrollOffset * 1.2)
3240

41+
/// 배경색의 높이를 저장하는 계산 속성: 헤더의 높이 + 여백 + 카드의 높이 / 2 + 상단 여백
42+
/// 배경이 카드의 중앙까지만 깔리게 해야 하는데 뷰가 여러 계층으로 나눠져있어서 각 컴포넌트의 높이를 계산해서 사용함
43+
var gradientHeight: CGFloat {
44+
dynamicHeaderHeight + CardConst.headerContentSpacing + (CardConst.cardHeight / 2) + topInset
45+
}
46+
3347
GeometryReader { outerProxy in
3448
NavigationStack {
3549
ScrollView {
3650
VStack {
37-
RecommendCoinView()
51+
RecommendCoinView(headerHeight: dynamicHeaderHeight)
3852
AIBriefingView()
3953
}
4054
.padding(.top, topInset)
@@ -112,12 +126,6 @@ struct DashboardView: View {
112126
}
113127
}
114128

115-
#Preview {
116-
DashboardView()
117-
.environmentObject(ThemeManager())
118-
.environmentObject(RecommendCoinViewModel())
119-
}
120-
121129
/// scrollOffset을 구하기 위한 PreferenceKey
122130
private struct ScrollOffsetPreferenceKey: PreferenceKey {
123131
static var defaultValue: CGFloat { .zero }
@@ -126,3 +134,9 @@ private struct ScrollOffsetPreferenceKey: PreferenceKey {
126134
value += nextValue()
127135
}
128136
}
137+
138+
#Preview {
139+
DashboardView()
140+
.environmentObject(ThemeManager())
141+
.environmentObject(RecommendCoinViewModel())
142+
}

AIProject/iCo/Features/Dashboard/View/RecommendCoinView.swift

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,14 @@ import SwiftUI
1212
/// 컨텐츠 뷰에 코인 추천 상태별로 알맞은 뷰를 뿌려줍니다.
1313
struct RecommendCoinView: View {
1414
@StateObject private var viewModel = RecommendCoinViewModel()
15+
16+
let headerHeight: CGFloat
1517

1618
var body: some View {
1719
ZStack(alignment: .top) {
1820
VStack(alignment: .center, spacing: CardConst.headerContentSpacing) {
1921
RecommendHeaderView()
22+
.frame(height: headerHeight)
2023

2124
recommendContentView()
2225
.frame(minHeight: CardConst.cardHeight)
@@ -69,7 +72,7 @@ struct RecommendCoinView: View {
6972
}
7073

7174
#Preview {
72-
RecommendCoinView()
75+
RecommendCoinView(headerHeight: 140)
7376
.environmentObject(RecommendCoinViewModel())
7477
}
7578

AIProject/iCo/Features/Dashboard/View/RecommendHeaderView.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,13 @@ struct RecommendHeaderView: View {
1919
imageColor: .white,
2020
fontColor: .white
2121
)
22-
23-
Spacer()
2422
}
25-
.frame(height: CardConst.headerHeight)
2623
}
2724
}
2825

2926
#Preview() {
30-
RecommendCoinView()
27+
RecommendCoinView(headerHeight: 140)
3128
.environmentObject(RecommendCoinViewModel())
29+
.environmentObject(ThemeManager())
30+
.background(.black.opacity(0.2))
3231
}

0 commit comments

Comments
 (0)