diff --git a/.DS_Store b/.DS_Store index ddc94f36..8c0954d1 100644 Binary files a/.DS_Store and b/.DS_Store differ 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