From 0ffdf2a91fff8091763ace23ba5b7ffce04ff834 Mon Sep 17 00:00:00 2001 From: gme_2 Date: Fri, 28 Sep 2018 10:51:38 +0900 Subject: [PATCH] added actions --- .DS_Store | Bin 8196 -> 8196 bytes .../View/HomeViewController.swift | 69 ++++++++++++++++++ 2 files changed, 69 insertions(+) diff --git a/.DS_Store b/.DS_Store index ddc94f36963a4ac586c7bf7a6815ba2d14d85427..8c0954d175e70b8af848ca39f449a753bbd6bfd9 100644 GIT binary patch delta 100 zcmZp1XmQxENsw{hi_wQMkTHlc mngI-$7$G!+ER=>)j46{11mrfi2v@LdW|#QJviXw;J2L=Rx)b;S delta 95 zcmZp1XmQxENsw{#B#8J=)vg87{mYuOpFkk hK?X`gDaPo{g~HQVCN^+yW|#QJvYA8lKhwkp4gkhE6H)*G diff --git a/GMERemittance/Module/Home/User Interface/View/HomeViewController.swift b/GMERemittance/Module/Home/User Interface/View/HomeViewController.swift index 6602cc9b..1ec9c9e4 100644 --- a/GMERemittance/Module/Home/User Interface/View/HomeViewController.swift +++ b/GMERemittance/Module/Home/User Interface/View/HomeViewController.swift @@ -37,6 +37,11 @@ class HomeViewController: UIViewController, UICollectionViewDelegateFlowLayout { self.setup() } + override func viewWillAppear(_ animated: Bool) { + super.viewWillAppear(animated) + self.setActionBarIcons(showNotificationParameter: false) // set true if there is unread notification + } + override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) self.navigationItem.title = "" @@ -61,8 +66,59 @@ class HomeViewController: UIViewController, UICollectionViewDelegateFlowLayout { self.setupPicturedNavBar() } + + @objc func showNotification(){ + performSegue(withIdentifier: "notification", sender: nil) + } + + @objc func showSupport() { + let alert = UIAlertController(title:nil, message:"We are there to help you \n (Available time 10:00AM - 6:00PM)", preferredStyle: .actionSheet) +// alert.view.subviews.last?.subviews.last?.backgroundColor = UIColor.darkGray + + let liveChat = UIAlertAction(title: "Live Chat", style: .default) { + UIAlertAction in + } + let contactNumber = UIAlertAction(title: "1588 6864", style: .default) { + UIAlertAction in + self.startCall(contactNumber: "1588 6864") + } + let supportEmail = UIAlertAction(title: "support@gmeremit.com", style: .default) { + UIAlertAction in + + let storyboard = UIStoryboard.init(name: "_Home", bundle: Bundle.main) + if let messageViewController = storyboard.instantiateViewController(withIdentifier: "message") as? MessageComposeViewController { + messageViewController.supportIndex = 0 + self.navigationController!.pushViewController(messageViewController, animated: true) + } + } + + liveChat.setValue(UIImage(named:"ic_live_chat")?.withRenderingMode(.alwaysOriginal),forKey:"image") + contactNumber.setValue(UIImage(named:"ic_call")?.withRenderingMode(.alwaysOriginal),forKey:"image") + supportEmail.setValue(UIImage(named:"ic_email")?.withRenderingMode(.alwaysOriginal),forKey:"image") + + // TODO: have to enable when zendesk is provided + // alert.addAction(liveChat) + alert.addAction(contactNumber) + alert.addAction(supportEmail) + alert.view.tintColor = UIColor.darkGray + +// alert.view.subviews.last?.subviews.last?.layer.cornerRadius = 10 + + alert.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.cancel, handler: nil)) + present(alert, animated: true, completion: nil) + } + func startCall(contactNumber: String){ + if let url = URL(string: "tel://\(contactNumber.removeWhitespacesInBetween())"), UIApplication.shared.canOpenURL(url) { + if #available(iOS 10, *) { + UIApplication.shared.open(url) + } else { + UIApplication.shared.openURL(url) + } + } + } + private func setupNotifications() { let center = NotificationCenter.default center.addObserver(self, selector: #selector(self.showSendMoney), name: self.getSendMoneyNotificationName(), object: nil) @@ -74,6 +130,19 @@ class HomeViewController: UIViewController, UICollectionViewDelegateFlowLayout { center.addObserver(self, selector: #selector(self.setupHeight(sender:)), name: self.getCollectionHeightNotificationName(), object: nil) } + func setActionBarIcons(showNotificationParameter: Bool){ + let supportImage = UIImage(named: "ic_support")?.withRenderingMode(.alwaysOriginal) + let supportButton = UIBarButtonItem(image:supportImage, style: .plain, target: self, action: #selector(showSupport)) + let notificationImage: UIImage! + if showNotificationParameter { + notificationImage = UIImage(named: "ic_notificationDot")?.withRenderingMode(.alwaysOriginal) + } else { + notificationImage = UIImage(named: "ic_notification")?.withRenderingMode(.alwaysOriginal) + } + let notificationButton = UIBarButtonItem(image: notificationImage, style: .plain, target: self, action: #selector(showNotification)) + self.navigationItem.rightBarButtonItems=[notificationButton,supportButton] + } + private func setupDelegates() { self.tableView.delegate = self self.tableView.dataSource = self