diff --git a/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature_Combine/MyFeature/MyPageButton_Refactor.swift b/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature_Combine/MyFeature/MyPageButton_Refactor.swift index 14a9f6a3..f07c9cd0 100644 --- a/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature_Combine/MyFeature/MyPageButton_Refactor.swift +++ b/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature_Combine/MyFeature/MyPageButton_Refactor.swift @@ -13,8 +13,6 @@ import DSKit struct MyPageButton_Refactor: View { - @ObservedObject var viewModel: MyPageViewModel_Refactor - var buttonType: MyPageButtonType_Refactor var body: some View { diff --git a/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature_Combine/MyFeature/MyPageViewModel_Refactor.swift b/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature_Combine/MyFeature/MyPageViewModel_Refactor.swift index e05e2774..fe1143df 100644 --- a/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature_Combine/MyFeature/MyPageViewModel_Refactor.swift +++ b/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature_Combine/MyFeature/MyPageViewModel_Refactor.swift @@ -6,7 +6,6 @@ // import SwiftUI - import Combine import Core @@ -21,26 +20,34 @@ class MyPageViewModel_Refactor: ObservableObject { self.container = container } - @Published var alertType: CustomAlertType = .logout - @Published var name = "" - @Published var point = 0 - @Published var navigateToPrepare = false + @Published private(set) var state = State( + alertType: .logout, + name: "", + point: 0 + ) //MARK: Action + enum Action { case getUserData case revokeUser case logout } + struct State { + var alertType: CustomAlertType + var name: String + var point: Int + } + func send(action: Action) { switch action { case .getUserData: container.services.userService.getUserData() - .sink { _ in + .sink { _ in } receiveValue: { [weak self] data in - self?.name = data.data?.name ?? "" - self?.point = data.data?.point ?? 0 + self?.state.name = data.data?.name ?? "" + self?.state.point = data.data?.point ?? 0 }.store(in: cancelBag) case .revokeUser: diff --git a/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature_Combine/MyFeature/MyPageView_Refactor.swift b/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature_Combine/MyFeature/MyPageView_Refactor.swift index 20542a2d..cf862b76 100644 --- a/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature_Combine/MyFeature/MyPageView_Refactor.swift +++ b/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature_Combine/MyFeature/MyPageView_Refactor.swift @@ -11,8 +11,6 @@ import DSKit import Core public struct MyPageView_Refactor: View { - - @State private var isPresented: Bool = false @StateObject var viewModel: MyPageViewModel_Refactor @@ -73,7 +71,6 @@ extension MyPageView_Refactor { Image(uiImage: DSKitAsset.profile.image) .frame(width: 54, height: 54) .padding(10) - //TODO: 서버통신이랑 이어지는 부분이라서 Text(viewModel.name) .font(.title4_semibold_20) Spacer() @@ -81,7 +78,6 @@ extension MyPageView_Refactor { HStack { Text(StringLiteral.MyPageAccountControl.point) .font(.text6_medium_14) - //TODO: 서버통신이랑 이어지는 부분이라서 Text("\(viewModel.point)") .font(.text6_medium_14) } @@ -95,8 +91,8 @@ extension MyPageView_Refactor { } private func MyInfoView() -> some View { VStack(spacing: 0) { - MyPageButton_Refactor(viewModel: viewModel, buttonType: .travel) - MyPageButton_Refactor(viewModel: viewModel, buttonType: .market) + MyPageButton_Refactor(buttonType: .travel) + MyPageButton_Refactor(buttonType: .market) } .background(DSKitAsset.gray7.swiftUIColor) } @@ -106,8 +102,8 @@ extension MyPageView_Refactor { .font(.text4_semibold_16) .foregroundColor(DSKitAsset.gray2.swiftUIColor) .padding(.vertical, 14) - MyPageButton_Refactor(viewModel: viewModel, buttonType: .info) - MyPageButton_Refactor(viewModel: viewModel, buttonType: .term) + MyPageButton_Refactor(buttonType: .info) + MyPageButton_Refactor(buttonType: .term) } } private func AccountControlView() -> some View { diff --git a/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature_Combine/Service/Service/AuthService.swift b/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature_Combine/Service/Service/AuthService.swift index 2b36d8a8..927d7297 100644 --- a/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature_Combine/Service/Service/AuthService.swift +++ b/HMH_Tuist_iOS/Projects/Features/MyPageFeature/Sources/Refactor_MyFeature_Combine/Service/Service/AuthService.swift @@ -32,6 +32,7 @@ class StubAuthService: AuthServiceType { func revokeUser() -> AnyPublisher { Empty().eraseToAnyPublisher() } + func logoutUser() -> AnyPublisher { Empty().eraseToAnyPublisher() }