Skip to content

Commit

Permalink
♻️ :: [#79] 학생 회원가입 로직에 공통 회원가입 로직 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
shwaaaa committed Jan 2, 2024
1 parent 164c086 commit 118ce29
Show file tree
Hide file tree
Showing 2 changed files with 99 additions and 11 deletions.
93 changes: 86 additions & 7 deletions App/Sources/Feature/StudentSignUpFeature/StudentSignUpView.swift
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import SwiftUI
import Service

struct StudentSignUpView: View {
@StateObject var viewModel: StudentSignUpViewModel
Expand All @@ -12,7 +13,7 @@ struct StudentSignUpView: View {
signupTitleSection()

VStack(spacing: 16) {
switch viewModel.userRole {
switch viewModel.selectedUserRole {
case .student:
ConditionView(viewModel.grade != nil && viewModel.classRoom != nil && viewModel.number != nil) {
inputAuthorizationInfoSection()
Expand Down Expand Up @@ -113,6 +114,17 @@ struct StudentSignUpView: View {
)
.frame(height: 415)
}
.bitgouelBottomSheet(
isShowing: $viewModel.isPresentedAssociationSheet
) {
associationTypeView()
}
.bitgouelBottomSheet(
isShowing: $viewModel.isPresentedUserRoleSheet
) {
userRoleTypeView()
}
.animation(.default, value: viewModel.selectedAssociation)
.background(
NavigationLink(
destination: SuccessSignUpView(),
Expand Down Expand Up @@ -215,15 +227,24 @@ struct StudentSignUpView: View {
@ViewBuilder
func inputSchoolInfoSection() -> some View {
VStack(spacing: 16) {
AssociationSelectButton(
text: viewModel.selectedSchool?.display() ?? "학교"
) {
isSchool.toggle()
ConditionView(viewModel.selectedUserRole != nil) {
AssociationSelectButton(
text: viewModel.selectedSchool?.display() ?? "학교"
) {
isSchool.toggle()
}
}

AssociationSelectButton(text: viewModel.userRole.display())
ConditionView(viewModel.selectedAssociation != nil) {
AssociationSelectButton(text: viewModel.selectedUserRole?.display() ?? "직업") {
viewModel.isPresentedUserRoleSheet = true
}
}

AssociationSelectButton(text: viewModel.selectedAssociation?.associationValue() ?? "소속") {
viewModel.isPresentedAssociationSheet = true
}

AssociationSelectButton(text: "학생")
}
}

Expand Down Expand Up @@ -310,4 +331,62 @@ struct StudentSignUpView: View {
.padding(.bottom, -20)
}
}

@ViewBuilder
func userRoleTypeView() -> some View {
ScrollView {
let data: [UserAuthorityType] = viewModel.selectedAssociation == .school
? [.student, .teacher]
: [.companyInstructor, .professor, .bbozzack, .government]
ForEach(data, id: \.self) { userRole in
HStack {
Text(userRole.display())

Spacer()

BitgouelRadioButton(
isSelected: Binding(
get: { viewModel.selectedUserRole == userRole },
set: { isSelected in
if isSelected {
viewModel.isPresentedUserRoleSheet = false
viewModel.selectedUserRole = userRole

}
}
)
)
}
.padding(.horizontal, 28)
.padding(.vertical, 24)
}
}
}

@ViewBuilder
func associationTypeView() -> some View {
ScrollView {
ForEach(AssociationType.allCases, id: \.self) { association in
HStack {
Text(association.associationValue())

Spacer()

BitgouelRadioButton(
isSelected: Binding(
get: { viewModel.selectedAssociation == association },
set: { isSelected in
if isSelected {
viewModel.isPresentedAssociationSheet = false
viewModel.selectedAssociation = association
}
}
)
)
}
.padding(.horizontal, 28)
.padding(.vertical, 24)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ class StudentSignUpViewModel: BaseViewModel {
@Published var classRoom: Int?
@Published var number: Int?
@Published var studentID: String = ""
@Published var userRole: UserAuthorityType = .student
@Published var isPresentedAssociationSheet = false
@Published var isPresentedUserRoleSheet = false
@Published var selectedAssociation: AssociationType?
@Published var selectedUserRole: UserAuthorityType?
private var timer: Timer?
private let studentSignupUseCase: StudentSignupUseCase
private let teacherSignupUseCase: TeacherSignupUseCase
Expand Down Expand Up @@ -74,10 +77,16 @@ class StudentSignUpViewModel: BaseViewModel {
}

var titleMessage: String {
if selectedAssociation == nil {
return "만나서 반가워요!"
}
if selectedUserRole == nil {
return "무슨 일을 하시나요?"
}
if selectedSchool == nil {
return "학교 선택"
}
switch userRole {
switch selectedUserRole {
case .student:
if selectedClub == "동아리" {
return "동아리 선택"
Expand Down Expand Up @@ -139,7 +148,7 @@ class StudentSignUpViewModel: BaseViewModel {
}

var subTitleMessage: String {
switch userRole {
switch selectedUserRole {
case .student:
if selectedSchool == nil {
return "재학 중이신 학교를 선택해 주세요!"
Expand Down Expand Up @@ -289,7 +298,7 @@ class StudentSignUpViewModel: BaseViewModel {
guard let grade else { return }
guard let classRoom else { return }
guard let number else { return }
switch userRole {
switch selectedUserRole {
case .student:
studentSignup(
grade: grade,
Expand Down

0 comments on commit 118ce29

Please sign in to comment.