Skip to content

Commit

Permalink
✨[feat]: 명언 관련 수정 오류 수정
Browse files Browse the repository at this point in the history
  • Loading branch information
Roy-wonji committed Dec 13, 2023
1 parent 1559417 commit 1cfeedc
Show file tree
Hide file tree
Showing 11 changed files with 39 additions and 39 deletions.
5 changes: 2 additions & 3 deletions PingPong/Projects/App/Sources/Application/PingPongApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ struct PingPongProjectApp: App {
WindowGroup {
ZStack {
if commonViewViewModel.isLoginCheck {
CoreView(viewModel: commonViewViewModel, isFistUserPOPUP: $commonViewViewModel.isFirstUserPOPUP)
.environmentObject(authViewModel)
CoreView(viewModel: commonViewViewModel, authViewModel: authViewModel, isFistUserPOPUP: $commonViewViewModel.isFirstUserPOPUP)
.environmentObject(sheetManager)
.navigationBarHidden(true)
.onAppear {
Expand All @@ -46,7 +45,7 @@ struct PingPongProjectApp: App {
}

} else if commonViewViewModel.isExploreApp {
CoreView(viewModel: commonViewViewModel, isFistUserPOPUP: $commonViewViewModel.isFirstUserPOPUP)
CoreView(viewModel: commonViewViewModel, authViewModel: authViewModel, isFistUserPOPUP: $commonViewViewModel.isFirstUserPOPUP)
.environmentObject(authViewModel)
.environmentObject(sheetManager)
.navigationBarHidden(true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public class AuthorizationViewModel: ObservableObject {
}

//MARK: - 회원가입
public func signupPost(token: String, fcm: String, email: String, nickname: String, jobCd: String, signupSuccessAction: @escaping () -> Void, failSignUPAction: @escaping () -> Void) {
public func signupPost(token: String, fcm: String, email: String, nickname: String, jobCd: String, signupSuccessAction: @escaping (SignUPModel) -> Void, failSignUPAction: @escaping () -> Void) {
if let cancellable = signupCancellable {
cancellable.cancel()
}
Expand All @@ -276,7 +276,7 @@ public class AuthorizationViewModel: ObservableObject {
self?.userid = String(model.data?.id ?? .zero)
self?.userUid = model.data?.uid ?? ""
print("회원가입 성공", model)
signupSuccessAction()
signupSuccessAction(model)
} else {
self?.signupToViewModel(model)
self?.userid = String(model.data?.id ?? .zero)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,18 @@ public struct CoreView: View {
@StateObject var appState: AppState = AppState()
@Environment(\.presentationMode) var presentationMode
@Binding var isFistUserPOPUP: Bool
@EnvironmentObject var authViewModel: AuthorizationViewModel
@StateObject var authViewModel: AuthorizationViewModel
@StateObject var viewModel: CommonViewViewModel


public init(viewModel: CommonViewViewModel, isFistUserPOPUP: Binding<Bool>) {
public init(
viewModel: CommonViewViewModel,
authViewModel: AuthorizationViewModel,
isFistUserPOPUP: Binding<Bool>
) {

self._viewModel = StateObject(wrappedValue: viewModel)
self._authViewModel = StateObject(wrappedValue: authViewModel)
self._isFistUserPOPUP = isFistUserPOPUP
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,25 +82,7 @@ public struct HomeView: View {

}
}
} else if authViewModel.userid == authViewModel.userid {
viewModel.cards = []
homeViewModel.randomQuoteRequest(userID: "\(authViewModel.userid)") { model in
for quoteContent in model.data?.content ?? [] {
let hashTags = viewModel.getHashtags(post: quoteContent)
self.homeViewModel.selecteLikeYn = quoteContent.likeID != nil
let card = CardInfomation(qouteId: quoteContent.quoteID ?? .zero,
hashtags: hashTags, image: "",
title: quoteContent.content ?? "",
sources: quoteContent.author ?? "",
isBookrmark: quoteContent.likeID != nil,
likeId: quoteContent.likeID
)
if !viewModel.cards.contains(card) {
viewModel.cards.append(card)
}
}
}
} else if authViewModel.userid == "" || authViewModel.userid == "0" || authViewModel.userid != authViewModel.userid {
} else if authViewModel.userid == "" || authViewModel.userid == "0" || authViewModel.userid != authViewModel.userid {
viewModel.cards = []
homeViewModel.randomQuoteRequest(userID: "") { model in
for quoteContent in model.data?.content ?? [] {
Expand Down Expand Up @@ -130,6 +112,7 @@ public struct HomeView: View {
isBookrmark: quoteContent.likeID != nil,
likeId: quoteContent.likeID
)

if !viewModel.cards.contains(card) {
viewModel.cards.append(card)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Common
public struct FavoriteWiseChooseView: View {
@StateObject private var viewModel: OnBoardingViewModel
@StateObject private var commonViewViewModel: CommonViewViewModel

public init(viewModel: OnBoardingViewModel, commonViewViewModel: CommonViewViewModel) {
self._viewModel = StateObject(wrappedValue: viewModel)
self._commonViewViewModel = StateObject(wrappedValue: commonViewViewModel)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,17 @@ public struct CompleteLoginView: View {
@StateObject private var commonViewViewModel: CommonViewViewModel
@StateObject private var viewModel: OnBoardingViewModel
@Environment(\.presentationMode) var presentationMode
@StateObject var authViewModel: AuthorizationViewModel = AuthorizationViewModel()
@StateObject var authViewModel: AuthorizationViewModel
let columns = Array(repeating: GridItem(.flexible()), count: 3)

public init(viewModel: OnBoardingViewModel, commonViewViewModel: CommonViewViewModel) {
public init(
viewModel: OnBoardingViewModel,
commonViewViewModel: CommonViewViewModel,
authViewModel: AuthorizationViewModel
) {
self._viewModel = StateObject(wrappedValue: viewModel)
self._commonViewViewModel = StateObject(wrappedValue: commonViewViewModel)
self._authViewModel = StateObject(wrappedValue: authViewModel)
}


Expand Down Expand Up @@ -129,8 +134,10 @@ public struct CompleteLoginView: View {
//MARK: - 임시로 하드 코딩 나중에 로그인 성공하면 success action에 추가
//TODO: 회원가입 중간에 나가면 뷰깨지는 문제 해결
viewModel.completdSignUP = true
authViewModel.signupPost(token: authViewModel.uid, fcm: AppManager.shared.fcmToken, email: authViewModel.userEmail, nickname: viewModel.nickname, jobCd: String(viewModel.selectJobCode)) {

authViewModel.signupPost(token: authViewModel.uid, fcm: AppManager.shared.fcmToken, email: authViewModel.userEmail, nickname: viewModel.nickname, jobCd: String(viewModel.selectJobCode)) { model in
authViewModel.userid = String(model.data?.id ?? .zero)
authViewModel.userEmail = model.data?.email ?? ""
authViewModel.userNickName = model.data?.nickname ?? ""
} failSignUPAction: {
// authViewModel.isSignupFail.toggle()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public struct LoginView: View {
case .isNickNameComplete:
LoginJobSettingView(viewModel: self.viewModel, commonViewViewModel: commonViewViewModel)
case .isJobSettingComplete:
CompleteLoginView(viewModel: self.viewModel, commonViewViewModel: self.commonViewViewModel)
CompleteLoginView(viewModel: self.viewModel, commonViewViewModel: self.commonViewViewModel, authViewModel: authViewModel)
case .isCompleteLogin:
FavoriteWiseChooseView(viewModel: self.viewModel, commonViewViewModel: commonViewViewModel)
case .isStartChoiceFavorite:
Expand All @@ -70,13 +70,11 @@ public struct LoginView: View {
OnBoardingPushView(viewModel: self.viewModel, commonViewViewModel: commonViewViewModel)

case .isCompleteOnboarding:
CompletOnBoardingView(viewModel: viewModel, commonViewViewModel: commonViewViewModel)
.environmentObject(authViewModel)
CompletOnBoardingView(viewModel: viewModel, commonViewViewModel: commonViewViewModel, authViewModel: authViewModel)
case .isDeniedNoti:
RecomandPushNotificationView(viewModel: self.viewModel, commonViewViewModel: commonViewViewModel)
case .isLoginned:
CoreView(viewModel: commonViewViewModel, isFistUserPOPUP: $commonViewViewModel.firstUserPOPUP)
.environmentObject(authViewModel)
CoreView(viewModel: commonViewViewModel, authViewModel: authViewModel, isFistUserPOPUP: $commonViewViewModel.firstUserPOPUP)
.environmentObject(sheetManager)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ public struct OnBoardingLoginView: View {
authViewModel.userid = String(model.data?.id ?? .zero)
authViewModel.userNickName = model.data?.nickname ?? ""
commonViewViewModel.isLoginExplore = false
commonViewViewModel.cards = []
}, failLoginCompletion: {
appState.signUPFaillPOPUP.toggle()
presentationMode.wrappedValue.dismiss()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,18 @@ import Model

public struct CompletOnBoardingView: View {
@Environment(\.presentationMode) var presentationMode
@StateObject var authViewModel: AuthorizationViewModel = AuthorizationViewModel()
@StateObject var authViewModel: AuthorizationViewModel
@StateObject var viewModel: OnBoardingViewModel
@StateObject var commonViewViewModel: CommonViewViewModel

public init(viewModel: OnBoardingViewModel, commonViewViewModel: CommonViewViewModel) {
public init(
viewModel: OnBoardingViewModel,
commonViewViewModel: CommonViewViewModel,
authViewModel: AuthorizationViewModel
) {
self._viewModel = StateObject(wrappedValue: viewModel)
self._commonViewViewModel = StateObject(wrappedValue: commonViewViewModel)
self._authViewModel = StateObject(wrappedValue: authViewModel)
}

public var body: some View {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public struct RecomandPushNotificationView: View {
}

.navigationDestination(isPresented: $appState.completOnBoardingView) {
CompletOnBoardingView(viewModel: self.viewModel, commonViewViewModel: commonViewViewModel)
CompletOnBoardingView(viewModel: self.viewModel, commonViewViewModel: commonViewViewModel, authViewModel: authViewModel)
.environmentObject(authViewModel)
.navigationBarHidden(true)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ struct WithDrawView: View {
viewModel.isFirstUserPOPUP = false


DispatchQueue.main.asyncAfter(deadline: .now() + 0.8) {
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
authViewModel.deleteAuth = true
}

Expand Down

0 comments on commit 1cfeedc

Please sign in to comment.