From 8629a59fefd625cd91cf3b25222e1082b29c5f12 Mon Sep 17 00:00:00 2001 From: YuleGlycerine Date: Sun, 27 Oct 2024 16:59:23 +0900 Subject: [PATCH] =?UTF-8?q?Feat:=20SignUpView=20DI=20Container=20=EB=B0=98?= =?UTF-8?q?=EC=98=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Kabinett/Application/KabinettApp.swift | 11 ----------- .../View/SignUp/SignUpKabinettNumberSelectView.swift | 2 +- .../View/SignUp/SignUpNameInputView.swift | 4 ++-- Kabinett/Presentation/View/SignUp/SignUpView.swift | 12 ++++++++++-- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/Kabinett/Application/KabinettApp.swift b/Kabinett/Application/KabinettApp.swift index a9d184b..7182bf0 100644 --- a/Kabinett/Application/KabinettApp.swift +++ b/Kabinett/Application/KabinettApp.swift @@ -22,9 +22,6 @@ struct KabinettApp: App { // MARK: - Profile Flow @StateObject private var profileViewModel: ProfileViewModel - // MARK: - SignUp Flow - @StateObject private var signUpViewModel: SignUpViewModel - // MARK: - Componets Flow @StateObject private var imagePickerViewModel: ImagePickerViewModel @StateObject private var customTabViewModel: CustomTabViewModel @@ -120,13 +117,6 @@ struct KabinettApp: App { ) ) - // MARK: - SignUp ViewModel - _signUpViewModel = .init( - wrappedValue: SignUpViewModel( - signUpUseCase: signUpUseCase - ) - ) - // MARK: - Componets ViewModels _imagePickerViewModel = .init( wrappedValue: ImagePickerViewModel( @@ -174,7 +164,6 @@ struct KabinettApp: App { .environmentObject(letterBoxDetailViewModel) .environmentObject(calendarViewModel) .environmentObject(profileViewModel) - .environmentObject(signUpViewModel) .environmentObject(imagePickerViewModel) .environmentObject(customTabViewModel) .environmentObject(userSelectionViewModel) diff --git a/Kabinett/Presentation/View/SignUp/SignUpKabinettNumberSelectView.swift b/Kabinett/Presentation/View/SignUp/SignUpKabinettNumberSelectView.swift index 02a8163..34f5d2a 100644 --- a/Kabinett/Presentation/View/SignUp/SignUpKabinettNumberSelectView.swift +++ b/Kabinett/Presentation/View/SignUp/SignUpKabinettNumberSelectView.swift @@ -8,7 +8,7 @@ import SwiftUI struct SignUpKabinettNumberSelectView: View { - @EnvironmentObject var viewModel: SignUpViewModel + @ObservedObject var viewModel: SignUpViewModel @Environment(\.dismiss) var dismiss let horizontalPadding: CGFloat = UIScreen.main.bounds.width * 0.06 diff --git a/Kabinett/Presentation/View/SignUp/SignUpNameInputView.swift b/Kabinett/Presentation/View/SignUp/SignUpNameInputView.swift index d8d9b8d..74a3626 100644 --- a/Kabinett/Presentation/View/SignUp/SignUpNameInputView.swift +++ b/Kabinett/Presentation/View/SignUp/SignUpNameInputView.swift @@ -8,7 +8,7 @@ import SwiftUI struct SignUpNameInputView: View { - @EnvironmentObject var viewModel: SignUpViewModel + @ObservedObject var viewModel: SignUpViewModel @State private var shouldNavigate = false let horizontalPadding: CGFloat = UIScreen.main.bounds.width * 0.06 @@ -51,7 +51,7 @@ struct SignUpNameInputView: View { .keyboardType(.alphabet) .submitLabel(.done) .navigationDestination(isPresented: $shouldNavigate) { - SignUpKabinettNumberSelectView() + SignUpKabinettNumberSelectView(viewModel: viewModel) } } .frame(maxWidth: .infinity, maxHeight: .infinity) diff --git a/Kabinett/Presentation/View/SignUp/SignUpView.swift b/Kabinett/Presentation/View/SignUp/SignUpView.swift index 9f3e2a9..aefe86b 100644 --- a/Kabinett/Presentation/View/SignUp/SignUpView.swift +++ b/Kabinett/Presentation/View/SignUp/SignUpView.swift @@ -9,9 +9,17 @@ import SwiftUI import AuthenticationServices struct SignUpView: View { - @EnvironmentObject private var viewModel: SignUpViewModel + @StateObject private var viewModel: SignUpViewModel let horizontalPadding: CGFloat = UIScreen.main.bounds.width * 0.06 + init() { + @Injected(SignUpUseCaseKey.self) + var signUpUseCase: SignUpUseCase + + self._viewModel = StateObject( + wrappedValue: SignUpViewModel(signUpUseCase: signUpUseCase)) + } + var body: some View { ZStack { Color.background.ignoresSafeArea(.all) @@ -55,7 +63,7 @@ struct SignUpView: View { viewModel.isLoading ? LoadingView() : nil ) .navigationDestination(isPresented: $viewModel.showSignUpFlow) { - SignUpNameInputView() + SignUpNameInputView(viewModel: viewModel) } .alert( "오류",