diff --git a/GMERemittance.xcodeproj/project.pbxproj b/GMERemittance.xcodeproj/project.pbxproj index e450f99e..39e6a423 100644 --- a/GMERemittance.xcodeproj/project.pbxproj +++ b/GMERemittance.xcodeproj/project.pbxproj @@ -230,7 +230,7 @@ D9622319212BE3DC00B7A115 /* TablePickerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9622315212BE3DC00B7A115 /* TablePickerViewController.swift */; }; D962231B212BE4CA00B7A115 /* TablePickerWithImageTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D962231A212BE4CA00B7A115 /* TablePickerWithImageTableViewCell.swift */; }; D962231E212C126500B7A115 /* ExchangeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D962231D212C126500B7A115 /* ExchangeModel.swift */; }; - D9638A02212CF30C00B48742 /* CountryFlag.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9638A01212CF30C00B48742 /* CountryFlag.swift */; }; + D9638A02212CF30C00B48742 /* CountryInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9638A01212CF30C00B48742 /* CountryInfo.swift */; }; D96848C7212D3A7400EF12B1 /* DataRequestExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D96848C6212D3A7400EF12B1 /* DataRequestExtension.swift */; }; D96848C9212D3AEB00EF12B1 /* ExtensionJSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = D96848C8212D3AEB00EF12B1 /* ExtensionJSON.swift */; }; D96848CC212D3F2300EF12B1 /* ExchangeRateApiService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D96848CB212D3F2300EF12B1 /* ExchangeRateApiService.swift */; }; @@ -496,7 +496,7 @@ D9622315212BE3DC00B7A115 /* TablePickerViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TablePickerViewController.swift; sourceTree = ""; }; D962231A212BE4CA00B7A115 /* TablePickerWithImageTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TablePickerWithImageTableViewCell.swift; sourceTree = ""; }; D962231D212C126500B7A115 /* ExchangeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExchangeModel.swift; sourceTree = ""; }; - D9638A01212CF30C00B48742 /* CountryFlag.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CountryFlag.swift; sourceTree = ""; }; + D9638A01212CF30C00B48742 /* CountryInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CountryInfo.swift; sourceTree = ""; }; D96848C6212D3A7400EF12B1 /* DataRequestExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataRequestExtension.swift; sourceTree = ""; }; D96848C8212D3AEB00EF12B1 /* ExtensionJSON.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExtensionJSON.swift; sourceTree = ""; }; D96848CB212D3F2300EF12B1 /* ExchangeRateApiService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExchangeRateApiService.swift; sourceTree = ""; }; @@ -1049,7 +1049,7 @@ isa = PBXGroup; children = ( D9622302212BD62F00B7A115 /* TablePicker */, - D9638A01212CF30C00B48742 /* CountryFlag.swift */, + D9638A01212CF30C00B48742 /* CountryInfo.swift */, ); path = Library; sourceTree = ""; @@ -1521,7 +1521,7 @@ 9F2E0D162059168C008611D1 /* LoadBalanceViewController.swift in Sources */, A2233B3220297C960014AE4C /* AgentSearchViewController.swift in Sources */, A24B44FC204D158F009BF491 /* HomeViewModel.swift in Sources */, - D9638A02212CF30C00B48742 /* CountryFlag.swift in Sources */, + D9638A02212CF30C00B48742 /* CountryInfo.swift in Sources */, 9F16112A2029A2DE009E8610 /* TrackRecipientTableViewCell.swift in Sources */, 9FCBD347202AE76900BAEB32 /* TrackPhaseViewController.swift in Sources */, D962231B212BE4CA00B7A115 /* TablePickerWithImageTableViewCell.swift in Sources */, diff --git a/GMERemittance/AppDelegate.swift b/GMERemittance/AppDelegate.swift index c06dd3b4..de91789e 100644 --- a/GMERemittance/AppDelegate.swift +++ b/GMERemittance/AppDelegate.swift @@ -16,6 +16,7 @@ import BRYXBanner import Fabric import Crashlytics import AlamofireNetworkActivityLogger +import IQKeyboardManagerSwift @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, MessagingDelegate { @@ -44,6 +45,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD NetworkActivityLogger.shared.startLogging() NetworkActivityLogger.shared.level = .debug + IQKeyboardManager.shared.enable = true + + if #available(iOS 10.0, *) { // For iOS 10 display notification (sent via APNS) UNUserNotificationCenter.current().delegate = self diff --git a/GMERemittance/Library/CountryFlag.swift b/GMERemittance/Library/CountryFlag.swift index 9aea2ee6..90c49e6a 100644 --- a/GMERemittance/Library/CountryFlag.swift +++ b/GMERemittance/Library/CountryFlag.swift @@ -8,7 +8,7 @@ import Foundation -class CountryFlag { +class CountryInfo { private var flag: [String: UIImage] = [ "sg" : #imageLiteral(resourceName: "flag_singapore"), // singapore @@ -29,10 +29,42 @@ class CountryFlag { "np" : #imageLiteral(resourceName: "flag_nepal") // nepal ] - func getFlagfor(countryCode: String) -> UIImage? { + + private var defaultSendingAmount: [String: String] = + [ + "np" : "100000", // nepal + "kh" : "500", // cambodia + "ph" : "50000" // philipines + "lk" : "100,000" // sri lanka + "vn" : "20000000" // vietnam + "in" : "50000" // india + "pk" : "100000" // pakistan + "default": "1000000" + ] + + private var defaultSendingCurrency: [String: String] = + [ + "np" : "NPR", // nepal + "kh" : "USD", // cambodia + "ph" : "PHP" // philipines + "lk" : "LKR" // sri lanka + "vn" : "VND" // vietnam + "in" : "INR" // india + "pk" : "PKR" // pakistan + "default": "KRW" + ] + + func getFlag(for countryCode: String) -> UIImage? { let code = countryCode.lowercased() return flag[code] } - + + func getDefaultSendingAmount(for countryCode) -> String? { + return defaultSendingAmount[countryCode] + } + + func getDefaultSendingCurrency(for countryCode) -> String? { + return defaultSendingCurrency[countryCode] + } } diff --git a/GMERemittance/Library/TablePicker/TablePickerTableViewCell.swift b/GMERemittance/Library/TablePicker/TablePickerTableViewCell.swift index 28a8d96c..62ee62e9 100644 --- a/GMERemittance/Library/TablePicker/TablePickerTableViewCell.swift +++ b/GMERemittance/Library/TablePicker/TablePickerTableViewCell.swift @@ -27,7 +27,7 @@ class TablePickerTableViewCell: UITableViewCell { let currency = place?.currency ?? "" self.titleLabel.text = "\(country) (\(currency))" - if let image = CountryFlag().getFlagfor(countryCode: self.place?.countryCode ?? "") { + if let image = CountryInfo().getFlagfor(countryCode: self.place?.countryCode ?? "") { self.flagImageview.image = image } diff --git a/GMERemittance/Module/ExchangeRateViewControllerV2.swift b/GMERemittance/Module/ExchangeRateViewControllerV2.swift index 09213507..dae27b60 100644 --- a/GMERemittance/Module/ExchangeRateViewControllerV2.swift +++ b/GMERemittance/Module/ExchangeRateViewControllerV2.swift @@ -36,17 +36,32 @@ class ExchangeRateViewControllerV2: UIViewController { var countryListTapGuesture: UITapGestureRecognizer? - var exchangeModels: [ExchangeRateModel] = [] + var selectedPaymentIndex: IndexPath = IndexPath.init(row: 0, section: 0) + var nativeCountry: String? = "Nepal" - var exchangeRateModels: [ExchangeRateModel] = [] + var exchangeRateModels: [ExchangeRateModel] = [] { + didSet { + // added default values + if let defaultExchangeRate = self.exchangeRateModels.filter({ + ($0.country ?? "").lowercased() == (self.nativeCountry ?? "").lowercased() + }).first { + // there is native country and defaultExchangeRate is the information for that country + let countryCode = defaultExchangeRate.countryCode + let flag = CountryInfo().getFlagfor(countryCode: countryCode ?? "") + self.countryCodeLabel.text = countryCode + self.countryFlagImage.image = flag + + } + } + } var selectedExchageRateModel: ExchangeRateModel? { didSet { self.countryCodeLabel.text = self.selectedExchageRateModel?.countryCode - if let image = CountryFlag().getFlagfor(countryCode: self.selectedExchageRateModel?.countryCode ?? "") { + if let image = CountryInfo().getFlagfor(countryCode: self.selectedExchageRateModel?.countryCode ?? "") { self.countryFlagImage.image = image } self.collectionView.reloadData() @@ -109,14 +124,13 @@ class ExchangeRateViewControllerV2: UIViewController { // other function func countrySelected(model: [ExchangeRateModel]) { self.selectedExchageRateModel = model.first - print(model.first?.country) // show country with flag. } private func fetchExchangeRateInformation() { self.showProgressHud() self.fetchCountryCurrencyInfo(success: { (models) in - self.exchangeModels = models + self.exchangeRateModels = models self.hideProgressHud() }) { (error) in self.hideProgressHud()