diff --git a/YELLO-iOS/YELLO-iOS/Application/AppDelegate.swift b/YELLO-iOS/YELLO-iOS/Application/AppDelegate.swift index 6b9b73d5..3883b6e1 100644 --- a/YELLO-iOS/YELLO-iOS/Application/AppDelegate.swift +++ b/YELLO-iOS/YELLO-iOS/Application/AppDelegate.swift @@ -112,16 +112,21 @@ extension AppDelegate: UNUserNotificationCenterDelegate { guard let type = userInfo["type"] as? String else { return } guard let path = userInfo["path"] as? String, let messageNumber = path.split(separator: "/").last else { - if type == StringLiterals.PushAlarm.TypeName.available || type == StringLiterals.PushAlarm.TypeName.recommend { - NotificationCenter.default.post(name: Notification.Name("showPage"), object: nil, userInfo: ["index":2]) + if type == StringLiterals.PushAlarm.TypeName.available || type == StringLiterals.PushAlarm.TypeName.recommend + || type == StringLiterals.PushAlarm.TypeName.lunchEvent { + NotificationCenter.default.post(name: Notification.Name("showPage"), object: nil, userInfo: ["index":2]) // 40분 초기화, 추천인 포인트, 점심시간 이벤트 } else if type == StringLiterals.PushAlarm.TypeName.newFriend { - NotificationCenter.default.post(name: Notification.Name("showPage"), object: nil, userInfo: ["index":4]) + NotificationCenter.default.post(name: Notification.Name("showPage"), object: nil, userInfo: ["index":4]) // 새친구 + } else if type == StringLiterals.PushAlarm.TypeName.firstRecommend { + NotificationCenter.default.post(name: Notification.Name("showPage"), object: nil, userInfo: ["index":5]) // 추천인 열람권 + } else if type == StringLiterals.PushAlarm.TypeName.openVote { + NotificationCenter.default.post(name: Notification.Name("showPage"), object: nil, userInfo: ["index":1]) // 내가 보낸 쪽지 열람 } return } NotificationCenter.default.post(name: Notification.Name("showMessage"), object: nil, userInfo: ["message":Int(messageNumber) ?? 0]) - + if type == StringLiterals.PushAlarm.TypeName.newVote { NotificationCenter.default.post(name: Notification.Name("showPage"), object: nil, userInfo: ["index":3]) } diff --git a/YELLO-iOS/YELLO-iOS/Application/SceneDelegate.swift b/YELLO-iOS/YELLO-iOS/Application/SceneDelegate.swift index 2015858f..26300bf4 100644 --- a/YELLO-iOS/YELLO-iOS/Application/SceneDelegate.swift +++ b/YELLO-iOS/YELLO-iOS/Application/SceneDelegate.swift @@ -78,7 +78,8 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { let messageNumber = path.split(separator: "/").last else { let rootViewController = YELLOTabBarController() let navigationController = UINavigationController(rootViewController: rootViewController) - if type == StringLiterals.PushAlarm.TypeName.available || type == StringLiterals.PushAlarm.TypeName.recommend { + if type == StringLiterals.PushAlarm.TypeName.available || type == StringLiterals.PushAlarm.TypeName.recommend + || type == StringLiterals.PushAlarm.TypeName.lunchEvent { selectedIndex = 2 rootViewController.selectedIndex = selectedIndex self.window?.rootViewController = navigationController @@ -94,7 +95,27 @@ class SceneDelegate: UIResponder, UIWindowSceneDelegate { if NetworkCheck.shared.isConnected { self.checkAndUpdateIfNeeded() } + } else if type == StringLiterals.PushAlarm.TypeName.firstRecommend { + selectedIndex = 3 + rootViewController.selectedIndex = selectedIndex + self.window?.rootViewController = navigationController + self.window?.makeKeyAndVisible() + if NetworkCheck.shared.isConnected { + self.checkAndUpdateIfNeeded() + } + } else if type == StringLiterals.PushAlarm.TypeName.openVote { + selectedIndex = 1 + rootViewController.selectedIndex = selectedIndex + self.window?.rootViewController = navigationController + self.window?.makeKeyAndVisible() + DispatchQueue.main.async { + NotificationCenter.default.post(name: Notification.Name("changeMode"), object: nil, userInfo: nil) + } + if NetworkCheck.shared.isConnected { + self.checkAndUpdateIfNeeded() + } } + return } diff --git a/YELLO-iOS/YELLO-iOS/Global/Literals/String.swift b/YELLO-iOS/YELLO-iOS/Global/Literals/String.swift index f46df298..31441cae 100644 --- a/YELLO-iOS/YELLO-iOS/Global/Literals/String.swift +++ b/YELLO-iOS/YELLO-iOS/Global/Literals/String.swift @@ -449,6 +449,9 @@ enum StringLiterals { static let newVote = "NEW_VOTE" static let newFriend = "NEW_FRIEND" static let recommend = "RECOMMEND" + static let firstRecommend = "FIRST_RECOMMEND" + static let openVote = "OPEN_VOTE" + static let lunchEvent = "LUNCH_EVENT" } } diff --git a/YELLO-iOS/YELLO-iOS/Presentation/Around/View/AroundView.swift b/YELLO-iOS/YELLO-iOS/Presentation/Around/View/AroundView.swift index 1f017ebc..48480c0f 100644 --- a/YELLO-iOS/YELLO-iOS/Presentation/Around/View/AroundView.swift +++ b/YELLO-iOS/YELLO-iOS/Presentation/Around/View/AroundView.swift @@ -26,7 +26,38 @@ final class AroundView: BaseView { } } var scrollCount = 0 - var isUserSenderVote = false + var isUserSenderVote = false { + didSet { + if isUserSenderVote { + filterButtonLabel.text = StringLiterals.Around.myYello + filterButtonStackView.spacing = 0 + filterButtonStackView.snp.updateConstraints { + $0.leading.equalToSuperview().inset(8.adjustedWidth) + } + aroundEmptyView.emptyDescriptionLabel.setTextWithLineHeight( + text: StringLiterals.Recommending.Empty.timeLineMyTitle, + lineHeight: 24) + } else { + filterButtonLabel.text = StringLiterals.Around.allYello + filterButtonStackView.spacing = 6.adjustedWidth + filterButtonStackView.snp.updateConstraints { + $0.leading.equalToSuperview().inset(20.adjustedWidth) + } + aroundEmptyView.emptyDescriptionLabel.setTextWithLineHeight( + text: StringLiterals.Recommending.Empty.timeLineAllTitle, + lineHeight: 24) + } + + self.aroundPage = -1 + self.aroundCount = -1 + self.isFinishPaging = false + self.fetchingMore = false + self.aroundTableView.reloadData() + self.aroundModelDummy = [] + self.around() + self.updateView() + } + } var aroundModelDummy: [FriendVote] = [] @@ -190,6 +221,10 @@ final class AroundView: BaseView { } } + private func setAroundViewMode() { + + } + // MARK: Custom Function /// 친구가 없을 때 초대 뷰를 띄우는 로직 func updateView() { @@ -328,36 +363,5 @@ extension AroundView: UITableViewDataSource { extension AroundView { @objc private func filterButtonTapped() { isUserSenderVote.toggle() - - if isUserSenderVote { - filterButtonLabel.text = StringLiterals.Around.myYello - filterButtonStackView.spacing = 0 - filterButtonStackView.snp.updateConstraints { - $0.leading.equalToSuperview().inset(8.adjustedWidth) - } - aroundEmptyView.emptyDescriptionLabel.setTextWithLineHeight( - text: StringLiterals.Recommending.Empty.timeLineMyTitle, - lineHeight: 24) - aroundEmptyView.inviteButton.setTitle(StringLiterals.Recommending.Empty.myInviteButton, for: .normal) - } else { - filterButtonLabel.text = StringLiterals.Around.allYello - filterButtonStackView.spacing = 6.adjustedWidth - filterButtonStackView.snp.updateConstraints { - $0.leading.equalToSuperview().inset(20.adjustedWidth) - } - aroundEmptyView.emptyDescriptionLabel.setTextWithLineHeight( - text: StringLiterals.Recommending.Empty.timeLineAllTitle, - lineHeight: 24) - aroundEmptyView.inviteButton.setTitle(StringLiterals.Recommending.Empty.inviteButton, for: .normal) - } - - self.aroundPage = -1 - self.aroundCount = -1 - self.isFinishPaging = false - self.fetchingMore = false - self.aroundTableView.reloadData() - self.aroundModelDummy = [] - self.around() - self.updateView() } } diff --git a/YELLO-iOS/YELLO-iOS/Presentation/Around/ViewController/AroundViewController.swift b/YELLO-iOS/YELLO-iOS/Presentation/Around/ViewController/AroundViewController.swift index 9690b5d2..81df8a7f 100644 --- a/YELLO-iOS/YELLO-iOS/Presentation/Around/ViewController/AroundViewController.swift +++ b/YELLO-iOS/YELLO-iOS/Presentation/Around/ViewController/AroundViewController.swift @@ -31,6 +31,13 @@ final class AroundViewController: UIViewController { aroundView.scrollCount = 0 self.tabBarController?.tabBar.isHidden = false self.navigationController?.navigationBar.isHidden = true + NotificationCenter.default.addObserver(self, selector: #selector(changeMode(_:)), name: NSNotification.Name("changeMode"), object: nil) + self.tabBarController?.tabBar.items?[2].imageInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) + } + + override func viewWillDisappear(_ animated: Bool) { + super.viewWillDisappear(animated) + NotificationCenter.default.removeObserver(self, name: NSNotification.Name("changeMode"), object: nil) } } @@ -66,4 +73,9 @@ extension AroundViewController { } } + + @objc + private func changeMode(_ notification: Notification) { + self.aroundView.isUserSenderVote = true + } } diff --git a/YELLO-iOS/YELLO-iOS/Presentation/Notification/NotificationView.swift b/YELLO-iOS/YELLO-iOS/Presentation/Notification/NotificationView.swift index 2aa7d7e3..02636db6 100644 --- a/YELLO-iOS/YELLO-iOS/Presentation/Notification/NotificationView.swift +++ b/YELLO-iOS/YELLO-iOS/Presentation/Notification/NotificationView.swift @@ -38,6 +38,9 @@ final class NotificationView: BaseView { $0.text = StringLiterals.Notification.doNotSeeAgainLabel $0.textColor = .white $0.font = .uiBody02 + $0.isUserInteractionEnabled = true + let tapGesture = UITapGestureRecognizer(target: self, action: #selector(doNotSeeLabelTapped)) + $0.addGestureRecognizer(tapGesture) } closeButton.do { @@ -95,6 +98,13 @@ extension NotificationView { UserDefaults.standard.set(isTapped, forKey: "isTapped") } + @objc + private func doNotSeeLabelTapped() { + isTapped.toggle() + doNotSeeAgainButton.setImage(UIImage(imageLiteralResourceName: isTapped ? "btnCheckBox" : "btnNotCheckBox"), for: .normal) + UserDefaults.standard.set(isTapped, forKey: "isTapped") + } + @objc private func closeButtonTapped() { self.isHidden = true diff --git a/YELLO-iOS/YELLO-iOS/Presentation/TabBar/YELLOTabBarController.swift b/YELLO-iOS/YELLO-iOS/Presentation/TabBar/YELLOTabBarController.swift index cc9b664b..8d9e19e7 100644 --- a/YELLO-iOS/YELLO-iOS/Presentation/TabBar/YELLOTabBarController.swift +++ b/YELLO-iOS/YELLO-iOS/Presentation/TabBar/YELLOTabBarController.swift @@ -339,18 +339,26 @@ extension YELLOTabBarController { func showPage(_ notification: Notification) { if let userInfo = notification.userInfo { if let index = userInfo["index"] as? Int { - self.selectedIndex = index + if index != 5 { + self.selectedIndex = index + } if selectedIndex == 2 { tabBar.items?[2].imageInsets = UIEdgeInsets(top: -23, left: 0, bottom: 0, right: 0) } else if selectedIndex == 3 { tabBar.items?[2].imageInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) let myYelloDetailViewController = MyYelloDetailViewController() - myYelloDetailViewController.myYelloDetail(voteId: Int(messageIndex)) + myYelloDetailViewController.myYelloDetail(voteId: Int(messageIndex)) self.navigationController?.pushViewController(myYelloDetailViewController, animated: true) } else if selectedIndex == 4 { tabBar.items?[2].imageInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) + } else if selectedIndex == 1 { + tabBar.items?[2].imageInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) + NotificationCenter.default.post(name: Notification.Name("changeMode"), object: nil, userInfo: nil) + } else if index == 5 { + self.selectedIndex = 3 + tabBar.items?[2].imageInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0) } } } diff --git a/YELLO-iOS/YELLO-iOS/Presentation/Voting/Voting/VotingFunction.swift b/YELLO-iOS/YELLO-iOS/Presentation/Voting/Voting/VotingFunction.swift index 4ed96f9f..21f5fc31 100644 --- a/YELLO-iOS/YELLO-iOS/Presentation/Voting/Voting/VotingFunction.swift +++ b/YELLO-iOS/YELLO-iOS/Presentation/Voting/Voting/VotingFunction.swift @@ -164,32 +164,35 @@ extension VotingViewController { guard let identify = identify else {return} Amplitude.instance().identify(identify) - let viewController = VotingPointViewController() - let myPlusPoint = UserDefaults.standard.integer(forKey: "UserPlusPoint") - viewController.myPoint = myPoint + myPlusPoint - viewController.votingPlusPoint = myPlusPoint - - let status = votingList[0].subscribe - if status == "CANCELED" || status == "ACTIVE" { - viewController.multiplyByTwoImageView.isHidden = false - UserDefaults.standard.set(true, forKey: "isYelloPlus") - viewController.adButtonStackView.isHidden = true - viewController.originView.yellowButton.isHidden = false - viewController.myPoint += myPlusPoint - viewController.votingPlusPoint *= 2 - } else { - viewController.multiplyByTwoImageView.isHidden = true - UserDefaults.standard.set(false, forKey: "isYelloPlus") - viewController.adButtonStackView.isHidden = false - viewController.originView.yellowButton.isHidden = true + DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 0.1) { + + let viewController = VotingPointViewController() + let myPlusPoint = UserDefaults.standard.integer(forKey: "UserPlusPoint") + viewController.myPoint = self.myPoint + myPlusPoint + viewController.votingPlusPoint = myPlusPoint + + let status = self.votingList[0].subscribe + if status == "CANCELED" || status == "ACTIVE" { + viewController.multiplyByTwoImageView.isHidden = false + UserDefaults.standard.set(true, forKey: "isYelloPlus") + viewController.adButtonStackView.isHidden = true + viewController.originView.yellowButton.isHidden = false + viewController.myPoint += myPlusPoint + viewController.votingPlusPoint *= 2 + } else { + viewController.multiplyByTwoImageView.isHidden = true + UserDefaults.standard.set(false, forKey: "isYelloPlus") + viewController.adButtonStackView.isHidden = false + viewController.originView.yellowButton.isHidden = true + } + + UserDefaults.standard.set(viewController.myPoint, forKey: "UserPoint") + UserDefaults.standard.set(viewController.votingPlusPoint, forKey: "UserPlusPointNotPost") + + UIView.transition(with: self.navigationController?.view ?? UIView(), duration: 0.1, options: .transitionCrossDissolve, animations: { + self.navigationController?.pushViewController(viewController, animated: false) + }) } - - UserDefaults.standard.set(viewController.myPoint, forKey: "UserPoint") - UserDefaults.standard.set(viewController.votingPlusPoint, forKey: "UserPlusPointNotPost") - - UIView.transition(with: self.navigationController?.view ?? UIView(), duration: 0.001, options: .transitionCrossDissolve, animations: { - self.navigationController?.pushViewController(viewController, animated: false) - }) } else { let viewController = VotingViewController() viewController.votingList = votingList