Skip to content

Commit 17dff34

Browse files
committed
refactor: SettingsView TCA 적용
1 parent 3d816ff commit 17dff34

7 files changed

Lines changed: 398 additions & 298 deletions

File tree

Application/DevLogPresentation/Sources/Main/MainView.swift

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -361,15 +361,11 @@ struct MainView: View {
361361
TodoDetailView(store: profileViewCoordinator.makeTodoDetailStore(todoId: todoId))
362362
.id(todoId)
363363
case .settings:
364-
SettingsView(viewModel: profileViewCoordinator.settingsViewModel)
364+
SettingsView(store: profileViewCoordinator.settingsStore)
365365
.environment(profileViewCoordinator.router)
366366
case .theme:
367-
ThemeView(
368-
theme: Binding(
369-
get: { profileViewCoordinator.settingsViewModel.state.theme },
370-
set: { profileViewCoordinator.settingsViewModel.send(.setTheme($0)) }
371-
)
372-
)
367+
@Bindable var settingsStore = profileViewCoordinator.settingsStore
368+
ThemeView(theme: $settingsStore.theme)
373369
case .pushNotification:
374370
PushNotificationSettingsView(
375371
store: profileViewCoordinator.makePushNotificationSettingsStore()

Application/DevLogPresentation/Sources/Profile/ProfileView.swift

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,17 +158,13 @@ struct ProfileView: View {
158158
private func profileDestinationView(_ route: ProfileRoute) -> some View {
159159
switch route {
160160
case .settings:
161-
SettingsView(viewModel: coordinator.settingsViewModel)
161+
SettingsView(store: coordinator.settingsStore)
162162
.environment(coordinator.router)
163163
case .activity(let todoId):
164164
TodoDetailView(store: coordinator.makeTodoDetailStore(todoId: todoId))
165165
case .theme:
166-
ThemeView(
167-
theme: Binding(
168-
get: { coordinator.settingsViewModel.state.theme },
169-
set: { coordinator.settingsViewModel.send(.setTheme($0)) }
170-
)
171-
)
166+
@Bindable var settingsStore = coordinator.settingsStore
167+
ThemeView(theme: $settingsStore.theme)
172168
case .pushNotification:
173169
PushNotificationSettingsView(store: coordinator.makePushNotificationSettingsStore())
174170
case .account:

Application/DevLogPresentation/Sources/Profile/ProfileViewCoordinator.swift

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import DevLogDomain
1414
@Observable
1515
final class ProfileViewCoordinator {
1616
let viewModel: ProfileViewModel
17-
let settingsViewModel: SettingsViewModel
17+
let settingsStore: StoreOf<SettingsFeature>
1818
var router = NavigationRouter<ProfileRoute>()
1919
private let container: DIContainer
2020

@@ -29,15 +29,18 @@ final class ProfileViewCoordinator {
2929
fetchHeatmapActivityTypesUseCase: container.resolve(FetchHeatmapActivityTypesUseCase.self),
3030
updateHeatmapActivityTypesUseCase: container.resolve(UpdateHeatmapActivityTypesUseCase.self)
3131
)
32-
self.settingsViewModel = SettingsViewModel(
33-
deleteAuthUseCase: container.resolve(DeleteAuthUseCase.self),
34-
signOutUseCase: container.resolve(SignOutUseCase.self),
35-
networkConnectivityUseCase: container.resolve(ObserveNetworkConnectivityUseCase.self),
36-
systemThemeUseCase: container.resolve(ObserveSystemThemeUseCase.self),
37-
updateSystemThemeUseCase: container.resolve(UpdateSystemThemeUseCase.self),
38-
fetchWebPageImageDirSizeUseCase: container.resolve(FetchWebPageImageDirSizeUseCase.self),
39-
clearWebPageImageDirectoryUseCase: container.resolve(ClearWebPageImageDirectoryUseCase.self)
40-
)
32+
self.settingsStore = Store(initialState: SettingsFeature.State()) {
33+
SettingsFeature()
34+
} withDependencies: {
35+
$0.deleteAuthUseCase = container.resolve(DeleteAuthUseCase.self)
36+
$0.signOutUseCase = container.resolve(SignOutUseCase.self)
37+
$0.networkConnectivityUseCase = container.resolve(ObserveNetworkConnectivityUseCase.self)
38+
$0.systemThemeUseCase = container.resolve(ObserveSystemThemeUseCase.self)
39+
$0.updateSystemThemeUseCase = container.resolve(UpdateSystemThemeUseCase.self)
40+
$0.fetchWebPageImageDirSizeUseCase = container.resolve(FetchWebPageImageDirSizeUseCase.self)
41+
$0.clearWebPageImageDirectoryUseCase = container.resolve(ClearWebPageImageDirectoryUseCase.self)
42+
}
43+
self.settingsStore.send(.startObserving)
4144
}
4245

4346
func fetchData() {

0 commit comments

Comments
 (0)