From 0a963ec6311e343b9723ffd0996822b3db3a10a9 Mon Sep 17 00:00:00 2001 From: peng-u-0807 Date: Wed, 2 Oct 2024 17:24:54 +0900 Subject: [PATCH 1/2] Add sendFeedback button to `OnboardScene` --- .../SNUTT/ViewModels/OnboardViewModel.swift | 14 ++ .../SNUTT/Views/Scenes/OnboardScene.swift | 146 ++++++++++-------- 2 files changed, 96 insertions(+), 64 deletions(-) diff --git a/SNUTT-2022/SNUTT/ViewModels/OnboardViewModel.swift b/SNUTT-2022/SNUTT/ViewModels/OnboardViewModel.swift index 359bb799..107fda82 100644 --- a/SNUTT-2022/SNUTT/ViewModels/OnboardViewModel.swift +++ b/SNUTT-2022/SNUTT/ViewModels/OnboardViewModel.swift @@ -40,6 +40,20 @@ extension OnboardScene { return false } } + + func sendFeedback(email: String, message: String) async -> Bool { + if !Validation.check(email: email) { + services.globalUIService.presentErrorAlert(error: .INVALID_EMAIL) + return false + } + do { + try await services.etcService.sendFeedback(email: email, message: message) + return true + } catch { + services.globalUIService.presentErrorAlert(error: error) + return false + } + } func sendVerificationCode(email: String) async -> Bool { do { diff --git a/SNUTT-2022/SNUTT/Views/Scenes/OnboardScene.swift b/SNUTT-2022/SNUTT/Views/Scenes/OnboardScene.swift index 131044be..4062ca3f 100644 --- a/SNUTT-2022/SNUTT/Views/Scenes/OnboardScene.swift +++ b/SNUTT-2022/SNUTT/Views/Scenes/OnboardScene.swift @@ -12,6 +12,7 @@ struct OnboardScene: View { @State private var pushToSignUpScene = false @State private var pushToLoginScene = false + @State private var pushToFeedbackView = false @Binding var pushToTimetableScene: Bool @Namespace private var launchScreenAnimation @@ -21,82 +22,97 @@ struct OnboardScene: View { var body: some View { ZStack { if isActivated { - VStack(spacing: 15) { - Spacer() - .frame(height: 200) - - Logo(orientation: .vertical) - .matchedGeometryEffect(id: logoId, in: launchScreenAnimation) - - VStack { + GeometryReader { proxy in + VStack(spacing: 0) { Spacer() - Button { - pushToLoginScene = true - } label: { - Text("로그인") - .font(.system(size: 14, weight: .bold)) - .foregroundColor(.white) - .frame(maxWidth: .infinity, maxHeight: 41) - .background( - RoundedRectangle(cornerRadius: 10, style: .continuous) - .foregroundColor(STColor.cyan) - ) - } - .padding(.horizontal, 32) + Logo(orientation: .vertical) + .matchedGeometryEffect(id: logoId, in: launchScreenAnimation) + + Spacer().frame(height: proxy.size.height * 0.16) - Button { - pushToSignUpScene = true - } label: { - Text("회원가입") - .font(.system(size: 14, weight: .semibold)) - .foregroundColor(.init(uiColor: .label)) - .padding(.top, 12) - .padding(.bottom, 40) - } - - HStack(spacing: 10) { - Rectangle() - .fill(STColor.gray20) - .frame(height: 1) - Text("SNS 계정으로 계속하기") - .font(.system(size: 14, weight: .semibold)) - .foregroundColor(STColor.gray20) - .fixedSize(horizontal: true, vertical: false) - Rectangle() - .fill(STColor.gray20) - .frame(height: 1) - } - .padding(.bottom, 24) - - HStack(spacing: 12) { - Button { - viewModel.performKakaoSignIn() - } label: { - Image("sns.kakao") + VStack(spacing: 0) { + VStack(spacing: 14) { + Button { + pushToLoginScene = true + } label: { + Text("로그인") + .font(.system(size: 15, weight: .bold)) + .foregroundColor(.white) + .padding(.vertical, 12) + .frame(maxWidth: .infinity) + .background( + RoundedRectangle(cornerRadius: 6, style: .continuous) + .foregroundColor(STColor.cyan) + ) + } + .padding(.horizontal, 20) + + Button { + pushToSignUpScene = true + } label: { + Text("회원가입") + .font(.system(size: 14, weight: .semibold)) + .foregroundColor(STColor.darkerGray) + } } - Button { - viewModel.performGoogleSignIn() - } label: { - Image("sns.google") + + Spacer().frame(height: proxy.size.height * 0.07) + + HStack(spacing: 10) { + Rectangle() + .fill(STColor.gray20) + .frame(height: 1) + Text("SNS 계정으로 계속하기") + .font(.system(size: 14, weight: .semibold)) + .foregroundColor(STColor.gray20) + .fixedSize(horizontal: true, vertical: false) + Rectangle() + .fill(STColor.gray20) + .frame(height: 1) } - Button { - viewModel.performFacebookSignIn() - } label: { - Image("sns.facebook") + + Spacer().frame(height: 24) + + HStack(spacing: 12) { + Button { + viewModel.performKakaoSignIn() + } label: { + Image("sns.kakao") + } + Button { + viewModel.performGoogleSignIn() + } label: { + Image("sns.google") + } + Button { + viewModel.performFacebookSignIn() + } label: { + Image("sns.facebook") + } + Button { + viewModel.performAppleSignIn() + } label: { + Image("sns.apple") + } } + + Spacer().frame(height: proxy.size.height * 0.06) + Button { - viewModel.performAppleSignIn() + pushToFeedbackView = true } label: { - Image("sns.apple") + Text("로그인/회원가입에 문제가 생겼나요?") + .font(.system(size: 14, weight: .semibold)) + .foregroundStyle(STColor.gray2) } } - - Spacer() + .padding(.horizontal, 12) + + Spacer().frame(height: proxy.size.height * 0.05) } - .padding(.horizontal, 12) + .transition(.scale(scale: 1)) } - .transition(.scale(scale: 1)) } else { VStack { Spacer() @@ -114,6 +130,8 @@ struct OnboardScene: View { NavigationLink(destination: SignUpView(registerLocalId: viewModel.registerWith(id:password:email:), sendVerificationCode: viewModel.sendVerificationCode(email:), checkVerificationCode: viewModel.submitVerificationCode(code:), pushToTimetableScene: $pushToTimetableScene), isActive: $pushToSignUpScene) { EmptyView() } NavigationLink(destination: LoginScene(viewModel: .init(container: viewModel.container), moveToTimetableScene: $pushToTimetableScene), isActive: $pushToLoginScene) { EmptyView() } + + NavigationLink(destination: UserSupportView(email: nil, sendFeedback: viewModel.sendFeedback(email:message:)), isActive: $pushToFeedbackView) { EmptyView() } } ) .onLoad { From 2aac20278d45eb69f35b13095981d81c0ddecbda Mon Sep 17 00:00:00 2001 From: peng-u-0807 Date: Wed, 2 Oct 2024 08:26:33 +0000 Subject: [PATCH 2/2] Apply SwiftFormat changes --- SNUTT-2022/SNUTT/ViewModels/OnboardViewModel.swift | 2 +- SNUTT-2022/SNUTT/Views/Scenes/OnboardScene.swift | 14 +++++++------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/SNUTT-2022/SNUTT/ViewModels/OnboardViewModel.swift b/SNUTT-2022/SNUTT/ViewModels/OnboardViewModel.swift index 107fda82..938f2406 100644 --- a/SNUTT-2022/SNUTT/ViewModels/OnboardViewModel.swift +++ b/SNUTT-2022/SNUTT/ViewModels/OnboardViewModel.swift @@ -40,7 +40,7 @@ extension OnboardScene { return false } } - + func sendFeedback(email: String, message: String) async -> Bool { if !Validation.check(email: email) { services.globalUIService.presentErrorAlert(error: .INVALID_EMAIL) diff --git a/SNUTT-2022/SNUTT/Views/Scenes/OnboardScene.swift b/SNUTT-2022/SNUTT/Views/Scenes/OnboardScene.swift index 4062ca3f..f51353c6 100644 --- a/SNUTT-2022/SNUTT/Views/Scenes/OnboardScene.swift +++ b/SNUTT-2022/SNUTT/Views/Scenes/OnboardScene.swift @@ -28,7 +28,7 @@ struct OnboardScene: View { Logo(orientation: .vertical) .matchedGeometryEffect(id: logoId, in: launchScreenAnimation) - + Spacer().frame(height: proxy.size.height * 0.16) VStack(spacing: 0) { @@ -47,7 +47,7 @@ struct OnboardScene: View { ) } .padding(.horizontal, 20) - + Button { pushToSignUpScene = true } label: { @@ -56,7 +56,7 @@ struct OnboardScene: View { .foregroundColor(STColor.darkerGray) } } - + Spacer().frame(height: proxy.size.height * 0.07) HStack(spacing: 10) { @@ -71,7 +71,7 @@ struct OnboardScene: View { .fill(STColor.gray20) .frame(height: 1) } - + Spacer().frame(height: 24) HStack(spacing: 12) { @@ -98,7 +98,7 @@ struct OnboardScene: View { } Spacer().frame(height: proxy.size.height * 0.06) - + Button { pushToFeedbackView = true } label: { @@ -108,7 +108,7 @@ struct OnboardScene: View { } } .padding(.horizontal, 12) - + Spacer().frame(height: proxy.size.height * 0.05) } .transition(.scale(scale: 1)) @@ -130,7 +130,7 @@ struct OnboardScene: View { NavigationLink(destination: SignUpView(registerLocalId: viewModel.registerWith(id:password:email:), sendVerificationCode: viewModel.sendVerificationCode(email:), checkVerificationCode: viewModel.submitVerificationCode(code:), pushToTimetableScene: $pushToTimetableScene), isActive: $pushToSignUpScene) { EmptyView() } NavigationLink(destination: LoginScene(viewModel: .init(container: viewModel.container), moveToTimetableScene: $pushToTimetableScene), isActive: $pushToLoginScene) { EmptyView() } - + NavigationLink(destination: UserSupportView(email: nil, sendFeedback: viewModel.sendFeedback(email:message:)), isActive: $pushToFeedbackView) { EmptyView() } } )