Skip to content

Commit

Permalink
🪛[chore]: 팝업 처리
Browse files Browse the repository at this point in the history
  • Loading branch information
Roy-wonji committed Dec 5, 2023
1 parent b9feb23 commit 2ba896f
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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?
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -315,7 +315,7 @@ public class CommonViewViewModel: ObservableObject {
public func archiveRequest(
userId: String,
completion: @escaping () -> Void

) async {
if let cancellable = archiveCancellable {
cancellable.cancel()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ public struct CompletOnBoardingView: View {

commonViewViewModel.isLogin = true
commonViewViewModel.isLoginCheck = true

DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
commonViewViewModel.isFirstUserPOPUP = true
}

}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}

})
}
Expand Down

0 comments on commit 2ba896f

Please sign in to comment.