Skip to content
Permalink
76ef02638d
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
54 lines (50 sloc) 2.16 KB
//
// BankSelectionInterfaceController.swift
// SynchronyFinancial WatchKit Extension
//
// Created by Rahul Kantesaria on 4/5/19.
// Copyright © 2019 Alan Maynard. All rights reserved.
//
import WatchKit
import Foundation
class PaymentOptionsInterfaceController: WKInterfaceController {
@IBOutlet weak var bankAcctTable: WKInterfaceTable!
var bankAccts: [BankAcct] = []
var dictForDefault: [String: String] = [:]
override func awake(withContext context: Any?) {
super.awake(withContext: context)
//grab the potential list of bank accounts from the payment detail controller
guard let data = context as? [String: [BankAcct]], let accts = data["paymentOptions"] else {
NSLog("Error receiving context containing bank accounts in PaymentOptionsInterfaceController")
return
}
bankAccts = accts
configureRows()
}
override func willActivate() {
// This method is called when watch view controller is about to be visible to user
super.willActivate()
}
override func didDeactivate() {
// This method is called when watch view controller is no longer visible
super.didDeactivate()
}
private func configureRows() {
bankAcctTable.setNumberOfRows(bankAccts.count, withRowType: "bankAcctCell")
for index in 0..<bankAcctTable.numberOfRows {
if let row = bankAcctTable.rowController(at: index) as? BankAcctCell {
row.BankNameLabel.setText(bankAccts[index].bankName)
row.Last4Label.setText("(\(bankAccts[index].last4Acct))")
}
}
}
override func table(_ table: WKInterfaceTable, didSelectRowAt rowIndex: Int) {
let acct = bankAccts[rowIndex]
self.dictForDefault.updateValue(String(acct.acctType.rawValue), forKey: "acctType")
self.dictForDefault.updateValue(acct.bankAcctId, forKey: "bankAcctId")
self.dictForDefault.updateValue(acct.bankName, forKey: "bankName")
self.dictForDefault.updateValue(acct.last4Acct, forKey: "last4Acct")
UserDefaults.standard.set(self.dictForDefault, forKey: "default_bank_acct")
pop()
}
}