Skip to content

Commit

Permalink
🪛[chore]: Navigation 설정
Browse files Browse the repository at this point in the history
  • Loading branch information
Byeonjinha committed Nov 29, 2023
1 parent 5954421 commit 0a4c29c
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 77 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ public class CommonViewViewModel: ObservableObject {
print(selectedFlavorArray)
}
}

@Published public var viewPath: NavigationPath = NavigationPath()

//MARK: 모달 관련
@Published public var offsetY: CGFloat = 30
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,14 @@ public struct LoginView: View {
@StateObject var authViewModel: AuthorizationViewModel = AuthorizationViewModel()
@StateObject var viewModel: OnBoardingViewModel
@StateObject var commonViewViewModel: CommonViewViewModel = CommonViewViewModel()
@State var path: [String] = []

public init(viewModel: OnBoardingViewModel){
self._viewModel = StateObject(wrappedValue: viewModel)
}

public var body: some View {
NavigationStack {
NavigationStack(path: $path) {
VStack(spacing: .zero) {

loadingAnimationView()
Expand All @@ -38,23 +39,25 @@ public struct LoginView: View {
authButton()

}
.navigationDestination(for: String.self) { state in
switch state {
case "isLogin":
OnBoardingLoginView(viewModel: viewModel, path: $path)
.navigationBarBackButtonHidden()
case "isLoginSuccess":
ServiceUseAgreementView(path: $path)
.environmentObject(viewModel)
default:
OnBoardingView(viewModel: viewModel, path: $path)
.navigationBarBackButtonHidden()
}
}
.onAppear{
authViewModel.getRefreshToken()
if authViewModel.isDeletAuth {
authViewModel.deleteAuth = true
}
}

.navigationDestination(isPresented: $viewModel.goToLoginRegisterView) {
OnBoardingView(viewModel: viewModel)
.navigationBarBackButtonHidden()
}

.navigationDestination(isPresented: $viewModel.goToLoginView){
OnBoardingLoginView(viewModel: viewModel)
.navigationBarBackButtonHidden()
}

.popup(isPresented: $authViewModel.deleteAuth) {
WithDrawPOPUP(
image: .empty,
Expand Down Expand Up @@ -143,18 +146,19 @@ public struct LoginView: View {
.frame(height: UIScreen.screenHeight*0.1)

VStack(spacing: .zero) {
RoundedRectangle(cornerRadius: 12)
.stroke(Color.primaryOrange, style: .init(lineWidth: 2))
.frame(height: 56)
.overlay {
Text("로그인하기")
.foregroundStyle(Color.primaryOrangeText)
.pretendardFont(family: .SemiBold, size: 16)
}
.onTapGesture {
viewModel.goToLoginView.toggle()
}

// RoundedRectangle(cornerRadius: 12)
// .stroke(Color.primaryOrange, style: .init(lineWidth: 2))
// .frame(height: 56)
// .overlay {
// Text("로그인하기")
// .foregroundStyle(Color.primaryOrangeText)
// .pretendardFont(family: .SemiBold, size: 16)
// }
// .onTapGesture {
// viewModel.goToLoginView.toggle()
// path.append(LoginViewPageState.isLogin.rawValue)
// }

Spacer()
.frame(height: 8)

Expand All @@ -170,9 +174,8 @@ public struct LoginView: View {
viewModel.isSignUP = true
viewModel.alreadySignUP = false
viewModel.goToLoginRegisterView.toggle()
path.append(LoginViewPageState.isEnter.rawValue)
}


}
.padding(.horizontal, 20)
}
Expand All @@ -184,3 +187,8 @@ extension LoginView {
public static let viewStringKey: String = "LoginView"
}
}

enum LoginViewPageState:String, Hashable {
case isLogin
case isEnter
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,32 +21,28 @@ struct OnBoardingLoginView: View {
@StateObject var commonViewViewModel: CommonViewViewModel = CommonViewViewModel()
@StateObject var sheetManager: SheetManager = SheetManager()

@Binding var path: [String]

@Environment(\.presentationMode) var presentationMode



public init(
viewModel: OnBoardingViewModel

viewModel: OnBoardingViewModel,
path: Binding<[String]>
) {
self._viewModel = ObservedObject(wrappedValue: viewModel)
self._path = path
}

var body: some View {
NavigationStack {
VStack(spacing: .zero) {

loadingAnimationView()

cookeWiseSayingView()

socialLoginButtonView()


}



.navigationDestination(isPresented: $appState.goToMainHomeView) {
CoreView(viewModel: commonViewViewModel, isFistUserPOPUP: $commonViewViewModel.isFirstUserPOPUP)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,35 +21,28 @@ public struct OnBoardingView: View {
@StateObject var viewModel: OnBoardingViewModel
@StateObject var commonViewViewModel: CommonViewViewModel = CommonViewViewModel()
@StateObject var sheetManager: SheetManager = SheetManager()
@Binding var path: [String]

@Environment(\.presentationMode) var presentationMode

public init(
viewModel: OnBoardingViewModel

viewModel: OnBoardingViewModel,
path: Binding<[String]>
) {
self._viewModel = StateObject(wrappedValue: viewModel)
self._path = path
}
public var body: some View {
NavigationStack {
VStack(spacing: .zero) {

loadingAnimationView()

cookeWiseSayingView()

socialLoginButtonView()


}
VStack(spacing: .zero) {

loadingAnimationView()

cookeWiseSayingView()

socialLoginButtonView()

.navigationDestination(isPresented: $appState.serviceUseAgmentView) {
ServiceUseAgreementView()
.environmentObject(viewModel)
}

}


.popup(isPresented: $appState.signUPFaillPOPUP) {
FloaterPOPUP(image: .errorCircle_rounded, floaterTitle: "알림", floaterSubTitle: "애플로그인에 오류가 생겼습니다. 다시 시도해주세요")
Expand All @@ -62,7 +55,7 @@ public struct OnBoardingView: View {
.closeOnTapOutside(true)

}


}

Expand Down Expand Up @@ -116,8 +109,6 @@ public struct OnBoardingView: View {
Spacer()
}
.offset(x: -10)


}
.padding(.horizontal, 20)
}
Expand All @@ -132,17 +123,13 @@ public struct OnBoardingView: View {
.frame(height: 12)

loginWithApple()

}
}

@ViewBuilder
private func loginWithApple() -> some View {
Spacer()
.frame(height: 20)
//mark:



SignInWithAppleButton(.signIn) { request in
authViewModel.nonce = AppleLoginManger.shared.randomNonceString()
Expand All @@ -159,10 +146,12 @@ public struct OnBoardingView: View {
authViewModel.appleLogin(credential: credential)

DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
appState.serviceUseAgmentView.toggle()
path.append(OnboardingViewPageState.isLoginSuccess.rawValue)
print(path)
}

case .failure(let error):

case .failure:
appState.signUPFaillPOPUP.toggle()
presentationMode.wrappedValue.dismiss()
}
Expand All @@ -182,4 +171,6 @@ public struct OnBoardingView: View {
}
}


enum OnboardingViewPageState: String, Hashable {
case isLoginSuccess
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ import SafariServices
import API

public struct ServiceUseAgreementView: View {
public init() { }
public init(path: Binding<[String]>) { self._path = path}
@Environment(\.presentationMode) var presentationMode

@EnvironmentObject var viewModel: OnBoardingViewModel

@Binding var path: [String]

public var body: some View {
ZStack (alignment: .bottom) {
VStack {
Expand Down Expand Up @@ -158,10 +160,3 @@ public struct ServiceUseAgreementView: View {
}
}
}

struct ServiceUseAgmentView_Previews: PreviewProvider {
static var previews: some View {
ServiceUseAgreementView()
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ struct WithDrawView: View {
authViewModel.isDeletAuth = true
authViewModel.isLoginCheck = false
profileViewModel.randomNickName = ""
print("viewModelviewPath", viewModel.viewPath.count)
while !viewModel.viewPath.isEmpty {
viewModel.viewPath.removeLast()
}

presentationMode.wrappedValue.dismiss()

})
Expand Down

0 comments on commit 0a4c29c

Please sign in to comment.