From bed506121f4625102099189eea0154032675ff5a Mon Sep 17 00:00:00 2001 From: james Date: Mon, 27 May 2019 10:16:51 +0900 Subject: [PATCH] change ui --- .DS_Store | Bin 10244 -> 10244 bytes .../View/HomeViewController.swift | 90 ++++------ .../Interactor/HotLineInteractor.swift | 13 +- .../View/Cell/HotLineCell.swift | 85 +++++++-- .../User Interface/View/HotLine.storyboard | 163 ++++++++---------- .../View/HotLineViewController.swift | 14 +- 6 files changed, 202 insertions(+), 163 deletions(-) diff --git a/.DS_Store b/.DS_Store index 36348e6949790781509237faaf1af1eed0d15d38..f3c2465c8bb7aca2bec56c8fffb81d8e26a60d3b 100644 GIT binary patch delta 32 ocmZn(XbG6$ÄU^hRb#%3M?1kd!= diff --git a/GMERemittance/Module/Home/User Interface/View/HomeViewController.swift b/GMERemittance/Module/Home/User Interface/View/HomeViewController.swift index 567834bc..9fa9aaae 100644 --- a/GMERemittance/Module/Home/User Interface/View/HomeViewController.swift +++ b/GMERemittance/Module/Home/User Interface/View/HomeViewController.swift @@ -117,31 +117,7 @@ class HomeViewController: UIViewController, UICollectionViewDelegateFlowLayout { super.viewDidAppear(animated) if KeyChain.shared.get(key: .biometricAuth) == nil { - // new page BiometricAuthenticationNotificationWireframe().openMainView(source: self) - - // alert -// self.alertWithOkCancel( -// message: "(manual: Settings -> Use FaceID & TouchID)", -// title: "Do you want to use your FaceID & TouchID\nto log in and send money?", -// okTitle: "Use", -// style: .alert, -// cancelTitle: "Don't use", -// OkStyle: .default, -// cancelStyle: .destructive, -// okAction: { -// BiometricAuthenticationWireframe().showBiometricAuthentication() { error in -// if error != nil { -// KeyChain.shared.save(data: "0", key: .biometricAuth) -// } else { -// KeyChain.shared.save(data: "1", key: .biometricAuth) -// } -// } -// }, -// cancelAction: { -// KeyChain.shared.save(data: "0", key: .biometricAuth) -// } -// ) } } // MARK: IBActions @@ -308,38 +284,40 @@ class HomeViewController: UIViewController, UICollectionViewDelegateFlowLayout { } @objc func showSupport() { - let alert = UIAlertController(title:nil, message:"help_you_text".localized(), 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: userHotLine?.remitPhone ?? "1588 6864", style: .default) { - UIAlertAction in - self.startCall(contactNumber: self.userHotLine?.remitPhone ?? "1588 6864") - } - let supportEmail = UIAlertAction(title: "support@gmeremit.com", style: .default) { - UIAlertAction in - let storyboard = UIStoryboard.init(name: "MessageCompose", bundle: Bundle.main) - if let messageViewController = storyboard.instantiateViewController(withIdentifier: "message") as? MessageComposeViewController { - 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_text".localized(), style: UIAlertActionStyle.cancel, handler: nil)) - present(alert, animated: true, completion: nil) + +// let alert = UIAlertController(title:nil, message:"help_you_text".localized(), 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: userHotLine?.remitPhone ?? "1588 6864", style: .default) { +// UIAlertAction in +// self.startCall(contactNumber: self.userHotLine?.remitPhone ?? "1588 6864") +// } +// let supportEmail = UIAlertAction(title: "support@gmeremit.com", style: .default) { +// UIAlertAction in +// let storyboard = UIStoryboard.init(name: "MessageCompose", bundle: Bundle.main) +// if let messageViewController = storyboard.instantiateViewController(withIdentifier: "message") as? MessageComposeViewController { +// 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_text".localized(), style: UIAlertActionStyle.cancel, handler: nil)) +// present(alert, animated: true, completion: nil) + HotLineWireframe().openHotLineUsingPanModal(in: self) } diff --git a/GMERemittance/Utility/HotLine/Application Logic/Interactor/HotLineInteractor.swift b/GMERemittance/Utility/HotLine/Application Logic/Interactor/HotLineInteractor.swift index 78ee82a6..7b476744 100644 --- a/GMERemittance/Utility/HotLine/Application Logic/Interactor/HotLineInteractor.swift +++ b/GMERemittance/Utility/HotLine/Application Logic/Interactor/HotLineInteractor.swift @@ -29,7 +29,18 @@ extension HotLineInteractor: HotLineInteractorInput { func fetchHotLines() { service.fetchHotLines( success: { - self.output?.setHotLine(with: $0) + let userCountry = UserDefaults.standard.string(forKey: AppConstants.firstTimeLanguageIsSet) + + guard + let userHotLine = $0?.filter({ $0.countryCode == userCountry }), + let anotherHotLines = $0?.filter ({ $0.countryCode != userCountry }) + else { + self.output?.setHotLine(with: $0) + return + } + + let restoredHotLines = userHotLine + anotherHotLines + self.output?.setHotLine(with: restoredHotLines) }, failure: { self.output?.setError(with: $0) diff --git a/GMERemittance/Utility/HotLine/User Interface/View/Cell/HotLineCell.swift b/GMERemittance/Utility/HotLine/User Interface/View/Cell/HotLineCell.swift index 9eca5d14..d82fbc65 100644 --- a/GMERemittance/Utility/HotLine/User Interface/View/Cell/HotLineCell.swift +++ b/GMERemittance/Utility/HotLine/User Interface/View/Cell/HotLineCell.swift @@ -9,16 +9,81 @@ import UIKit class HotLineCell: UITableViewCell { - - override func awakeFromNib() { - super.awakeFromNib() - // Initialization code + + @IBOutlet weak var flagImageView: UIImageView! + + private var remitPhoneNunmber: String? + private var remitFacebookURL: String? + + private var loanPhoneNumber: String? + private var loanFacebookUrl: String? + + private var countryName: String? + + private var coutryFlag: UIImage? { + didSet { + flagImageView.image = coutryFlag } - - override func setSelected(_ selected: Bool, animated: Bool) { - super.setSelected(selected, animated: animated) - - // Configure the view for the selected state + } + + @IBAction func touchButtons(_ sender: UIButton) { + switch sender.tag { + case 0: + guard let phone = remitPhoneNunmber + else { + return + } + + startCall(contactNumber: phone) + + case 1: + guard let url = remitFacebookURL + else { + return + } + + UIApplication.tryURL(url: url) + + case 2: + guard let phone = remitPhoneNunmber + else { + return + } + + startCall(contactNumber: phone) + case 3: + guard let url = remitFacebookURL + else { + return + } + + UIApplication.tryURL(url: url) + + default: + break } - + + } + + func setModel(_ model: HotLine?){ + remitPhoneNunmber = model?.remitPhone + remitFacebookURL = model?.remitFacebook + + loanPhoneNumber = model?.loanPhone + loanFacebookUrl = model?.loanFacebook + + countryName = model?.country + coutryFlag = CountryInfo().getFlag(for: model?.countryCode ?? "") + } + + private 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) + } + } + } + } diff --git a/GMERemittance/Utility/HotLine/User Interface/View/HotLine.storyboard b/GMERemittance/Utility/HotLine/User Interface/View/HotLine.storyboard index ca520d31..7d5aee1a 100644 --- a/GMERemittance/Utility/HotLine/User Interface/View/HotLine.storyboard +++ b/GMERemittance/Utility/HotLine/User Interface/View/HotLine.storyboard @@ -1,11 +1,12 @@ - + + @@ -17,11 +18,7 @@ - - - - - + @@ -30,139 +27,119 @@ - - + + - - + + - - + + - - + + - - - - - - - - - + + - - - - - - - - - - - - - - - - - - + + - - + - - + + - - - - - - - - - - - - + - + + + + + + + + - - - - + + + + + + + - - - - + + + + + @@ -174,7 +151,7 @@ - + diff --git a/GMERemittance/Utility/HotLine/User Interface/View/HotLineViewController.swift b/GMERemittance/Utility/HotLine/User Interface/View/HotLineViewController.swift index 6b74e748..af4c505e 100644 --- a/GMERemittance/Utility/HotLine/User Interface/View/HotLineViewController.swift +++ b/GMERemittance/Utility/HotLine/User Interface/View/HotLineViewController.swift @@ -15,7 +15,7 @@ class HotLineViewController: UIViewController { var presenter: HotLineModuleInterface? - let CellHeight: CGFloat = 180.0 + let CellHeight: CGFloat = 100.0 // MARK: Computed Properties @@ -45,11 +45,11 @@ class HotLineViewController: UIViewController { // MARK: HotLineViewInterface extension HotLineViewController: HotLineViewInterface { func setHotLine(with model: [HotLine]?) { - + hotLines = model } func setError(with error: Error) { - + alert(message: error.localizedDescription) } } @@ -57,6 +57,8 @@ extension HotLineViewController: HotLineViewInterface { extension HotLineViewController { private func setup() { // all setup should be done here + tableView.dataSource = self + presenter?.fetchHotLines() } } @@ -72,6 +74,8 @@ extension HotLineViewController: UITableViewDataSource { return UITableViewCell() } + cell.setModel(hotLines?[indexPath.row]) + return cell } @@ -87,6 +91,10 @@ extension HotLineViewController: PanModalPresentable { return self.tableView } + var shortFormHeight: PanModalHeight { + return .contentHeight(CellHeight) + } + var longFormHeight: PanModalHeight { return .maxHeight }