Skip to content

Commit

Permalink
Merge pull request #359 from team-yello/feat/#354
Browse files Browse the repository at this point in the history
Feat [#354] 푸시알림 및 건의사항 반영 + 오류 수정
  • Loading branch information
Heyjooo committed Mar 4, 2024
2 parents 589a559 + 2011422 commit 3da1e58
Show file tree
Hide file tree
Showing 8 changed files with 130 additions and 64 deletions.
13 changes: 9 additions & 4 deletions YELLO-iOS/YELLO-iOS/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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])
}
Expand Down
23 changes: 22 additions & 1 deletion YELLO-iOS/YELLO-iOS/Application/SceneDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}

Expand Down
3 changes: 3 additions & 0 deletions YELLO-iOS/YELLO-iOS/Global/Literals/String.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

Expand Down
68 changes: 36 additions & 32 deletions YELLO-iOS/YELLO-iOS/Presentation/Around/View/AroundView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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] = []

Expand Down Expand Up @@ -190,6 +221,10 @@ final class AroundView: BaseView {
}
}

private func setAroundViewMode() {

}

// MARK: Custom Function
/// 친구가 없을 때 초대 뷰를 띄우는 로직
func updateView() {
Expand Down Expand Up @@ -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()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

}
Expand Down Expand Up @@ -66,4 +73,9 @@ extension AroundViewController {
}

}

@objc
private func changeMode(_ notification: Notification) {
self.aroundView.isUserSenderVote = true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down
53 changes: 28 additions & 25 deletions YELLO-iOS/YELLO-iOS/Presentation/Voting/Voting/VotingFunction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 3da1e58

Please sign in to comment.