Skip to content

Commit 3b91473

Browse files
authored
πŸ”€ ν”„λ‘œλͺ¨μ…˜ 선택 μ‹œ λ°”ν…€μ‹œνŠΈ ν‘œμ‹œ / νˆ΄λ°” μ•„μ΄μ½˜ 색상 μˆ˜μ • / 닀크λͺ¨λ“œ 연동 (#73)
* 🚧 Add changePromotion(Promotion) in HomeAction * ✨ Implement Promotion Select bottom sheet * ✨ Implement modal presentation for promotion selection * πŸ’„ Set text color to gray900 * πŸ’„ Fix dark mode UI * πŸ’„ Sync toolbar icon colors with dark mode
1 parent 073c347 commit 3b91473

File tree

9 files changed

+185
-6
lines changed

9 files changed

+185
-6
lines changed

β€ŽEntity/Sources/Entity/Promotion.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import Foundation
99

1010
/// 행사 μ’…λ₯˜
11-
public enum Promotion: String, Codable {
11+
public enum Promotion: String, Codable, CaseIterable {
1212
case buyOneGetOneFree = "1+1"
1313
case buyTwoGetOneFree = "2+1"
1414
case allItems = "All"

β€ŽPyeonHaeng-iOS.xcodeproj/project.pbxproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
BAB569612B639F3000D1E0F9 /* DesignSystem in Frameworks */ = {isa = PBXBuildFile; productRef = BAB569602B639F3000D1E0F9 /* DesignSystem */; };
4343
BAB5CF252B6B7C5A008B24BF /* AppRootComponent.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAB5CF242B6B7C5A008B24BF /* AppRootComponent.swift */; };
4444
BAB5CF272B6B7CF3008B24BF /* HomeViewModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAB5CF262B6B7CF3008B24BF /* HomeViewModel.swift */; };
45+
BAB720342B9325F200C2CA1A /* PromotionSelectBottomSheetView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAB720332B9325F200C2CA1A /* PromotionSelectBottomSheetView.swift */; };
4546
BAE159D82B65FA6F002DCF94 /* HomeProductDetailSelectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAE159D72B65FA6F002DCF94 /* HomeProductDetailSelectionView.swift */; };
4647
BAE159DA2B65FC35002DCF94 /* HomeProductListView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAE159D92B65FC35002DCF94 /* HomeProductListView.swift */; };
4748
BAE159DE2B663A9A002DCF94 /* HomeProductSorterView.swift in Sources */ = {isa = PBXBuildFile; fileRef = BAE159DD2B663A9A002DCF94 /* HomeProductSorterView.swift */; };
@@ -105,6 +106,7 @@
105106
BAA4D9B32B5A1796005999F8 /* Preview Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = "Preview Assets.xcassets"; sourceTree = "<group>"; };
106107
BAB5CF242B6B7C5A008B24BF /* AppRootComponent.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppRootComponent.swift; sourceTree = "<group>"; };
107108
BAB5CF262B6B7CF3008B24BF /* HomeViewModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeViewModel.swift; sourceTree = "<group>"; };
109+
BAB720332B9325F200C2CA1A /* PromotionSelectBottomSheetView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PromotionSelectBottomSheetView.swift; sourceTree = "<group>"; };
108110
BABFEA6F2B6399C30084C0EC /* Shared */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = Shared; sourceTree = "<group>"; };
109111
BAE159D72B65FA6F002DCF94 /* HomeProductDetailSelectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeProductDetailSelectionView.swift; sourceTree = "<group>"; };
110112
BAE159D92B65FC35002DCF94 /* HomeProductListView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeProductListView.swift; sourceTree = "<group>"; };
@@ -288,6 +290,7 @@
288290
isa = PBXGroup;
289291
children = (
290292
BA402F7D2B85E31800E86AAD /* ConvenienceSelectBottomSheetView.swift */,
293+
BAB720332B9325F200C2CA1A /* PromotionSelectBottomSheetView.swift */,
291294
);
292295
path = BottomSheet;
293296
sourceTree = "<group>";
@@ -560,6 +563,8 @@
560563
BA28F18B2B6155BD0052855E /* ProductInfoView.swift in Sources */,
561564
E5462C662B65677B00E9FDF2 /* PromotionTag.swift in Sources */,
562565
E50584532B763C8C002FDACF /* ProductInfoViewModel.swift in Sources */,
566+
BAB720342B9325F200C2CA1A /* PromotionSelectBottomSheetView.swift in Sources */,
567+
BA28F1912B61566E0052855E /* ProductSearchView.swift in Sources */,
563568
BA28F1912B61566E0052855E /* SearchView.swift in Sources */,
564569
9CE4B4732B6F0BA3002DC446 /* OnboardingViewModel.swift in Sources */,
565570
9CE4B4752B6F78E8002DC446 /* OnboardingPageControl.swift in Sources */,

β€ŽPyeonHaeng-iOS/Resources/Localizable.xcstrings

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,38 @@
4040
}
4141
}
4242
},
43+
"1+1" : {
44+
"localizations" : {
45+
"ja" : {
46+
"stringUnit" : {
47+
"state" : "translated",
48+
"value" : "1+1"
49+
}
50+
},
51+
"ko" : {
52+
"stringUnit" : {
53+
"state" : "translated",
54+
"value" : "1+1"
55+
}
56+
}
57+
}
58+
},
59+
"2+1" : {
60+
"localizations" : {
61+
"ja" : {
62+
"stringUnit" : {
63+
"state" : "translated",
64+
"value" : "2+1"
65+
}
66+
},
67+
"ko" : {
68+
"stringUnit" : {
69+
"state" : "translated",
70+
"value" : "2+1"
71+
}
72+
}
73+
}
74+
},
4375
"7-Eleven" : {
4476
"localizations" : {
4577
"ja" : {
@@ -56,6 +88,22 @@
5688
}
5789
}
5890
},
91+
"All(View All)" : {
92+
"localizations" : {
93+
"ja" : {
94+
"stringUnit" : {
95+
"state" : "translated",
96+
"value" : "AllοΌˆε…¨γ¦θ‘¨η€ΊοΌ‰"
97+
}
98+
},
99+
"ko" : {
100+
"stringUnit" : {
101+
"state" : "translated",
102+
"value" : "All(전체보기)"
103+
}
104+
}
105+
}
106+
},
59107
"Announcements" : {
60108
"localizations" : {
61109
"ja" : {
@@ -200,6 +248,22 @@
200248
}
201249
}
202250
},
251+
"Select Promotion Items" : {
252+
"localizations" : {
253+
"ja" : {
254+
"stringUnit" : {
255+
"state" : "translated",
256+
"value" : "γƒ—γƒ­γƒ’γ‚·γƒ§γƒ³ε•†ε“ιΈζŠž"
257+
}
258+
},
259+
"ko" : {
260+
"stringUnit" : {
261+
"state" : "translated",
262+
"value" : "행사 ν’ˆλͺ© 선택"
263+
}
264+
}
265+
}
266+
},
203267
"Version Info" : {
204268
"localizations" : {
205269
"ja" : {

β€ŽPyeonHaeng-iOS/Sources/PyeonHaengApp.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct PyeonHaengApp: App {
2929
private func setupNavigationBarAppearance() {
3030
// λ„€λΉ„κ²Œμ΄μ…˜ λ°” 슀크둀 μ—£μ§€ 외관을 μ„€μ •ν•˜κΈ° μœ„ν•œ UINavigationBarAppearance 객체 생성
3131
let appearance = UINavigationBarAppearance()
32-
appearance.backgroundColor = .white // 배경색을 ν•˜μ–€μƒ‰μœΌλ‘œ μ„€μ •
32+
appearance.backgroundColor = .systemBackground // 배경색을 ν•˜μ–€μƒ‰μœΌλ‘œ μ„€μ •
3333
appearance.shadowColor = .clear // 그림자 제거
3434
appearance.titleTextAttributes = [
3535
.foregroundColor: UIColor(Color.gray900),

β€ŽPyeonHaeng-iOS/Sources/Scenes/HomeScene/BottomSheet/ConvenienceSelectBottomSheetView.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
// Created by ν™μŠΉν˜„ on 2/21/24.
66
//
77

8+
import DesignSystem
89
import Entity
910
import SwiftUI
1011

@@ -32,6 +33,7 @@ struct ConvenienceSelectBottomSheetView<ViewModel>: View where ViewModel: HomeVi
3233
}
3334
.padding(.horizontal, Metrics.itemHorizontalPadding)
3435
}
36+
.foregroundStyle(.gray900)
3537
.padding(.top, Metrics.topPadding)
3638
.padding(.bottom, Metrics.bottomPadding)
3739
}
@@ -50,6 +52,7 @@ private struct ConvenienceSelectItem: View {
5052
HStack(spacing: Metrics.itemHorizontalSpacing) {
5153
convenienceImageView()
5254
convenienceText()
55+
.font(.body2)
5356
}
5457
}
5558

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
//
2+
// PromotionSelectBottomSheetView.swift
3+
// PyeonHaeng-iOS
4+
//
5+
// Created by ν™μŠΉν˜„ on 3/2/24.
6+
//
7+
8+
import DesignSystem
9+
import Entity
10+
import SwiftUI
11+
12+
// MARK: - PromotionSelectBottomSheetView
13+
14+
struct PromotionSelectBottomSheetView<ViewModel>: View where ViewModel: HomeViewModelRepresentable {
15+
// MARK: Properties
16+
17+
@EnvironmentObject private var viewModel: ViewModel
18+
@Environment(\.dismiss) private var dismiss
19+
20+
// MARK: Body - View
21+
22+
var body: some View {
23+
VStack(spacing: Metrics.itemSpacing) {
24+
titleView
25+
promotionButtons
26+
}
27+
.foregroundStyle(.gray900)
28+
.padding(.top, Metrics.topPadding)
29+
.padding(.bottom, Metrics.bottomPadding)
30+
}
31+
32+
// MARK: SubViews
33+
34+
private var titleView: some View {
35+
Text("Select Promotion Items")
36+
.font(.h3)
37+
.frame(maxWidth: .infinity, alignment: .leading)
38+
.padding(.horizontal, Metrics.horizontalPadding)
39+
}
40+
41+
private var promotionButtons: some View {
42+
ForEach(Promotion.allCases, id: \.self) { promotion in
43+
Button {
44+
viewModel.changePromotion(to: promotion)
45+
dismiss()
46+
} label: {
47+
Text(promotion.displayName)
48+
.font(.body2)
49+
.frame(maxWidth: .infinity, minHeight: Metrics.itemHeight, alignment: .leading)
50+
}
51+
}
52+
.padding(.horizontal, Metrics.itemHorizontalPadding)
53+
}
54+
}
55+
56+
private extension HomeViewModelRepresentable {
57+
func changePromotion(to promotion: Promotion) {
58+
trigger(.changePromotion(promotion))
59+
}
60+
}
61+
62+
private extension Promotion {
63+
var displayName: LocalizedStringKey {
64+
switch self {
65+
case .allItems: "All(View All)"
66+
case .buyOneGetOneFree: "1+1"
67+
case .buyTwoGetOneFree: "2+1"
68+
}
69+
}
70+
}
71+
72+
// MARK: - Metrics
73+
74+
private enum Metrics {
75+
static let topPadding: CGFloat = 12
76+
static let bottomPadding: CGFloat = 4
77+
static let horizontalPadding: CGFloat = 20
78+
79+
// MARK: Item
80+
81+
static let itemHorizontalPadding: CGFloat = 24
82+
static let itemHorizontalSpacing: CGFloat = 12
83+
static let itemSpacing: CGFloat = 4
84+
static let itemHeight: CGFloat = 44
85+
}

β€ŽPyeonHaeng-iOS/Sources/Scenes/HomeScene/View/HomeProductDetailSelectionView.swift

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import SwiftUI
1313
struct HomeProductDetailSelectionView<ViewModel>: View where ViewModel: HomeViewModelRepresentable {
1414
@EnvironmentObject private var viewModel: ViewModel
1515
@State private var convenienceStoreModalPresented: Bool = false
16+
@State private var promotionModalPresented: Bool = false
1617

1718
var body: some View {
1819
HStack {
@@ -32,14 +33,16 @@ struct HomeProductDetailSelectionView<ViewModel>: View where ViewModel: HomeView
3233
.accessibilityHint("더블 νƒ­ν•˜μ—¬ νŽΈμ˜μ μ„ μ„ νƒν•˜μ„Έμš”")
3334
.sheet(isPresented: $convenienceStoreModalPresented) {
3435
ConvenienceSelectBottomSheetView<ViewModel>()
35-
.presentationDetents([.height(Metrics.bottomSheetHeight)])
36+
.presentationDetents([.height(Metrics.convenienceBottomSheetHeight)])
3637
.presentationCornerRadius(20)
3738
.presentationBackground(.regularMaterial)
3839
}
3940

4041
Spacer()
4142

42-
Button {} label: {
43+
Button {
44+
promotionModalPresented = true
45+
} label: {
4346
HStack(spacing: Metrics.buttonSpacing) {
4447
Text(verbatim: "All")
4548
.font(.title2)
@@ -63,6 +66,12 @@ struct HomeProductDetailSelectionView<ViewModel>: View where ViewModel: HomeView
6366
.stroke()
6467
.foregroundStyle(.gray400)
6568
}
69+
.sheet(isPresented: $promotionModalPresented) {
70+
PromotionSelectBottomSheetView<ViewModel>()
71+
.presentationDetents([.height(Metrics.promotionBottomSheetHeight)])
72+
.presentationCornerRadius(20)
73+
.presentationBackground(.regularMaterial)
74+
}
6675
}
6776
.frame(height: Metrics.height)
6877
}
@@ -99,5 +108,6 @@ private enum Metrics {
99108
static let promotionButtonCornerRadius: CGFloat = 16
100109

101110
static let height: CGFloat = 56
102-
static let bottomSheetHeight: CGFloat = 334
111+
static let convenienceBottomSheetHeight: CGFloat = 334
112+
static let promotionBottomSheetHeight: CGFloat = 238
103113
}

β€ŽPyeonHaeng-iOS/Sources/Scenes/HomeScene/View/HomeView.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct HomeView<ViewModel>: View where ViewModel: HomeViewModelRepresentable {
2929
}
3030
.background(
3131
LinearGradient(
32-
colors: [.white, .white.opacity(0.9)],
32+
colors: [.init(.systemBackground), .init(.systemBackground).opacity(0.9)],
3333
startPoint: .top,
3434
endPoint: .bottom
3535
)
@@ -44,6 +44,8 @@ struct HomeView<ViewModel>: View where ViewModel: HomeViewModelRepresentable {
4444
ToolbarItem(placement: .topBarLeading) {
4545
HStack {
4646
Image.store
47+
.renderingMode(.template)
48+
.foregroundStyle(.gray900)
4749
}
4850
}
4951

@@ -53,6 +55,8 @@ struct HomeView<ViewModel>: View where ViewModel: HomeViewModelRepresentable {
5355
.toolbarRole(.editor)
5456
} label: {
5557
Image.magnifyingglass
58+
.renderingMode(.template)
59+
.foregroundStyle(.gray900)
5660
}
5761
.accessibilityLabel("검색")
5862
.accessibilityHint("더블 νƒ­ν•˜μ—¬ μ œν’ˆμ„ κ²€μƒ‰ν•˜μ„Έμš”")
@@ -61,6 +65,8 @@ struct HomeView<ViewModel>: View where ViewModel: HomeViewModelRepresentable {
6165
.toolbarRole(.editor)
6266
} label: {
6367
Image.gearshape
68+
.renderingMode(.template)
69+
.foregroundStyle(.gray900)
6470
}
6571
.accessibilityLabel("μ„€μ •")
6672
.accessibilityHint("더블 νƒ­ν•˜μ—¬ 섀정에 κ΄€ν•œ κΈ°λŠ₯을 ν™•μΈν•˜μ„Έμš”")

β€ŽPyeonHaeng-iOS/Sources/Scenes/HomeScene/ViewModel/HomeViewModel.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ enum HomeAction {
1818
case fetchCount
1919
case changeOrder
2020
case changeConvenienceStore(ConvenienceStore)
21+
case changePromotion(Promotion)
2122
}
2223

2324
// MARK: - HomeState
@@ -96,6 +97,11 @@ final class HomeViewModel: HomeViewModelRepresentable {
9697
state.productConfiguration.change(convenienceStore: store)
9798
trigger(.fetchProducts)
9899
trigger(.fetchCount)
100+
101+
case let .changePromotion(promotion):
102+
state.productConfiguration.change(promotion: promotion)
103+
trigger(.fetchProducts)
104+
trigger(.fetchCount)
99105
}
100106
}
101107

0 commit comments

Comments
Β (0)