Permalink
Cannot retrieve contributors at this time
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?
SynchronyFinancialWatchApp/SynchronyFinancial/SynchronyFinancial WatchKit Extension/PaymentOptionsInterfaceController.swift
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
52 lines (45 sloc)
1.77 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// 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() | |
} | |
} |