Permalink
Cannot retrieve contributors at this time
SynchronyFinancialWatchApp/SynchronyFinancial/SynchronyFinancial WatchKit Extension/AccountTableInterfaceController.swift
Go to file// | |
// AccountTableInterfaceController.swift | |
// SynchronyFinancial WatchKit Extension | |
// | |
// Created by Monday on 2019/02/13. | |
// Copyright © 2019 Alan Maynard. All rights reserved. | |
// | |
import WatchKit | |
import Foundation | |
class AccountTableInterfaceController: WKInterfaceController { | |
var accounts: [Account] = [] | |
var acctDict: [String: Account] = [:] | |
var transactionDict: [String: [Transaction]] = [:] | |
@IBOutlet var titleLabel: WKInterfaceLabel! | |
@IBOutlet weak var accountTable: WKInterfaceTable! | |
override func awake(withContext context: Any?) { | |
super.awake(withContext: context) | |
if let context = context as? [String: [Account]], let accts = context["accts"] { | |
accounts = 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() | |
} | |
override func table(_ table: WKInterfaceTable, didSelectRowAt rowIndex: Int) { | |
acctDict.updateValue(accounts[rowIndex], forKey: "acct") | |
pushController(withName: "AccountDetails", context: acctDict) | |
} | |
private func configureRows() { | |
accountTable.setNumberOfRows(accounts.count, withRowType: "account") | |
for index in 0..<accountTable.numberOfRows { | |
if let row = accountTable.rowController(at: index) as? AccountCell { | |
row.accountName.setText(accounts[index].accountName) | |
row.last4Label.setText("(...\(accounts[index].last4))") | |
} | |
} | |
} | |
} |