@ -10,6 +10,17 @@ import UIKit
class AutoDebitViewController : UIViewController {
struct StringConstants {
static let navigationTitle = " Manage Auto Debit Account "
static let languageUnavailableError = " No Lanugages Available "
static let pickerTitle = " Select Language "
static let cancelText = " Cancel "
static let deleteTitleText = " You want to delete Auto-Debit Account! "
static let confirmationText = " Are you sure? "
static let deleteText = " Delete "
static let editText = " Edit "
}
// MARK: - I B O u t l e t s
@IBOutlet weak var tableView : UITableView !
@IBOutlet weak var viewAddAccount : UIView ! // t h i s i s t h e v i e w t h a t c o n t a i n s a d d r e c i e p i e n t . s h o u l d b e h e a d e r
@ -77,7 +88,7 @@ class AutoDebitViewController: UIViewController {
override func viewWillAppear ( _ animated : Bool ) {
super . viewWillAppear ( animated )
self . setupNormalNavigation ( )
self . navigationItem . title = " Manage Auto Debit Account "
self . navigationItem . title = StringConstants . navigationTitle
fetchReceipients ( )
}
@ -113,7 +124,7 @@ class AutoDebitViewController: UIViewController {
if ( self . languages ? ? [ ] ) . isEmpty {
self . alert ( message : " No Lanugages Available " )
self . alert ( message : StringConstants . languageUnavailableError )
}
showLanguageSelection ( )
@ -126,7 +137,7 @@ class AutoDebitViewController: UIViewController {
}
private func showLanguageSelection ( ) {
let picker = UIAlertController . init ( title : " Select Language " , message : nil , preferredStyle : UIAlertControllerStyle . actionSheet )
let picker = UIAlertController . init ( title : StringConstants . pickerTitle , message : nil , preferredStyle : UIAlertControllerStyle . actionSheet )
self . languages ? . forEach ( { language in
let action = UIAlertAction . init ( title : language . value , style : UIAlertActionStyle . default , handler : { ( action ) in
@ -135,21 +146,10 @@ class AutoDebitViewController: UIViewController {
picker . addAction ( action )
} )
let cancelAction = UIAlertAction . init ( title : " Cancel " , style : UIAlertActionStyle . cancel , handler : nil )
let cancelAction = UIAlertAction . init ( title : StringConstants . cancelText , style : UIAlertActionStyle . cancel , handler : nil )
picker . addAction ( cancelAction )
self . present ( picker , animated : true , completion : nil )
}
private func createDummyLangugage ( ) -> [ KftcLanguage ] {
let leng = KftcLanguage ( )
leng . key = " eng "
leng . value = " English "
let leng1 = KftcLanguage ( )
leng1 . key = " Nepali "
leng1 . value = " Nepali "
return [ leng , leng1 ]
}
}
extension AutoDebitViewController : UITableViewDelegate , UITableViewDataSource {
@ -174,19 +174,11 @@ extension AutoDebitViewController: UITableViewDelegate,UITableViewDataSource {
// s t a r t S e n d M o n e y P r o c e s s ( i n d e x : i n d e x P a t h . r o w )
}
// p r i v a t e f u n c s t a r t S e n d M o n e y P r o c e s s ( i n d e x : I n t ) {
// i f l e t n a v i g a t i o n = s e l f . n a v i g a t i o n C o n t r o l l e r {
// i f l e t r e c i e p i e n t = s e l f . a c c o u n t s ? . e l e m e n t A t ( i n d e x : i n d e x ) {
// l e t w i r e f r a m e = S e n d M o n e y P a r e n t W i r e f r a m e ( )
// / / w i r e f r a m e . o p e n ( f o r : r e c i e p i e n t , i n : n a v i g a t i o n )
// }
// }
// }
func tableView ( _ tableView : UITableView , editActionsForRowAt indexPath : IndexPath ) -> [ UITableViewRowAction ] ? {
let delete = UITableViewRowAction ( style : . destructive , title : " Delete " ) { ( action , indexPath ) in
let delete = UITableViewRowAction ( style : . destructive , title : StringConstants . deleteTitleText ) { ( action , indexPath ) in
self . alertWithOkCancel ( message : " You want to delete Auto-Debit Account! " , title : " Are you sure? " , okTitle : " Delete " , OkStyle : UIAlertActionStyle . destructive , okAction : {
self . alertWithOkCancel ( message : StringConstants . deleteTitleText , title : StringConstants . confirmationText , okTitle : StringConstants . deleteTitleText , OkStyle : UIAlertActionStyle . destructive , okAction : {
let defaults = UserDefaults . standard
let myUsername = defaults . string ( forKey : " com.gmeremit.username " ) ? ? " "
@ -203,7 +195,7 @@ extension AutoDebitViewController: UITableViewDelegate,UITableViewDataSource {
} )
}
let edit = UITableViewRowAction ( style : . normal , title : " Edit " ) { ( action , indexPath ) in
let edit = UITableViewRowAction ( style : . normal , title : StringConstants . editText ) { ( action , indexPath ) in
guard let navigation = self . navigationController else { return }
if let reciepient = self . accounts ? . elementAt ( index : indexPath . row ) {