Skip to content

Commit 2dab98c

Browse files
Roy-wonjiclaude
andcommitted
πŸ—οΈ refactor: TCA νŒ¨ν„΄μ— λ§žλŠ” μƒμˆ˜ ꡬ쑰 κ°œμ„ 
πŸ“¦ μƒμˆ˜ μž¬κ΅¬μ„±: - λ¬Έμžμ—΄ μƒμˆ˜λ₯Ό HomeFeature.Strings둜 이동 - TCA Feature λ ˆλ²¨μ—μ„œ λΉ„μ¦ˆλ‹ˆμŠ€ λ¬Έμžμ—΄ 관리 - View λ ˆλ²¨μ—μ„œλŠ” Layout μƒμˆ˜λ§Œ 관리 🎨 Layout μƒμˆ˜ ꡬ쑰화: - Layout.Hero: νžˆμ–΄λ‘œ μ„Ήμ…˜ κ΄€λ ¨ μƒμˆ˜ - Layout.TimePicker: μ‹œκ°„ 선택기 κ΄€λ ¨ μƒμˆ˜ - Layout.TimeCapsule: μ‹œκ°„ 캑슐 κ΄€λ ¨ μƒμˆ˜ - Layout.TimeDisplay: μ‹œκ°„ ν‘œμ‹œ κ΄€λ ¨ μƒμˆ˜ ✨ κ°œμ„  효과: - 의미 μžˆλŠ” λ„€μ΄λ°μœΌλ‘œ 가독성 ν–₯상 - TCA μ•„ν‚€ν…μ²˜ νŒ¨ν„΄ μ€€μˆ˜ - μœ μ§€λ³΄μˆ˜μ„± 및 ν™•μž₯μ„± ν–₯상 Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
1 parent 428885a commit 2dab98c

2 files changed

Lines changed: 51 additions & 38 deletions

File tree

β€ŽProjects/Presentation/Home/Sources/Main/Reducer/HomeFeature.swiftβ€Ž

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ public struct HomeFeature {
2222

2323
public init() {}
2424

25+
// MARK: - Constants
26+
public enum Strings {
27+
public static let currentTime = "ν˜„μž¬ μ‹œκ°„"
28+
public static let departureTime = "좜발 μ‹œκ°„"
29+
public static let hours = "HOURS"
30+
public static let minutes = "MINUTES"
31+
public static let exploreNearby = "μ£Όλ³€ 탐색 μ‹œμž‘ν•˜κΈ°"
32+
public static let departureTimeSelection = "좜발 μ‹œκ°„ 선택"
33+
public static let insufficientWaitTime = "λŒ€κΈ° μ‹œκ°„μ΄ λΆ€μ‘±ν•©λ‹ˆλ‹€ (μ΅œμ†Œ 20λΆ„ ν•„μš”)"
34+
}
35+
2536
@ObservableState
2637
public struct State: Equatable {
2738
public init() {

β€ŽProjects/Presentation/Home/Sources/Main/View/HomeView.swiftβ€Ž

Lines changed: 40 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,30 @@ public struct HomeView: View {
1616
@Bindable var store: StoreOf<HomeFeature>
1717

1818
// MARK: - Layout Constants
19-
private enum LayoutConstants {
20-
static let heroHeight: CGFloat = 524
21-
static let pickerWidth: CGFloat = 176
22-
static let pickerHeight: CGFloat = 180
23-
static let pickerOffset = UIOffset(horizontal: -184, vertical: 492)
24-
static let timeCapsuleHeight: CGFloat = 77
25-
static let cornerRadius: CGFloat = 28
26-
static let heroCornerRadius: CGFloat = 40
27-
static let timeLeftCornerRadius: CGFloat = 36
28-
}
19+
private enum Layout {
20+
enum Hero {
21+
static let height: CGFloat = 524
22+
static let cornerRadius: CGFloat = 40
23+
}
24+
25+
enum TimePicker {
26+
static let width: CGFloat = 176
27+
static let height: CGFloat = 180
28+
static let offset = UIOffset(horizontal: -184, vertical: 492)
29+
static let cornerRadius: CGFloat = 28
30+
}
2931

30-
// MARK: - String Constants (μ€€λΉ„: ν–₯ν›„ κ΅­μ œν™”μš©)
31-
private enum Strings {
32-
static let currentTime = "ν˜„μž¬ μ‹œκ°„"
33-
static let departureTime = "좜발 μ‹œκ°„"
34-
static let hours = "HOURS"
35-
static let minutes = "MINUTES"
36-
static let exploreNearby = "μ£Όλ³€ 탐색 μ‹œμž‘ν•˜κΈ°"
37-
static let departureTimeSelection = "좜발 μ‹œκ°„ 선택"
38-
static let insufficientWaitTime = "λŒ€κΈ° μ‹œκ°„μ΄ λΆ€μ‘±ν•©λ‹ˆλ‹€ (μ΅œμ†Œ 20λΆ„ ν•„μš”)"
32+
enum TimeCapsule {
33+
static let height: CGFloat = 77
34+
static let cornerRadius: CGFloat = 28
35+
}
36+
37+
enum TimeDisplay {
38+
static let cornerRadius: CGFloat = 36
39+
}
3940
}
4041

42+
4143
public init(store: StoreOf<HomeFeature>) {
4244
self.store = store
4345
}
@@ -79,7 +81,7 @@ public struct HomeView: View {
7981
}
8082
.onChange(of: store.shouldShowDepartureWarningToast) { _, shouldShow in
8183
guard shouldShow else { return }
82-
ToastManager.shared.showWarning(Strings.insufficientWaitTime)
84+
ToastManager.shared.showWarning(HomeFeature.Strings.insufficientWaitTime)
8385
}
8486
}
8587
}
@@ -96,7 +98,7 @@ extension HomeView {
9698
Image(asset: .homeLogo)
9799
.resizable()
98100
.scaledToFill()
99-
.frame(width: geometry.size.width, height: LayoutConstants.heroHeight, alignment: .top)
101+
.frame(width: geometry.size.width, height: Layout.Hero.height, alignment: .top)
100102
.scaleEffect(1.06, anchor: .top)
101103
.ignoresSafeArea(edges: .top)
102104

@@ -115,25 +117,25 @@ extension HomeView {
115117
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .bottom)
116118
.padding(.bottom, 28)
117119
}
118-
.frame(width: geometry.size.width, height: LayoutConstants.heroHeight)
120+
.frame(width: geometry.size.width, height: Layout.Hero.height)
119121
.background(.clear)
120122
.clipShape(
121123
UnevenRoundedRectangle(
122124
cornerRadii: .init(
123-
bottomLeading: LayoutConstants.heroCornerRadius,
124-
bottomTrailing: LayoutConstants.heroCornerRadius
125+
bottomLeading: Layout.Hero.cornerRadius,
126+
bottomTrailing: Layout.Hero.cornerRadius
125127
)
126128
)
127129
)
128130

129131
if store.departureTimePickerVisible {
130132
departureTimePickerView()
131-
.offset(x: geometry.size.width + LayoutConstants.pickerOffset.horizontal, y: LayoutConstants.pickerOffset.vertical)
133+
.offset(x: geometry.size.width + Layout.TimePicker.offset.horizontal, y: Layout.TimePicker.offset.vertical)
132134
.zIndex(2)
133135
}
134136
}
135137
}
136-
.frame(height: LayoutConstants.heroHeight)
138+
.frame(height: Layout.Hero.height)
137139
}
138140

139141
@ViewBuilder
@@ -182,7 +184,7 @@ extension HomeView {
182184
fileprivate func selectTrainTimeView() -> some View {
183185
HStack(alignment: .top, spacing: 10) {
184186
timeCapsuleView(
185-
title: Strings.currentTime,
187+
title: HomeFeature.Strings.currentTime,
186188
time: store.currentTime.formattedKoreanTime(),
187189
timeColor: .gray900,
188190
backgroundColor: .gray100
@@ -192,7 +194,7 @@ extension HomeView {
192194
store.send(.view(.departureTimeButtonTapped))
193195
} label: {
194196
timeCapsuleView(
195-
title: Strings.departureTime,
197+
title: HomeFeature.Strings.departureTime,
196198
time: store.isDepartureTimeSet
197199
? store.departureTime.formattedKoreanTime()
198200
: store.currentTime.formattedKoreanTime(),
@@ -210,7 +212,7 @@ extension HomeView {
210212
@ViewBuilder
211213
fileprivate func departureTimePickerView() -> some View {
212214
DatePicker(
213-
Strings.departureTimeSelection,
215+
HomeFeature.Strings.departureTimeSelection,
214216
selection: $store.departureTime,
215217
in: store.currentTime...,
216218
displayedComponents: [.hourAndMinute]
@@ -221,11 +223,11 @@ extension HomeView {
221223
.onChange(of: store.departureTime) { _, newValue in
222224
store.send(.view(.departureTimeChanged(newValue)))
223225
}
224-
.frame(height: LayoutConstants.pickerHeight)
226+
.frame(height: Layout.TimePicker.height)
225227
.clipped()
226-
.frame(width: LayoutConstants.pickerWidth)
228+
.frame(width: Layout.TimePicker.width)
227229
.background(.gray300)
228-
.clipShape(RoundedRectangle(cornerRadius: LayoutConstants.cornerRadius))
230+
.clipShape(RoundedRectangle(cornerRadius: Layout.TimePicker.cornerRadius))
229231
}
230232

231233
@ViewBuilder
@@ -245,9 +247,9 @@ extension HomeView {
245247
.foregroundStyle(timeColor)
246248
}
247249
.frame(maxWidth: .infinity)
248-
.frame(height: LayoutConstants.timeCapsuleHeight)
250+
.frame(height: Layout.TimeCapsule.height)
249251
.background(backgroundColor)
250-
.cornerRadius(LayoutConstants.cornerRadius)
252+
.cornerRadius(Layout.TimeCapsule.cornerRadius)
251253
}
252254

253255

@@ -262,7 +264,7 @@ extension HomeView {
262264
.foregroundStyle(store.hasRemainingTimeResult ? .gray900 : .enableColor)
263265
.frame(height: 69)
264266

265-
Text(Strings.hours)
267+
Text(HomeFeature.Strings.hours)
266268
.pretendardCustomFont(textStyle: .caption)
267269
.foregroundStyle(store.hasRemainingTimeResult ? .gray900 : .enableColor)
268270

@@ -285,7 +287,7 @@ extension HomeView {
285287
.foregroundStyle(store.hasRemainingTimeResult ? .gray900 : .enableColor)
286288
.frame(height: 69)
287289

288-
Text(Strings.minutes)
290+
Text(HomeFeature.Strings.minutes)
289291
.pretendardCustomFont(textStyle: .caption)
290292
.foregroundStyle(store.hasRemainingTimeResult ? .gray900 : .enableColor)
291293

@@ -296,7 +298,7 @@ extension HomeView {
296298
}
297299
.padding(.vertical, 21)
298300
.background(
299-
RoundedRectangle(cornerRadius: LayoutConstants.timeLeftCornerRadius)
301+
RoundedRectangle(cornerRadius: Layout.TimeDisplay.cornerRadius)
300302
.fill(.white)
301303
)
302304
.padding(.horizontal, 24)
@@ -308,7 +310,7 @@ extension HomeView {
308310
action: {
309311
store.send(.view(.exploreNearbyButtonTapped))
310312
},
311-
title: Strings.exploreNearby,
313+
title: HomeFeature.Strings.exploreNearby,
312314
config: CustomButtonConfig.create(),
313315
isEnable: store.isExploreNearbyEnabled
314316
)

0 commit comments

Comments
Β (0)