diff --git a/Projects/App/Sources/Application/DI/AppComponent.swift b/Projects/App/Sources/Application/DI/AppComponent.swift index 3ee45609..b9cd54e6 100644 --- a/Projects/App/Sources/Application/DI/AppComponent.swift +++ b/Projects/App/Sources/Application/DI/AppComponent.swift @@ -30,6 +30,9 @@ public extension AppComponent { var signinComponent: SigninComponent { SigninComponent(parent: self) } + var schoolConfirmationQuestionsComponent: SchoolConfirmationQuestionsComponent { + SchoolConfirmationQuestionsComponent(parent: self) + } var signupEmailVerifyComponent: SignupEmailVerifyComponent { SignupEmailVerifyComponent(parent: self) } diff --git a/Projects/App/Sources/Application/NeedleGenerated.swift b/Projects/App/Sources/Application/NeedleGenerated.swift index 5c42b4ce..8a16c732 100644 --- a/Projects/App/Sources/Application/NeedleGenerated.swift +++ b/Projects/App/Sources/Application/NeedleGenerated.swift @@ -25,6 +25,19 @@ private func parent1(_ component: NeedleFoundation.Scope) -> NeedleFoundation.Sc #if !NEEDLE_DYNAMIC +private class SchoolConfirmationQuestionsDependency3fa2ccd12da7c7f5cfc1Provider: SchoolConfirmationQuestionsDependency { + var checkSchoolQuestionUseCase: any CheckSchoolQuestionUseCase { + return appComponent.checkSchoolQuestionUseCase + } + private let appComponent: AppComponent + init(appComponent: AppComponent) { + self.appComponent = appComponent + } +} +/// ^->AppComponent->SchoolConfirmationQuestionsComponent +private func factoryd462667f0418a53210fcf47b58f8f304c97af4d5(_ component: NeedleFoundation.Scope) -> AnyObject { + return SchoolConfirmationQuestionsDependency3fa2ccd12da7c7f5cfc1Provider(appComponent: parent1(component) as! AppComponent) +} private class SchoolCodeDependencyc0114744c1c8c7843672Provider: SchoolCodeDependency { var checkSchoolCodeUseCase: any CheckSchoolCodeUseCase { return appComponent.checkSchoolCodeUseCase @@ -153,6 +166,7 @@ extension AppComponent: Registration { localTable["schoolCodeComponent-SchoolCodeComponent"] = { self.schoolCodeComponent as Any } localTable["findIDComponent-FindIDComponent"] = { self.findIDComponent as Any } localTable["signinComponent-SigninComponent"] = { self.signinComponent as Any } + localTable["schoolConfirmationQuestionsComponent-SchoolConfirmationQuestionsComponent"] = { self.schoolConfirmationQuestionsComponent as Any } localTable["signupEmailVerifyComponent-SignupEmailVerifyComponent"] = { self.signupEmailVerifyComponent as Any } localTable["signupEmailAuthCodeVerifyComponent-SignupEmailAuthCodeVerifyComponent"] = { self.signupEmailAuthCodeVerifyComponent as Any } localTable["signupProfileImageComponent-SignupProfileImageComponent"] = { self.signupProfileImageComponent as Any } @@ -180,6 +194,11 @@ extension AppComponent: Registration { localTable["checkSchoolCodeUseCase-any CheckSchoolCodeUseCase"] = { self.checkSchoolCodeUseCase as Any } } } +extension SchoolConfirmationQuestionsComponent: Registration { + public func registerItems() { + keyPathToName[\SchoolConfirmationQuestionsDependency.checkSchoolQuestionUseCase] = "checkSchoolQuestionUseCase-any CheckSchoolQuestionUseCase" + } +} extension SchoolCodeComponent: Registration { public func registerItems() { keyPathToName[\SchoolCodeDependency.checkSchoolCodeUseCase] = "checkSchoolCodeUseCase-any CheckSchoolCodeUseCase" @@ -240,6 +259,7 @@ private func registerProviderFactory(_ componentPath: String, _ factory: @escapi private func register1() { registerProviderFactory("^->AppComponent", factoryEmptyDependencyProvider) + registerProviderFactory("^->AppComponent->SchoolConfirmationQuestionsComponent", factoryd462667f0418a53210fcf47b58f8f304c97af4d5) registerProviderFactory("^->AppComponent->SchoolCodeComponent", factoryb65c1efbf06b87162473f47b58f8f304c97af4d5) registerProviderFactory("^->AppComponent->SignupEmailAuthCodeVerifyComponent", factoryb06be35aa893adde971bf47b58f8f304c97af4d5) registerProviderFactory("^->AppComponent->SignupEmailVerifyComponent", factory3b1904c76335d70151ebf47b58f8f304c97af4d5) diff --git a/Projects/Features/SignupFeature/Sources/SchoolCode/SchoolCodeView.swift b/Projects/Features/SignupFeature/Sources/SchoolCode/SchoolCodeView.swift index 7e43acef..63946ef6 100644 --- a/Projects/Features/SignupFeature/Sources/SchoolCode/SchoolCodeView.swift +++ b/Projects/Features/SignupFeature/Sources/SchoolCode/SchoolCodeView.swift @@ -30,9 +30,6 @@ struct SchoolCodeView: View { VStack { DMSPassCodeView(codeCount: 8, text: $viewModel.schoolCode) .padding(.horizontal, 64) - .onChange(of: viewModel.schoolCode) { _ in - viewModel.checkIsEmptyAuthCode() - } Spacer() .frame(height: 24) @@ -42,22 +39,15 @@ struct SchoolCodeView: View { .padding(.horizontal, 24) .frame(height: 40) } + Spacer() DMSWideButton(text: "인증", color: .PrimaryVariant.primary) { viewModel.verifyAuthCodeButtonDidTap() } - .disabled(viewModel.isDisabled) + .disabled(!viewModel.isEnabledVerify) .padding(.bottom, 20) .padding(.horizontal, 24) - .ignoresSafeArea(.keyboard, edges: .bottom) } - - } -} - -struct SignupView_Previews: PreviewProvider { - static var previews: some View { - Text("A") } } diff --git a/Projects/Features/SignupFeature/Sources/SchoolCode/SchoolCodeViewModel.swift b/Projects/Features/SignupFeature/Sources/SchoolCode/SchoolCodeViewModel.swift index 107f2e6b..d977bd86 100644 --- a/Projects/Features/SignupFeature/Sources/SchoolCode/SchoolCodeViewModel.swift +++ b/Projects/Features/SignupFeature/Sources/SchoolCode/SchoolCodeViewModel.swift @@ -4,11 +4,10 @@ import DomainModule final class SchoolCodeViewModel: BaseViewModel { @Published var schoolCode = "" - @Published var isDisabled = true @Published var isNavigateCheckSchool = false - var isSigninButtonEnabled: Bool { - !schoolCode.isEmpty + var isEnabledVerify: Bool { + schoolCode.count == 8 } private let checkSchoolCodeUseCase: any CheckSchoolCodeUseCase @@ -18,7 +17,7 @@ final class SchoolCodeViewModel: BaseViewModel { } func verifyAuthCodeButtonDidTap() { - guard isSigninButtonEnabled else { return } + guard isEnabledVerify else { return } addCancellable( checkSchoolCodeUseCase.execute( code: schoolCode @@ -27,7 +26,4 @@ final class SchoolCodeViewModel: BaseViewModel { self?.isNavigateCheckSchool = true } } - func checkIsEmptyAuthCode() { - isDisabled = 8 != schoolCode.count - } } diff --git a/Projects/Features/SignupFeature/Sources/SchoolConfirmationQuestions/SchoolConfirmationQuestionsComponent.swift b/Projects/Features/SignupFeature/Sources/SchoolConfirmationQuestions/SchoolConfirmationQuestionsComponent.swift new file mode 100644 index 00000000..e5344a10 --- /dev/null +++ b/Projects/Features/SignupFeature/Sources/SchoolConfirmationQuestions/SchoolConfirmationQuestionsComponent.swift @@ -0,0 +1,17 @@ +import DomainModule +import NeedleFoundation +import SwiftUI + +public protocol SchoolConfirmationQuestionsDependency: Dependency { + var checkSchoolQuestionUseCase: any CheckSchoolQuestionUseCase { get } +} + +public final class SchoolConfirmationQuestionsComponent: Component { + public func makeView() -> some View { + SchoolConfirmationQuestionsView( + viewModel: .init( + checkSchoolQuestionUseCase: dependency.checkSchoolQuestionUseCase + ) + ) + } +} diff --git a/Projects/Features/SignupFeature/Sources/SchoolConfirmationQuestions/SchoolConfirmationQuestionsView.swift b/Projects/Features/SignupFeature/Sources/SchoolConfirmationQuestions/SchoolConfirmationQuestionsView.swift new file mode 100644 index 00000000..27f0f3dc --- /dev/null +++ b/Projects/Features/SignupFeature/Sources/SchoolConfirmationQuestions/SchoolConfirmationQuestionsView.swift @@ -0,0 +1,68 @@ +import SwiftUI +import DesignSystem + +struct SchoolConfirmationQuestionsView: View { + @StateObject var viewModel: SchoolConfirmationQuestionsViewModel + + public init(viewModel: SchoolConfirmationQuestionsViewModel) { + _viewModel = StateObject(wrappedValue: viewModel) + } + var body: some View { + VStack { + HStack { + VStack(alignment: .leading, spacing: 8) { + Text("DMS") + .dmsFont(.title(.extraLarge), color: .PrimaryVariant.primary) + + Text("학교 확인 질문") + .dmsFont(.text(.medium), color: .GrayScale.gray6) + + Text("우리 학교 학생 수는?") + .dmsFont(.text(.large), color: .GrayScale.gray7) + .padding(.top, 50) + } + + Spacer() + } + + .padding(.top, 24) + + VStack(spacing: 72) { + DMSFloatingTextField( + "답변", + text: $viewModel.answer, + isError: viewModel.isErrorOcuured + ) + } + .padding(.top, 42) + + Spacer() + + HStack(spacing: 16) { + Text("이미 계정이 있으신가요?") + .dmsFont(.text(.small), color: .GrayScale.gray5) + + DMSButton(text: "로그인", style: .text, color: .GrayScale.gray6) { + } + } + + DMSWideButton(text: "확인", color: .PrimaryVariant.primary) { + viewModel.confirmButtonDidTap() + } + .disabled(!viewModel.isConfirmButtonEnabled) + .padding(.top, 24) + .padding(.bottom, 40) + } + .dmsToast(isShowing: $viewModel.isErrorOcuured, message: viewModel.errorMessage, style: .error) + .frame(maxWidth: .infinity) + .padding(.horizontal, 24) + .dmsBackground() + .ignoresSafeArea(.keyboard, edges: .bottom) + } +} + +struct SchoolConfirmationQuestionsView_Previews: PreviewProvider { + static var previews: some View { + Text("A") + } +} diff --git a/Projects/Features/SignupFeature/Sources/SchoolConfirmationQuestions/SchoolConfirmationQuestionsViewModel.swift b/Projects/Features/SignupFeature/Sources/SchoolConfirmationQuestions/SchoolConfirmationQuestionsViewModel.swift new file mode 100644 index 00000000..8d0fefe6 --- /dev/null +++ b/Projects/Features/SignupFeature/Sources/SchoolConfirmationQuestions/SchoolConfirmationQuestionsViewModel.swift @@ -0,0 +1,30 @@ +import BaseFeature +import Combine +import DomainModule + +final class SchoolConfirmationQuestionsViewModel: BaseViewModel { + @Published var id = "" + @Published var answer = "" + @Published var isDisabled = true + + var isConfirmButtonEnabled: Bool { + !answer.isEmpty + } + + private let checkSchoolQuestionUseCase: any CheckSchoolQuestionUseCase + + public init(checkSchoolQuestionUseCase: any CheckSchoolQuestionUseCase) { + self.checkSchoolQuestionUseCase = checkSchoolQuestionUseCase + } + + func confirmButtonDidTap() { + guard isConfirmButtonEnabled else { return } + addCancellable( + checkSchoolQuestionUseCase.execute( + schoolID: id, + answer: answer + ) + ) { _ in + } + } +}