From 118ce291f16b4469ab3ba3e7c4db73580dd6e732 Mon Sep 17 00:00:00 2001 From: shwaaaa Date: Tue, 2 Jan 2024 17:36:35 +0900 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20::=20[#79]=20=ED=95=99?= =?UTF-8?q?=EC=83=9D=20=ED=9A=8C=EC=9B=90=EA=B0=80=EC=9E=85=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=EC=97=90=20=EA=B3=B5=ED=86=B5=20=ED=9A=8C=EC=9B=90?= =?UTF-8?q?=EA=B0=80=EC=9E=85=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../StudentSignUpView.swift | 93 +++++++++++++++++-- .../StudentSignUpViewModel.swift | 17 +++- 2 files changed, 99 insertions(+), 11 deletions(-) diff --git a/App/Sources/Feature/StudentSignUpFeature/StudentSignUpView.swift b/App/Sources/Feature/StudentSignUpFeature/StudentSignUpView.swift index 0d9a9141..1611a2be 100644 --- a/App/Sources/Feature/StudentSignUpFeature/StudentSignUpView.swift +++ b/App/Sources/Feature/StudentSignUpFeature/StudentSignUpView.swift @@ -1,4 +1,5 @@ import SwiftUI +import Service struct StudentSignUpView: View { @StateObject var viewModel: StudentSignUpViewModel @@ -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() @@ -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(), @@ -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: "학생") } } @@ -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) + } + } + } } diff --git a/App/Sources/Feature/StudentSignUpFeature/StudentSignUpViewModel.swift b/App/Sources/Feature/StudentSignUpFeature/StudentSignUpViewModel.swift index d5a2da1d..6f0a6061 100644 --- a/App/Sources/Feature/StudentSignUpFeature/StudentSignUpViewModel.swift +++ b/App/Sources/Feature/StudentSignUpFeature/StudentSignUpViewModel.swift @@ -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 @@ -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 "동아리 선택" @@ -139,7 +148,7 @@ class StudentSignUpViewModel: BaseViewModel { } var subTitleMessage: String { - switch userRole { + switch selectedUserRole { case .student: if selectedSchool == nil { return "재학 중이신 학교를 선택해 주세요!" @@ -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,