From c934cb782ceb30c889dd38e0be60c9addae8c1f6 Mon Sep 17 00:00:00 2001 From: InKwon James Kim Date: Thu, 13 Feb 2020 15:55:25 +0900 Subject: [PATCH] Implement Push Notification --- .DS_Store | Bin 10244 -> 10244 bytes GME Remit/AppDelegate.swift | 24 ++++++++-- .../View/HomeViewController.swift | 2 + .../View/DetailNotification.storyboard | 37 ++++----------- .../DetailNotificationViewController.swift | 12 ----- .../DetailNotificationWireframe.swift | 4 +- .../Application Logic/Model/NoticeModel.swift | 2 + .../View/NotificationCell.swift | 5 +++ .../View/NotificationHistory.storyboard | 42 +++++++++++++++--- .../NotificationHistoryViewController.swift | 9 +++- .../NotificationHistoryWireframe.swift | 7 +++ .../new.imageset/Contents.json | 21 +++++++++ .../Assets.xcassets/new.imageset/new.png | Bin 0 -> 3045 bytes .../new2.imageset/Contents.json | 21 +++++++++ .../Assets.xcassets/new2.imageset/new2.png | Bin 0 -> 137 bytes 15 files changed, 132 insertions(+), 54 deletions(-) create mode 100644 GME Remit/Supported Files/Assets.xcassets/new.imageset/Contents.json create mode 100644 GME Remit/Supported Files/Assets.xcassets/new.imageset/new.png create mode 100644 GME Remit/Supported Files/Assets.xcassets/new2.imageset/Contents.json create mode 100644 GME Remit/Supported Files/Assets.xcassets/new2.imageset/new2.png diff --git a/.DS_Store b/.DS_Store index e1a7ba5c932e1277b8f1fe37497e1da26653b740..c51104400abcf35e458824f5e9d6fc18aa21cd17 100644 GIT binary patch delta 37 rcmZn(XbITxMx1G~=VSv3gUNCd6PO+_OfHmC*nB}kh94xnL0k*~156Ck delta 37 rcmZn(XbITxMw}_uZ?b`e!DKm!2}}zZCKpO6Y`!2N!w(YPAT9;~_y7zr diff --git a/GME Remit/AppDelegate.swift b/GME Remit/AppDelegate.swift index ecf5dc98..3ff5d0ca 100644 --- a/GME Remit/AppDelegate.swift +++ b/GME Remit/AppDelegate.swift @@ -30,9 +30,23 @@ let server: Server = .live var destination: PushNotificationDestination? var overlayView: UIView? -enum PushNotificationDestination: String { - case trasactionHistory = "TransactionHistory" - case rechargeHistory = "RechargeHistory" +enum PushNotificationDestination { + case trasactionHistory + case rechargeHistory + case pushNotification + + static func getDestination(target: String) -> PushNotificationDestination? { + switch target { + case "TransactionHistory": + return .trasactionHistory + case "RechargeHistory": + return .rechargeHistory + case "PushNotification": + return .pushNotification + default: + return nil + } + } } @UIApplicationMain @@ -211,6 +225,8 @@ extension AppDelegate: UNUserNotificationCenterDelegate { TransactionHistoryGroupWireframe().open(overseasType: .inbound, on: baseVC) case .rechargeHistory: RechargeHistoryWireframe().open(on: baseVC) + case .pushNotification: + NotificationHistoryWireframe().open(on: baseVC) } } @@ -222,7 +238,7 @@ extension AppDelegate { private func extractDestination(userInfo: [String : AnyObject]?) -> PushNotificationDestination? { guard let destination = userInfo?["destination"] as? String, - let destinationType = PushNotificationDestination(rawValue: destination) else { + let destinationType = PushNotificationDestination.getDestination(target: destination) else { return nil } diff --git a/GME Remit/Modules/Home/User Interface/View/HomeViewController.swift b/GME Remit/Modules/Home/User Interface/View/HomeViewController.swift index 7754c14a..e156b22e 100644 --- a/GME Remit/Modules/Home/User Interface/View/HomeViewController.swift +++ b/GME Remit/Modules/Home/User Interface/View/HomeViewController.swift @@ -122,6 +122,8 @@ class HomeViewController: UIViewController { presenter?.openRechargeHistory() case .trasactionHistory: presenter?.openTransactionHistory(type: .inbound) + case .pushNotification: + NotificationHistoryWireframe().open(on: self) } destination = nil diff --git a/GME Remit/Modules/Notice/DetailNotification/User Interface/View/DetailNotification.storyboard b/GME Remit/Modules/Notice/DetailNotification/User Interface/View/DetailNotification.storyboard index 4a0791e2..88120480 100644 --- a/GME Remit/Modules/Notice/DetailNotification/User Interface/View/DetailNotification.storyboard +++ b/GME Remit/Modules/Notice/DetailNotification/User Interface/View/DetailNotification.storyboard @@ -26,31 +26,31 @@ - + - + - + - + - + @@ -129,28 +129,13 @@ - - - + - - @@ -160,7 +145,6 @@ - @@ -191,9 +175,6 @@ - - - diff --git a/GME Remit/Modules/Notice/DetailNotification/User Interface/View/DetailNotificationViewController.swift b/GME Remit/Modules/Notice/DetailNotification/User Interface/View/DetailNotificationViewController.swift index 0f93abcb..135081d6 100644 --- a/GME Remit/Modules/Notice/DetailNotification/User Interface/View/DetailNotificationViewController.swift +++ b/GME Remit/Modules/Notice/DetailNotification/User Interface/View/DetailNotificationViewController.swift @@ -23,7 +23,6 @@ class DetailNotificationViewController: UIViewController { @IBOutlet private weak var titleLabel: UILabel! @IBOutlet private weak var contentLabel: UILabel! @IBOutlet private weak var dateLabel: UILabel! - @IBOutlet private weak var okButton: UIButton! @IBOutlet private weak var contentView: UIView! // MARK: VC's Life cycle @@ -55,20 +54,9 @@ extension DetailNotificationViewController { } private func setUI() { - if self.presentingViewController == nil { - okButton.isHidden = true - } - -// contentView.layer.cornerRadius = 5 -// contentView.layer.borderWidth = 1 -// contentView.layer.borderColor = UIColor.themeSeparate.cgColor - okButton.layer.cornerRadius = 5 } private func setUIBinding() { - okButton.rx.tap.bind {[weak self] in - self?.dismiss(animated: true) - }.disposed(by: disposeBag) } private func setBinding() { diff --git a/GME Remit/Modules/Notice/DetailNotification/User Interface/Wireframe/DetailNotificationWireframe.swift b/GME Remit/Modules/Notice/DetailNotification/User Interface/Wireframe/DetailNotificationWireframe.swift index fd18c0d9..bee3ecd0 100644 --- a/GME Remit/Modules/Notice/DetailNotification/User Interface/Wireframe/DetailNotificationWireframe.swift +++ b/GME Remit/Modules/Notice/DetailNotification/User Interface/Wireframe/DetailNotificationWireframe.swift @@ -38,11 +38,11 @@ extension DetailNotificationWireframe: DetailNotificationWireframeInput { viewController.navigationController?.pushViewController(vc, animated: true) } - func open(with index: String, on viewController: UIViewController) { + func open(with index: String, on viewController: UIViewController?) { self.index = index let vc = getMainView() let naviVC = UINavigationController(rootViewController: vc) - viewController.present(naviVC, animated: true) + viewController?.present(naviVC, animated: true) } } diff --git a/GME Remit/Modules/Notice/NotificationHistory/Application Logic/Model/NoticeModel.swift b/GME Remit/Modules/Notice/NotificationHistory/Application Logic/Model/NoticeModel.swift index d19e6918..5e71a47b 100644 --- a/GME Remit/Modules/Notice/NotificationHistory/Application Logic/Model/NoticeModel.swift +++ b/GME Remit/Modules/Notice/NotificationHistory/Application Logic/Model/NoticeModel.swift @@ -12,6 +12,7 @@ struct NoticeModel: Mappable { var title: String? var key: String? var date: String? + var isRead: String? init?(map: Map) { @@ -21,5 +22,6 @@ struct NoticeModel: Mappable { title <- map["title"] key <- map["rowId"] date <- map["createDate"] + isRead <- map["isRead"] } } diff --git a/GME Remit/Modules/Notice/NotificationHistory/User Interface/View/NotificationCell.swift b/GME Remit/Modules/Notice/NotificationHistory/User Interface/View/NotificationCell.swift index 4821e466..c4c83920 100644 --- a/GME Remit/Modules/Notice/NotificationHistory/User Interface/View/NotificationCell.swift +++ b/GME Remit/Modules/Notice/NotificationHistory/User Interface/View/NotificationCell.swift @@ -12,9 +12,14 @@ class NotificationCell: UITableViewCell { @IBOutlet private weak var titleLabel: UILabel! @IBOutlet private weak var dateLabel: UILabel! + @IBOutlet private weak var newIconImageView: UIImageView! func setModel(_ model: NoticeModel) { + newIconImageView.isHidden = false + titleLabel.text = model.title dateLabel.text = model.date + + newIconImageView.isHidden = model.isRead == "1" } } diff --git a/GME Remit/Modules/Notice/NotificationHistory/User Interface/View/NotificationHistory.storyboard b/GME Remit/Modules/Notice/NotificationHistory/User Interface/View/NotificationHistory.storyboard index 5a2713f2..745251e0 100644 --- a/GME Remit/Modules/Notice/NotificationHistory/User Interface/View/NotificationHistory.storyboard +++ b/GME Remit/Modules/Notice/NotificationHistory/User Interface/View/NotificationHistory.storyboard @@ -35,7 +35,7 @@