From 2ba896f473d7c9241d62c207c0db4ba66db6a0f6 Mon Sep 17 00:00:00 2001 From: Roy-wonji Date: Tue, 5 Dec 2023 23:09:58 +0900 Subject: [PATCH] =?UTF-8?q?=F0=9F=AA=9B[chore]:=20=ED=8C=9D=EC=97=85=20?= =?UTF-8?q?=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ViewModel/CommonViewViewModel.swift | 36 +++++++-------- .../Sources/UI/View/MainView/LoginView.swift | 45 ++++++++++--------- .../CompletOnBoardingView.swift | 5 +++ .../RecomandNotificationView.swift | 2 +- .../NotificationQuoteView.swift | 4 +- .../View/OtherSetting/OtherSettingView.swift | 5 ++- .../UI/View/WithDraw/WithDrawView.swift | 18 ++++++-- 7 files changed, 67 insertions(+), 48 deletions(-) diff --git a/PingPong/Projects/Core/Common/Sources/ViewModel/CommonViewViewModel.swift b/PingPong/Projects/Core/Common/Sources/ViewModel/CommonViewViewModel.swift index e205b5cc..2337debd 100644 --- a/PingPong/Projects/Core/Common/Sources/ViewModel/CommonViewViewModel.swift +++ b/PingPong/Projects/Core/Common/Sources/ViewModel/CommonViewViewModel.swift @@ -19,15 +19,15 @@ public class CommonViewViewModel: ObservableObject { public init() { isLogin = UserDefaults.standard.bool(forKey: "isLogin") - - + + } - @AppStorage("isFirstUserPOPUP") public var isFirstUserPOPUP: Bool = true + @AppStorage("isFirstUserPOPUP") public var isFirstUserPOPUP: Bool = false @Published public var isLoginCheck: Bool = false { didSet { - coreViewPath.removeAll() - viewPath.removeAll() + coreViewPath.removeAll() + viewPath.removeAll() } } @AppStorage("isLogin") public var isLogin: Bool = false { @@ -42,14 +42,14 @@ public class CommonViewViewModel: ObservableObject { @Published public var firstUserPOPUP: Bool = false @Published public var showDeleteAuthPOPUP: Bool = false - + @Published public var selectedTab: Tab = .home @Published public var goToMainView: Bool = false @Published public var customTabs: [CustomTab] = [] @Published public var selectedSourceArray: [Source] = [] @Published public var selectedFlavorArray: [Flavor] = [] - + //MARK: 모달 관련 @Published public var offsetY: CGFloat = 30 public func generateIsButtonAble(situationFlavorSourceTitle: SearchType) -> Bool { @@ -67,7 +67,7 @@ public class CommonViewViewModel: ObservableObject { //MARK: HomeBakeing 관련 @Published public var exploreViewSearchBarText: String = "" - + @Published public var choicedBread: Bread? @Published public var choicedIngredent: Ingredent? @@ -154,19 +154,19 @@ public class CommonViewViewModel: ObservableObject { return searchViewButtonInfoArray[idx].options.filter { $0.isCheck }.count } -// func filterPostsByText() { -// if exploreViewSearchBarText.isEmpty { -// homePosts = originHomePosts -// } else { -// homePosts = originHomePosts.filter { $0.title.contains(exploreViewSearchBarText) -// } -// } -// } + // func filterPostsByText() { + // if exploreViewSearchBarText.isEmpty { + // homePosts = originHomePosts + // } else { + // homePosts = originHomePosts.filter { $0.title.contains(exploreViewSearchBarText) + // } + // } + // } //MARK: - 홈 좋아요 및 스크램 api public func homeBaseToViewModel(_ list: BaseModel) { self.homeBaseModel = list } - + public func quoteLikeRequest(userID: String, quoteId: Int, completion: @escaping () -> Void ) async { if let cancellable = homeLikeCancellable { cancellable.cancel() @@ -315,7 +315,7 @@ public class CommonViewViewModel: ObservableObject { public func archiveRequest( userId: String, completion: @escaping () -> Void - + ) async { if let cancellable = archiveCancellable { cancellable.cancel() diff --git a/PingPong/Projects/Feature/OnBoarding/Sources/UI/View/MainView/LoginView.swift b/PingPong/Projects/Feature/OnBoarding/Sources/UI/View/MainView/LoginView.swift index b4df57f4..b8216cc6 100644 --- a/PingPong/Projects/Feature/OnBoarding/Sources/UI/View/MainView/LoginView.swift +++ b/PingPong/Projects/Feature/OnBoarding/Sources/UI/View/MainView/LoginView.swift @@ -82,28 +82,29 @@ public struct LoginView: View { .onAppear{ authViewModel.getRefreshToken() } - .popup(isPresented: $authViewModel.deleteAuth) { - WithDrawPOPUP( - image: .empty, - title: "이용해 주셔서 감사합니다", - subTitle: "주신 의견에 반영하여\n 더나은 명언 제과점이 되겠습니다", - confirmAction: {}, - cancelAction: { - authViewModel.deleteAuth = false - viewModel.isSignUP = false - viewModel.alreadySignUP = false - }, noImage: true, - noImageButton: true - ) - } customize: { popup in - popup - .type(.default) - .position(.bottom) - .animation(.easeIn) - .closeOnTap(true) - .closeOnTapOutside(true) - .backgroundColor(.basicBlackDimmed) - } + + } + .popup(isPresented: $authViewModel.deleteAuth) { + WithDrawPOPUP( + image: .empty, + title: "이용해 주셔서 감사합니다", + subTitle: "주신 의견에 반영하여\n 더나은 명언 제과점이 되겠습니다", + confirmAction: {}, + cancelAction: { + authViewModel.deleteAuth = false + viewModel.isSignUP = false + viewModel.alreadySignUP = false + }, noImage: true, + noImageButton: true + ) + } customize: { popup in + popup + .type(.default) + .position(.bottom) + .animation(.easeIn) + .closeOnTap(true) + .closeOnTapOutside(true) + .backgroundColor(.basicBlackDimmed) } } diff --git a/PingPong/Projects/Feature/OnBoarding/Sources/UI/View/OnBoardingPushViiew/CompletOnBoardingView.swift b/PingPong/Projects/Feature/OnBoarding/Sources/UI/View/OnBoardingPushViiew/CompletOnBoardingView.swift index 5b9e6892..7f49d7f3 100644 --- a/PingPong/Projects/Feature/OnBoarding/Sources/UI/View/OnBoardingPushViiew/CompletOnBoardingView.swift +++ b/PingPong/Projects/Feature/OnBoarding/Sources/UI/View/OnBoardingPushViiew/CompletOnBoardingView.swift @@ -123,6 +123,11 @@ public struct CompletOnBoardingView: View { commonViewViewModel.isLogin = true commonViewViewModel.isLoginCheck = true + + DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) { + commonViewViewModel.isFirstUserPOPUP = true + } + } } } diff --git a/PingPong/Projects/Feature/OnBoarding/Sources/UI/View/OnBoardingPushViiew/RecomandNotificationView.swift b/PingPong/Projects/Feature/OnBoarding/Sources/UI/View/OnBoardingPushViiew/RecomandNotificationView.swift index 7c6b42ff..93c5c224 100644 --- a/PingPong/Projects/Feature/OnBoarding/Sources/UI/View/OnBoardingPushViiew/RecomandNotificationView.swift +++ b/PingPong/Projects/Feature/OnBoarding/Sources/UI/View/OnBoardingPushViiew/RecomandNotificationView.swift @@ -137,7 +137,7 @@ public struct RecomandPushNotificationView: View { .onTapGesture { appState.isActivePushNotifcation.toggle() authViewModel.isNotification.toggle() - authViewModel.isActiveNotification.toggle() +// authViewModel.isActiveNotification.toggle() if appState.isActivePushNotifcation { let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound] diff --git a/PingPong/Projects/Feature/Profile/Sources/UI/View/NotificationQuoteView/NotificationQuoteView.swift b/PingPong/Projects/Feature/Profile/Sources/UI/View/NotificationQuoteView/NotificationQuoteView.swift index c52b05a4..25463438 100644 --- a/PingPong/Projects/Feature/Profile/Sources/UI/View/NotificationQuoteView/NotificationQuoteView.swift +++ b/PingPong/Projects/Feature/Profile/Sources/UI/View/NotificationQuoteView/NotificationQuoteView.swift @@ -13,13 +13,13 @@ import Authorization struct NotificationQuoteView: View { @StateObject private var profileViewModel: ProfileViewViewModel = ProfileViewViewModel() - @ObservedObject var authViewModel: AuthorizationViewModel + @StateObject var authViewModel: AuthorizationViewModel @Environment(\.presentationMode) var presentationMode public init( authViewModel: AuthorizationViewModel ) { - self._authViewModel = ObservedObject(wrappedValue: authViewModel) + self._authViewModel = StateObject(wrappedValue: authViewModel) } var body: some View { diff --git a/PingPong/Projects/Feature/Profile/Sources/UI/View/OtherSetting/OtherSettingView.swift b/PingPong/Projects/Feature/Profile/Sources/UI/View/OtherSetting/OtherSettingView.swift index 89847d19..9c18e3e2 100644 --- a/PingPong/Projects/Feature/Profile/Sources/UI/View/OtherSetting/OtherSettingView.swift +++ b/PingPong/Projects/Feature/Profile/Sources/UI/View/OtherSetting/OtherSettingView.swift @@ -64,7 +64,10 @@ public struct OtherSettingView: View { } .navigationDestination(isPresented: $profileViewModel.gotoWithDrawView) { - WithDrawView(authViewModel: authViewModel, viewModel: viewModel) + WithDrawView(authViewModel: authViewModel, + viewModel: viewModel, + profileViewModel: profileViewModel + ) .navigationBarBackButtonHidden() } } diff --git a/PingPong/Projects/Feature/Profile/Sources/UI/View/WithDraw/WithDrawView.swift b/PingPong/Projects/Feature/Profile/Sources/UI/View/WithDraw/WithDrawView.swift index 15319219..94f0a913 100644 --- a/PingPong/Projects/Feature/Profile/Sources/UI/View/WithDraw/WithDrawView.swift +++ b/PingPong/Projects/Feature/Profile/Sources/UI/View/WithDraw/WithDrawView.swift @@ -15,17 +15,19 @@ import PopupView struct WithDrawView: View { - @StateObject private var profileViewModel: ProfileViewViewModel = ProfileViewViewModel() + @StateObject private var profileViewModel: ProfileViewViewModel @StateObject var viewModel: CommonViewViewModel @StateObject var authViewModel: AuthorizationViewModel @Environment(\.presentationMode) var presentationMode public init( authViewModel: AuthorizationViewModel, - viewModel: CommonViewViewModel + viewModel: CommonViewViewModel, + profileViewModel: ProfileViewViewModel ) { self._authViewModel = StateObject(wrappedValue: authViewModel) self._viewModel = StateObject(wrappedValue: viewModel) + self._profileViewModel = StateObject(wrappedValue: profileViewModel) } var body: some View { @@ -58,11 +60,19 @@ struct WithDrawView: View { confirmAction: { Task { await profileViewModel.withDrawPost(userID: "\(authViewModel.userid)", reason: profileViewModel.selectWithDrawReason, successCompletion: { - authViewModel.deleteAuth = true +// authViewModel.deleteAuth = true + profileViewModel.selectWithDrawPOPUP = false viewModel.isLoginCheck = false profileViewModel.randomNickName = "" - + authViewModel.userid = .zero + authViewModel.userNickName = "" presentationMode.wrappedValue.dismiss() + viewModel.isFirstUserPOPUP = false + + + DispatchQueue.main.asyncAfter(deadline: .now() + 0.8) { + authViewModel.deleteAuth = true + } }) }