Skip to content
Permalink
0b6fb6702a
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
52 lines (45 sloc) 1.77 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] = []
override func awake(withContext context: Any?) {
super.awake(withContext: context)
guard let data = context as? [String: [BankAcct]], let accts = data["paymentOptions"] else {
NSLog("Error receiving context containing bank accounts in PaymentOptionsInterfaceController")
return
}
bankAccts = accts
print(bankAccts.count)
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]
UserDefaults.standard.set(acct.bankName, forKey: "default_bank_acct")
pop()
}
}