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/AccountTableInterfaceController.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 (43 sloc)
1.7 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
// | |
// 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] = [:] | |
@IBOutlet weak var accountTable: WKInterfaceTable! | |
override func awake(withContext context: Any?) { | |
super.awake(withContext: context) | |
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 contextsForSegue(withIdentifier segueIdentifier: String, in table: WKInterfaceTable, rowIndex: Int) -> [Any]? { | |
if segueIdentifier == "showAccountDetails" { | |
// account data is passed to the first interface controller in our new navigation stack | |
// if we want to pass to subsequent interface controllers, we would add them in corresponding order | |
acctDict.updateValue(accounts[rowIndex], forKey: "acct") | |
return [acctDict] | |
} | |
return nil | |
} | |
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) | |
} | |
} | |
} | |
} |