Skip to content

Commit

Permalink
🪛[chore] : 로그인 및 로그아웃 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
Roy-wonji committed Nov 6, 2023
1 parent 4a3e3a5 commit dc43bcd
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 270 deletions.
3 changes: 2 additions & 1 deletion PingPong/Projects/App/Sources/Application/PingPongApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ struct PingPongProjectApp: App {
WindowGroup {

ZStack {
if viewModel.isLoginCheck {
if authViewModel.isLoginCheck {
CoreView(viewModel: commonViewViewModel, isFistUserPOPUP: $commonViewViewModel.isFirstUserPOPUP)
.environmentObject(authViewModel)
.environmentObject(sheetManager)
.navigationBarHidden(true)
.onAppear {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ public class AuthorizationViewModel: ObservableObject {
@AppStorage("Uid") public var uid: String = ""
@AppStorage("userUid") public var userUid: String = ""
@AppStorage("userEmail") public var userEmail: String = ""

@Published public var isLoginCheck: Bool = false
@AppStorage("isLogin") public var isLogin: Bool = false {
didSet {
self.isLoginCheck = isLogin
}
}

@Published public var loginStatus: Bool = false
@Published var deleteUser: Bool = false
Expand All @@ -49,6 +54,7 @@ public class AuthorizationViewModel: ObservableObject {
@Published public var userRmk: String = ""

public init() {
isLogin = UserDefaults.standard.bool(forKey: "isLogin")
self.userSession = Auth.auth().currentUser
uid = UserDefaults.standard.string(forKey: "Uid") ?? ""
userid = UserDefaults.standard.integer(forKey: "userId")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import SwiftUI
import DesignSystem
import PopupView
import Archive
//import Authorization
import Authorization
import Model
import Home
import Profile
Expand All @@ -20,7 +20,7 @@ public struct CoreView: View {
@StateObject var appState: AppState = AppState()
@Environment(\.presentationMode) var presentationMode
@Binding var isFistUserPOPUP: Bool

@EnvironmentObject var authViewModel: AuthorizationViewModel
@StateObject var viewModel: CommonViewViewModel

public init(viewModel: CommonViewViewModel, isFistUserPOPUP: Binding<Bool>) {
Expand Down Expand Up @@ -70,7 +70,6 @@ public struct CoreView: View {
}
}
.navigationBarHidden(true)
.ignoresSafeArea()
.onAppear {
self.viewModel.setupCustomTabs()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,19 @@ public struct OnBoardingView: View {
.environmentObject(viewModel)
}

// .fullScreenCover(isPresented: $appState.goToMainHomeView, content: {
// CoreView(viewModel: commonViewViewModel, isFistUserPOPUP: $commonViewViewModel.isFirstUserPOPUP)
// .environmentObject(sheetManager)
// .navigationBarHidden(true)
// })

.navigationDestination(isPresented: $appState.goToMainHomeView) {
CoreView(viewModel: commonViewViewModel, isFistUserPOPUP: $commonViewViewModel.isFirstUserPOPUP)
.environmentObject(sheetManager)
.navigationBarHidden(true)
.environmentObject(authViewModel)
}
}


.popup(isPresented: $appState.signUPFaillPOPUP) {
FloaterPOPUP(image: .errorCircle_rounded, floaterTitle: "알림", floaterSubTitle: "애플로그인에 오류가 생겼습니다. 다시 시도해주세요")
Expand Down Expand Up @@ -160,6 +167,7 @@ public struct OnBoardingView: View {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
if viewModel.completdSignUP {
appState.goToMainHomeView.toggle()
authViewModel.isLogin = true
} else {
if !viewModel.isFirstUser {
appState.serviceUseAgmentView.toggle()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ public struct CompletOnBoardingView: View {
}
.onTapGesture {
//MARK: - 취향 등록 api 성공 후 mainview 로직
viewModel.isLogin = true
authViewModel.isLogin = true
viewModel.isFirstUser = true
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@ public class OnBoardingViewModel: ObservableObject {
@Published var selectedFavoriteFlavor: String = ""
@Published var selectedFavorite: [Favorite] = []
@Published var selectedCharacter: [String] = []
@Published public var isLoginCheck: Bool = false
@AppStorage("isLogin") public var isLogin: Bool = false {
didSet {
self.isLoginCheck = isLogin
}
}
@AppStorage("isFirstUser") public var isFirstUser: Bool = false
@AppStorage("completdSignUP") public var completdSignUP: Bool = false
@AppStorage("isFirstUserPOPUP") public var isFirstUserPOPUP: Bool = false
Expand Down Expand Up @@ -104,7 +98,6 @@ public class OnBoardingViewModel: ObservableObject {

public init() {
isFirstUserPOPUP = UserDefaults.standard.bool(forKey: "isFirstUserPOPUP")
isLogin = UserDefaults.standard.bool(forKey: "isLogin")
isFirstUser = UserDefaults.standard.bool(forKey: "isFirstUser")
completdSignUP = UserDefaults.standard.bool(forKey: "completdSignUP")
}
Expand Down
1 change: 1 addition & 0 deletions PingPong/Projects/Feature/Profile/Project.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ product: .staticFramework,
setting: .appBaseSetting,
dependencies: [
.core(implements: .Common),
.core(implements: .Authorization),
.design(implements: .DesignSystem),
.domain(implements: .Model),
.domain(implements: .Service)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
import Common
import DesignSystem
import Model
import Authorization
import SwiftUI

public struct ProfileView: View {
@StateObject private var appState: AppState
@StateObject private var viewModel: CommonViewViewModel
@StateObject private var profileViewModel: ProfileViewViewModel = ProfileViewViewModel()
@EnvironmentObject var authViewModel: AuthorizationViewModel

@Environment(\.presentationMode) var presentationMode

Expand Down Expand Up @@ -86,6 +88,9 @@ public struct ProfileView: View {
.pretendardFont(family: .Medium, size: 14)
.foregroundColor(.logoutText)
}
.onTapGesture {
authViewModel.isLogin = false
}
}
.navigationBarHidden(true)

Expand Down
Loading

0 comments on commit dc43bcd

Please sign in to comment.