Browse Source

library added

pull/1/head
gme_2 6 years ago
parent
commit
acc8c52a62
  1. 8
      GMERemittance.xcodeproj/project.pbxproj
  2. 4
      GMERemittance/AppDelegate.swift
  3. 38
      GMERemittance/Library/CountryFlag.swift
  4. 2
      GMERemittance/Library/TablePicker/TablePickerTableViewCell.swift
  5. 24
      GMERemittance/Module/ExchangeRateViewControllerV2.swift

8
GMERemittance.xcodeproj/project.pbxproj

@ -230,7 +230,7 @@
D9622319212BE3DC00B7A115 /* TablePickerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9622315212BE3DC00B7A115 /* TablePickerViewController.swift */; }; D9622319212BE3DC00B7A115 /* TablePickerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D9622315212BE3DC00B7A115 /* TablePickerViewController.swift */; };
D962231B212BE4CA00B7A115 /* TablePickerWithImageTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D962231A212BE4CA00B7A115 /* TablePickerWithImageTableViewCell.swift */; }; D962231B212BE4CA00B7A115 /* TablePickerWithImageTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = D962231A212BE4CA00B7A115 /* TablePickerWithImageTableViewCell.swift */; };
D962231E212C126500B7A115 /* ExchangeModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = D962231D212C126500B7A115 /* ExchangeModel.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 */; }; D96848C7212D3A7400EF12B1 /* DataRequestExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = D96848C6212D3A7400EF12B1 /* DataRequestExtension.swift */; };
D96848C9212D3AEB00EF12B1 /* ExtensionJSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = D96848C8212D3AEB00EF12B1 /* ExtensionJSON.swift */; }; D96848C9212D3AEB00EF12B1 /* ExtensionJSON.swift in Sources */ = {isa = PBXBuildFile; fileRef = D96848C8212D3AEB00EF12B1 /* ExtensionJSON.swift */; };
D96848CC212D3F2300EF12B1 /* ExchangeRateApiService.swift in Sources */ = {isa = PBXBuildFile; fileRef = D96848CB212D3F2300EF12B1 /* ExchangeRateApiService.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 = "<group>"; }; D9622315212BE3DC00B7A115 /* TablePickerViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TablePickerViewController.swift; sourceTree = "<group>"; };
D962231A212BE4CA00B7A115 /* TablePickerWithImageTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TablePickerWithImageTableViewCell.swift; sourceTree = "<group>"; }; D962231A212BE4CA00B7A115 /* TablePickerWithImageTableViewCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TablePickerWithImageTableViewCell.swift; sourceTree = "<group>"; };
D962231D212C126500B7A115 /* ExchangeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExchangeModel.swift; sourceTree = "<group>"; }; D962231D212C126500B7A115 /* ExchangeModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExchangeModel.swift; sourceTree = "<group>"; };
D9638A01212CF30C00B48742 /* CountryFlag.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CountryFlag.swift; sourceTree = "<group>"; };
D9638A01212CF30C00B48742 /* CountryInfo.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CountryInfo.swift; sourceTree = "<group>"; };
D96848C6212D3A7400EF12B1 /* DataRequestExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataRequestExtension.swift; sourceTree = "<group>"; }; D96848C6212D3A7400EF12B1 /* DataRequestExtension.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataRequestExtension.swift; sourceTree = "<group>"; };
D96848C8212D3AEB00EF12B1 /* ExtensionJSON.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExtensionJSON.swift; sourceTree = "<group>"; }; D96848C8212D3AEB00EF12B1 /* ExtensionJSON.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExtensionJSON.swift; sourceTree = "<group>"; };
D96848CB212D3F2300EF12B1 /* ExchangeRateApiService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExchangeRateApiService.swift; sourceTree = "<group>"; }; D96848CB212D3F2300EF12B1 /* ExchangeRateApiService.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ExchangeRateApiService.swift; sourceTree = "<group>"; };
@ -1049,7 +1049,7 @@
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
D9622302212BD62F00B7A115 /* TablePicker */, D9622302212BD62F00B7A115 /* TablePicker */,
D9638A01212CF30C00B48742 /* CountryFlag.swift */,
D9638A01212CF30C00B48742 /* CountryInfo.swift */,
); );
path = Library; path = Library;
sourceTree = "<group>"; sourceTree = "<group>";
@ -1521,7 +1521,7 @@
9F2E0D162059168C008611D1 /* LoadBalanceViewController.swift in Sources */, 9F2E0D162059168C008611D1 /* LoadBalanceViewController.swift in Sources */,
A2233B3220297C960014AE4C /* AgentSearchViewController.swift in Sources */, A2233B3220297C960014AE4C /* AgentSearchViewController.swift in Sources */,
A24B44FC204D158F009BF491 /* HomeViewModel.swift in Sources */, A24B44FC204D158F009BF491 /* HomeViewModel.swift in Sources */,
D9638A02212CF30C00B48742 /* CountryFlag.swift in Sources */,
D9638A02212CF30C00B48742 /* CountryInfo.swift in Sources */,
9F16112A2029A2DE009E8610 /* TrackRecipientTableViewCell.swift in Sources */, 9F16112A2029A2DE009E8610 /* TrackRecipientTableViewCell.swift in Sources */,
9FCBD347202AE76900BAEB32 /* TrackPhaseViewController.swift in Sources */, 9FCBD347202AE76900BAEB32 /* TrackPhaseViewController.swift in Sources */,
D962231B212BE4CA00B7A115 /* TablePickerWithImageTableViewCell.swift in Sources */, D962231B212BE4CA00B7A115 /* TablePickerWithImageTableViewCell.swift in Sources */,

4
GMERemittance/AppDelegate.swift

@ -16,6 +16,7 @@ import BRYXBanner
import Fabric import Fabric
import Crashlytics import Crashlytics
import AlamofireNetworkActivityLogger import AlamofireNetworkActivityLogger
import IQKeyboardManagerSwift
@UIApplicationMain @UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, MessagingDelegate { class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate, MessagingDelegate {
@ -44,6 +45,9 @@ class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterD
NetworkActivityLogger.shared.startLogging() NetworkActivityLogger.shared.startLogging()
NetworkActivityLogger.shared.level = .debug NetworkActivityLogger.shared.level = .debug
IQKeyboardManager.shared.enable = true
if #available(iOS 10.0, *) { if #available(iOS 10.0, *) {
// For iOS 10 display notification (sent via APNS) // For iOS 10 display notification (sent via APNS)
UNUserNotificationCenter.current().delegate = self UNUserNotificationCenter.current().delegate = self

38
GMERemittance/Library/CountryFlag.swift

@ -8,7 +8,7 @@
import Foundation import Foundation
class CountryFlag {
class CountryInfo {
private var flag: [String: UIImage] = private var flag: [String: UIImage] =
[ [
"sg" : #imageLiteral(resourceName: "flag_singapore"), // singapore "sg" : #imageLiteral(resourceName: "flag_singapore"), // singapore
@ -29,10 +29,42 @@ class CountryFlag {
"np" : #imageLiteral(resourceName: "flag_nepal") // nepal "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() let code = countryCode.lowercased()
return flag[code] return flag[code]
} }
func getDefaultSendingAmount(for countryCode) -> String? {
return defaultSendingAmount[countryCode]
}
func getDefaultSendingCurrency(for countryCode) -> String? {
return defaultSendingCurrency[countryCode]
}
} }

2
GMERemittance/Library/TablePicker/TablePickerTableViewCell.swift

@ -27,7 +27,7 @@ class TablePickerTableViewCell: UITableViewCell {
let currency = place?.currency ?? "" let currency = place?.currency ?? ""
self.titleLabel.text = "\(country) (\(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 self.flagImageview.image = image
} }

24
GMERemittance/Module/ExchangeRateViewControllerV2.swift

@ -36,17 +36,32 @@ class ExchangeRateViewControllerV2: UIViewController {
var countryListTapGuesture: UITapGestureRecognizer? var countryListTapGuesture: UITapGestureRecognizer?
var exchangeModels: [ExchangeRateModel] = []
var selectedPaymentIndex: IndexPath = IndexPath.init(row: 0, section: 0) 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? { var selectedExchageRateModel: ExchangeRateModel? {
didSet { didSet {
self.countryCodeLabel.text = self.selectedExchageRateModel?.countryCode 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.countryFlagImage.image = image
} }
self.collectionView.reloadData() self.collectionView.reloadData()
@ -109,14 +124,13 @@ class ExchangeRateViewControllerV2: UIViewController {
// other function // other function
func countrySelected(model: [ExchangeRateModel]) { func countrySelected(model: [ExchangeRateModel]) {
self.selectedExchageRateModel = model.first self.selectedExchageRateModel = model.first
print(model.first?.country)
// show country with flag. // show country with flag.
} }
private func fetchExchangeRateInformation() { private func fetchExchangeRateInformation() {
self.showProgressHud() self.showProgressHud()
self.fetchCountryCurrencyInfo(success: { (models) in self.fetchCountryCurrencyInfo(success: { (models) in
self.exchangeModels = models
self.exchangeRateModels = models
self.hideProgressHud() self.hideProgressHud()
}) { (error) in }) { (error) in
self.hideProgressHud() self.hideProgressHud()

Loading…
Cancel
Save