Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge :: SchoolConfirmationQuestions UI #95

Merged
merged 18 commits into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Projects/App/Sources/Application/DI/AppComponent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
20 changes: 20 additions & 0 deletions Projects/App/Sources/Application/NeedleGenerated.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -18,7 +17,7 @@ final class SchoolCodeViewModel: BaseViewModel {
}

func verifyAuthCodeButtonDidTap() {
guard isSigninButtonEnabled else { return }
guard isEnabledVerify else { return }
addCancellable(
checkSchoolCodeUseCase.execute(
code: schoolCode
Expand All @@ -27,7 +26,4 @@ final class SchoolCodeViewModel: BaseViewModel {
self?.isNavigateCheckSchool = true
}
}
func checkIsEmptyAuthCode() {
isDisabled = 8 != schoolCode.count
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import DomainModule
import NeedleFoundation
import SwiftUI

public protocol SchoolConfirmationQuestionsDependency: Dependency {
var checkSchoolQuestionUseCase: any CheckSchoolQuestionUseCase { get }
}

public final class SchoolConfirmationQuestionsComponent: Component<SchoolConfirmationQuestionsDependency> {
public func makeView() -> some View {
SchoolConfirmationQuestionsView(
viewModel: .init(
checkSchoolQuestionUseCase: dependency.checkSchoolQuestionUseCase
)
)
}
}
Original file line number Diff line number Diff line change
@@ -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")
}
}
Original file line number Diff line number Diff line change
@@ -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
}
}
}