Browse Source

notification added

pull/1/head
gme_2 6 years ago
parent
commit
566e9244d8
  1. 61
      GMERemittance/Module/Home/User Interface/View/Cell/HomeCollectionTableViewCell.swift
  2. 91
      GMERemittance/Module/Home/User Interface/View/HomeViewController.swift
  3. 8
      GMERemittance/Utility/AppConstants.swift
  4. 10
      GMERemittance/_Home/_HomeViewController.swift

61
GMERemittance/Module/Home/User Interface/View/Cell/HomeCollectionTableViewCell.swift

@ -8,10 +8,29 @@
import UIKit
struct MenuNotificationName {
static let sendMoney = "SendMoeny"
static let mobileRecharge = "mobileRecharge"
static let todaysRate = "todaysRate"
static let trackYourTransfer = "trackYourTransfer"
static let transactionStatement = "transactionStatement"
static let walletToWallet = "walletToWallet"
}
class HomeCollectionTableViewCell: UITableViewCell, UICollectionViewDelegateFlowLayout {
enum CollectionMenus: Int {
case sendMoney = 0
case mobileRecharge
case todaysRate
case trackYourTransfer
case transationStatement
case walletToWallet
}
@IBOutlet weak var collectionView: UICollectionView!
private var menus: [HomeCollectionModel]?
var parentViewController: HomeViewController?
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
@ -72,7 +91,48 @@ class HomeCollectionTableViewCell: UITableViewCell, UICollectionViewDelegateFlow
extension HomeCollectionTableViewCell: UICollectionViewDelegate {
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
guard let index = self.menus?.elementAt(index: indexPath.row)?.index else {return}
guard let _index = CollectionMenus.init(rawValue: index) else {return }
let center = NotificationCenter.default
switch _index {
case .sendMoney:
center.post(name: self.getSendMoneyNotificationName(), object: nil)
case .mobileRecharge:
center.post(name: self.getMobileRechargeNotificationName(), object: nil)
case .todaysRate:
center.post(name: self.getTodaysRateNotificationName(), object: nil)
case .trackYourTransfer:
center.post(name: self.getTrackYourTransferNotificationName(), object: nil)
case .transationStatement:
center.post(name: self.getTransactionStatementNotificationName(), object: nil)
case .walletToWallet:
center.post(name: self.getWalletToWalletNotificationName(), object: nil)
}
}
func getSendMoneyNotificationName() -> Notification.Name {
return Notification.Name.init(rawValue: MenuNotificationName.sendMoney)
}
func getMobileRechargeNotificationName() -> Notification.Name {
return Notification.Name.init(rawValue: MenuNotificationName.mobileRecharge)
}
func getTodaysRateNotificationName() -> Notification.Name {
return Notification.Name.init(rawValue: MenuNotificationName.todaysRate)
}
func getTrackYourTransferNotificationName() -> Notification.Name {
return Notification.Name.init(rawValue: MenuNotificationName.trackYourTransfer)
}
func getTransactionStatementNotificationName() -> Notification.Name {
return Notification.Name.init(rawValue: MenuNotificationName.transactionStatement)
}
func getWalletToWalletNotificationName() -> Notification.Name {
return Notification.Name.init(rawValue: MenuNotificationName.walletToWallet)
}
}
extension HomeCollectionTableViewCell: UICollectionViewDataSource {
@ -91,3 +151,4 @@ extension HomeCollectionTableViewCell: UICollectionViewDataSource {
}

91
GMERemittance/Module/Home/User Interface/View/HomeViewController.swift

@ -35,16 +35,35 @@ class HomeViewController: UIViewController, UICollectionViewDelegateFlowLayout {
// MARK: IBActions
@IBAction func closeVerificationNotice(_ sender: UIButton) {
UIView.animate(withDuration: 0.33) {
self.verificationNoticeView.alpha = 0
}
self.verificationNoticeView.isHidden = true
}
// MARK: Other Functions
private func setup() {
// all setup should be done here
setupDelegates()
configureViews()
setupNotifications()
self.setupPicturedNavBar()
}
private func setupNotifications() {
let center = NotificationCenter.default
center.addObserver(self, selector: #selector(self.showSendMoney), name: self.getSendMoneyNotificationName(), object: nil)
center.addObserver(self, selector: #selector(self.showMobileRecharge), name: self.getMobileRechargeNotificationName(), object: nil)
center.addObserver(self, selector: #selector(self.showTodaysRate), name: self.getTodaysRateNotificationName(), object: nil)
center.addObserver(self, selector: #selector(self.showTrackYourTransfer), name: self.getTrackYourTransferNotificationName(), object: nil)
center.addObserver(self, selector: #selector(self.showTransactionStatement), name: self.getTransactionStatementNotificationName(), object: nil)
center.addObserver(self, selector: #selector(self.showWalletToWallet), name: self.getWalletToWalletNotificationName(), object: nil)
}
private func setupDelegates() {
self.tableView.delegate = self
self.tableView.dataSource = self
@ -65,19 +84,54 @@ class HomeViewController: UIViewController, UICollectionViewDelegateFlowLayout {
showUnverifiedNotice()
}
@IBAction func closeVerificationNotice(_ sender: UIButton) {
UIView.animate(withDuration: 0.33) {
self.verificationNoticeView.alpha = 0
}
self.verificationNoticeView.isHidden = true
}
private func isUserVerified() -> Bool {
return false
let val = (UserDefaults.standard.object(forKey: UserKeys.verified) as? Bool ) ?? false
print(val)
return val
}
@objc private func showSendMoney() {
if !isVerifiedUser() {
let viewcontroller = UIStoryboard.init(name:
"RecipientListViewController", bundle: nil).instantiateViewController(withIdentifier: "RecipientListViewController") as! RecipientListViewController
self.navigationController?.pushViewController(viewcontroller, animated: true)
} else {
self.popUpMessage(value: 13)
}
}
@objc private func showMobileRecharge() {
self.alert(message: "This feature is coming soon")
return
if isUserVerified() {
self.performSegue(withIdentifier: "mobileRecharge", sender: nil)
}else {
self.popUpMessage(value: 13)
}
}
@objc private func showTodaysRate() {
let exchangeRateWireFrame = ExchangeRatesWireframe()
if let navigation = self.navigationController {
exchangeRateWireFrame.pushMainView(in: navigation)
}
}
@objc private func showTrackYourTransfer() {
self.performSegue(withIdentifier: "trackTransfer", sender: nil)
}
@objc private func showTransactionStatement() {
self.performSegue(withIdentifier: "transactionStatement", sender: nil)
}
@objc private func showWalletToWallet() {
self.alert(message: "This feature is coming soon")
}
}
// MARK: HomeViewInterface
@ -137,3 +191,28 @@ extension HomeViewController: UITableViewDataSource {
}
}
// notification Name
extension HomeViewController {
func getSendMoneyNotificationName() -> Notification.Name {
return Notification.Name.init(rawValue: MenuNotificationName.sendMoney)
}
func getMobileRechargeNotificationName() -> Notification.Name {
return Notification.Name.init(rawValue: MenuNotificationName.mobileRecharge)
}
func getTodaysRateNotificationName() -> Notification.Name {
return Notification.Name.init(rawValue: MenuNotificationName.todaysRate)
}
func getTrackYourTransferNotificationName() -> Notification.Name {
return Notification.Name.init(rawValue: MenuNotificationName.trackYourTransfer)
}
func getTransactionStatementNotificationName() -> Notification.Name {
return Notification.Name.init(rawValue: MenuNotificationName.transactionStatement)
}
func getWalletToWalletNotificationName() -> Notification.Name {
return Notification.Name.init(rawValue: MenuNotificationName.walletToWallet)
}
}

8
GMERemittance/Utility/AppConstants.swift

@ -37,3 +37,11 @@ class Utility {
return nil
}
}
func isVerifiedUser() -> Bool {
return false
let val = (UserDefaults.standard.object(forKey: UserKeys.verified) as? Bool ) ?? false
print("value is")
print(val)
return val
}

10
GMERemittance/_Home/_HomeViewController.swift

@ -163,13 +163,7 @@ class _HomeViewController: UIViewController, TableViewCellDelegate, FBSDKSharin
sideMenuController?.showLeftViewAnimated()
}
func isVerifiedUser() -> Bool {
return false
let val = (UserDefaults.standard.object(forKey: UserKeys.verified) as? Bool ) ?? false
print("value is")
print(val)
return val
}
/**
Update User data in view
@ -1370,7 +1364,7 @@ extension _HomeViewController: UICollectionViewDelegate, UICollectionViewDataSou
switch collectionViewMenuIndexArray[indexPath.row] {
case 0:
if self.isVerifiedUser() {
if isVerifiedUser() {
// self.performSegue(withIdentifier: "recipientList", sender: nil)
// RecipientListViewController
// recipientList

Loading…
Cancel
Save