From e8155d31ff77072bdedd9c0597a7e101c57eaeaa Mon Sep 17 00:00:00 2001 From: HELLOHIDI Date: Tue, 13 Aug 2024 14:14:11 +0900 Subject: [PATCH] =?UTF-8?q?[Refacotr/#84]=20DIContainer=20=EC=83=9D?= =?UTF-8?q?=EC=84=B1=20=EB=B0=8F=20ServiceLayer=20=EA=B5=AC=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Refactor_MyFeature/DIContainer.swift | 17 +++++++++++ .../MyPageButton_Refactor.swift | 2 +- .../MyPageViewModel_Refactor.swift | 2 ++ .../{ => MyFeature}/MyPageView_Refactor.swift | 0 .../Service/AuthService.swift | 16 ++++++++++ .../Refactor_MyFeature/Service/Services.swift | 30 +++++++++++++++++++ .../Service/UserService.swift | 16 ++++++++++ .../Sources/Views/MyPageView.swift | 23 ++++++++++---- 8 files changed, 99 insertions(+), 7 deletions(-) create mode 100644 HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/DIContainer.swift rename HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/{ => MyFeature}/MyPageButton_Refactor.swift (95%) rename HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/{ => MyFeature}/MyPageViewModel_Refactor.swift (99%) rename HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/{ => MyFeature}/MyPageView_Refactor.swift (100%) create mode 100644 HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/Service/AuthService.swift create mode 100644 HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/Service/Services.swift create mode 100644 HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/Service/UserService.swift diff --git a/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/DIContainer.swift b/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/DIContainer.swift new file mode 100644 index 00000000..ceec7d88 --- /dev/null +++ b/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/DIContainer.swift @@ -0,0 +1,17 @@ +// +// DIContainer.swift +// MyPageFeatureInterface +// +// Created by 류희재 on 8/13/24. +// Copyright © 2024 HMH-iOS. All rights reserved. +// + +import Foundation + +class DIContainer: ObservableObject { + var repositorys: RepositoryType + + init(repositorys: RepositoryType) { + self.repositorys = repositorys + } +} diff --git a/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/MyPageButton_Refactor.swift b/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/MyFeature/MyPageButton_Refactor.swift similarity index 95% rename from HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/MyPageButton_Refactor.swift rename to HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/MyFeature/MyPageButton_Refactor.swift index e9acd50a..f1217442 100644 --- a/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/MyPageButton_Refactor.swift +++ b/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/MyFeature/MyPageButton_Refactor.swift @@ -13,7 +13,7 @@ import DSKit struct MyPageButton_Refactor: View { -// @ObservedObject var viewModel: MyPageViewModel_Refactor + @ObservedObject var viewModel: MyPageViewModel_Refactor var buttonType: MyPageButtonType diff --git a/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/MyPageViewModel_Refactor.swift b/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/MyFeature/MyPageViewModel_Refactor.swift similarity index 99% rename from HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/MyPageViewModel_Refactor.swift rename to HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/MyFeature/MyPageViewModel_Refactor.swift index 2b22b886..bc7c2a1b 100644 --- a/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/MyPageViewModel_Refactor.swift +++ b/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/MyFeature/MyPageViewModel_Refactor.swift @@ -49,6 +49,8 @@ class MyPageViewModel_Refactor: ObservableObject { @Published var point = 0 @Published var navigateToPrepare = false + + //TODO: 네트워크 부분은 의존성 정리한 뒤에 다시 연결해봅시다 func getUserData() { // let provider = Providers.myPageProvider diff --git a/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/MyPageView_Refactor.swift b/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/MyFeature/MyPageView_Refactor.swift similarity index 100% rename from HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/MyPageView_Refactor.swift rename to HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/MyFeature/MyPageView_Refactor.swift diff --git a/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/Service/AuthService.swift b/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/Service/AuthService.swift new file mode 100644 index 00000000..1d2d8751 --- /dev/null +++ b/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/Service/AuthService.swift @@ -0,0 +1,16 @@ +// +// AuthService.swift +// MyPageFeatureInterface +// +// Created by 류희재 on 8/13/24. +// Copyright © 2024 HMH-iOS. All rights reserved. +// + +import Foundation + +protocol AuthServiceType { +} + +class AuthService: AuthServiceType {} + +class StubAuthService: AuthServiceType {} diff --git a/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/Service/Services.swift b/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/Service/Services.swift new file mode 100644 index 00000000..e1865acd --- /dev/null +++ b/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/Service/Services.swift @@ -0,0 +1,30 @@ +// +// Services.swift +// MyPageFeatureInterface +// +// Created by 류희재 on 8/13/24. +// Copyright © 2024 HMH-iOS. All rights reserved. +// + +import Foundation + +protocol ServiceType { + var authService: AuthenticationServiceType { get set } + var userService: UserServiceType { get set } +} + +class Services: ServiceType { + var authService: AuthenticationServiceType + var userService: UserServiceType + + init() { + self.authService = AuthenticationService() + self.userService = UserService(dbRepository: UserDBRepository()) + } +} + +class StubService: ServiceType { + var authService: AuthenticationServiceType = StubAuthenticationService() + var userService: UserServiceType = StubUserService() +} + diff --git a/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/Service/UserService.swift b/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/Service/UserService.swift new file mode 100644 index 00000000..d3f3515e --- /dev/null +++ b/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature/Service/UserService.swift @@ -0,0 +1,16 @@ +// +// UserService.swift +// MyPageFeatureInterface +// +// Created by 류희재 on 8/13/24. +// Copyright © 2024 HMH-iOS. All rights reserved. +// + +import Foundation + +protocol UserServiceType { +} + +class UserService: UserServiceType {} + +class StubUserService: UserServiceType {} diff --git a/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Views/MyPageView.swift b/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Views/MyPageView.swift index ec3712a6..98d61c71 100644 --- a/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Views/MyPageView.swift +++ b/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Views/MyPageView.swift @@ -80,15 +80,26 @@ extension MyPageView { } } private func AccountControlView() -> some View { - HStack { - Text(StringLiteral.MyPageAccountControl.logout) - .font(.text6_medium_14) + HStack(spacing: 19) { + Button(action: { + viewModel.logoutButtonClicked() + }) { + Text(StringLiteral.MyPageAccountControl.logout) + .font(.text6_medium_14) + } + .foregroundColor(DSKitAsset.gray3.swiftUIColor) + Rectangle() .frame(width: 1, height: 16) - Text(StringLiteral.MyPageAccountControl.revoke) - .font(.text6_medium_14) + + Button(action: { + viewModel.withdrawButtonClicked() + }) { + Text(StringLiteral.MyPageAccountControl.revoke) + .font(.text6_medium_14) + } + .foregroundColor(DSKitAsset.gray3.swiftUIColor) } - .foregroundColor(DSKitAsset.gray3.swiftUIColor) .frame(height: 77) } }