From 3a44e1180de030148153b58c8b192949a1b82b01 Mon Sep 17 00:00:00 2001 From: Alan Maynard Date: Wed, 6 Mar 2019 19:48:25 -0500 Subject: [PATCH] SWF-10 Resolve swiftlint warnings, configure table for accounts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - created function to populate with “dummy” accounts - created function to configure each row in table - implemented `contextForSegue` function to allow us to “pass” the selected account to the next interface controller --- .../AccountDetailsInterfaceController.swift | 1 - .../AccountTableInterfaceController.swift | 40 ++++++++++++++++--- 2 files changed, 35 insertions(+), 6 deletions(-) diff --git a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/AccountDetailsInterfaceController.swift b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/AccountDetailsInterfaceController.swift index 6af904b..1a51ac6 100644 --- a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/AccountDetailsInterfaceController.swift +++ b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/AccountDetailsInterfaceController.swift @@ -9,7 +9,6 @@ import WatchKit import Foundation - class AccountDetailsInterfaceController: WKInterfaceController { override func awake(withContext context: Any?) { diff --git a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/AccountTableInterfaceController.swift b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/AccountTableInterfaceController.swift index a30fa7b..563adab 100644 --- a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/AccountTableInterfaceController.swift +++ b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/AccountTableInterfaceController.swift @@ -9,17 +9,18 @@ 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) - accountTable.setNumberOfRows(5, withRowType: "account") - // Configure interface objects here. + + populateDemoDate() + configureRows() } - - + override func willActivate() { // This method is called when watch view controller is about to be visible to user super.willActivate() @@ -30,4 +31,33 @@ class AccountTableInterfaceController: WKInterfaceController { super.didDeactivate() } + override func table(_ table: WKInterfaceTable, didSelectRowAt rowIndex: Int) { + acctDict["acct"] = accounts[rowIndex] + } + + override func contextForSegue(withIdentifier segueIdentifier: String) -> Any? { + if segueIdentifier == "showAccountDetails" { + return acctDict + } + + return nil + } + + private func configureRows() { + accountTable.setNumberOfRows(accounts.count, withRowType: "account") + + for index in 0..