Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
SWF-10 Account Details set up
- change how we get the account before it is passed to account details
- wrote methods to set up account details screen with the account object that is received
  • Loading branch information
ahm11003 committed Mar 7, 2019
1 parent 3a44e11 commit 472f648
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 11 deletions.
Expand Up @@ -100,7 +100,7 @@
</group>
<connections>
<outlet property="accountName" destination="Tl1-Kc-YJS" id="cgD-CY-lzh"/>
<segue destination="yrN-yp-gkH" kind="push" identifier="showAccountDetails" id="aX6-ip-bPv"/>
<segue destination="yrN-yp-gkH" kind="push" identifier="showAccountDetails" id="geu-70-EU1"/>
</connections>
</tableRow>
</items>
Expand All @@ -116,9 +116,25 @@
<!--Account Details Interface Controller-->
<scene sceneID="ozX-Kj-4yZ">
<objects>
<controller id="yrN-yp-gkH" customClass="AccountDetailsInterfaceController" customModule="SynchronyFinancial_WatchKit_Extension"/>
<controller id="yrN-yp-gkH" customClass="AccountDetailsInterfaceController" customModule="SynchronyFinancial_WatchKit_Extension">
<items>
<label width="1" alignment="left" text="Label" textAlignment="center" id="qzl-GE-bpZ">
<fontDescription key="font" style="UICTFontTextStyleHeadline"/>
</label>
<label width="1" alignment="left" text="Label" textAlignment="center" id="mdb-QX-GuO"/>
<label width="1" alignment="left" text="Label" textAlignment="center" id="q0b-tb-dAb"/>
<label width="1" alignment="left" text="Next Payment Due:" textAlignment="center" id="rxs-Zb-naU"/>
<label width="1" alignment="left" text="Label" textAlignment="center" id="CPc-qk-Z2y"/>
</items>
<connections>
<outlet property="accountNameLabel" destination="qzl-GE-bpZ" id="6jA-KZ-quX"/>
<outlet property="availableFundsLabel" destination="q0b-tb-dAb" id="rcl-Tl-bDh"/>
<outlet property="balanceLabel" destination="mdb-QX-GuO" id="2Dj-nO-AM8"/>
<outlet property="nextPaymentDueLabel" destination="CPc-qk-Z2y" id="AzY-pn-EMY"/>
</connections>
</controller>
</objects>
<point key="canvasLocation" x="755" y="-53"/>
<point key="canvasLocation" x="755" y="-53.5"/>
</scene>
</scenes>
</document>
Expand Up @@ -10,11 +10,23 @@ import WatchKit
import Foundation

class AccountDetailsInterfaceController: WKInterfaceController {
var selectedAccount: Account?

@IBOutlet weak var balanceLabel: WKInterfaceLabel!
@IBOutlet weak var availableFundsLabel: WKInterfaceLabel!
@IBOutlet weak var accountNameLabel: WKInterfaceLabel!
@IBOutlet weak var nextPaymentDueLabel: WKInterfaceLabel!

override func awake(withContext context: Any?) {
super.awake(withContext: context)

// Configure interface objects here.

guard let data = context as? [String: Account] else {
NSLog("Error receiving context containing selected account in AccountDetailInterfaceController")
return
}

selectedAccount = data["acct"]
configureForAccount()
}

override func willActivate() {
Expand All @@ -27,4 +39,16 @@ class AccountDetailsInterfaceController: WKInterfaceController {
super.didDeactivate()
}

private func configureForAccount() {
guard selectedAccount != nil, let acct = selectedAccount else {
NSLog("Error configuring AccountDetails. selectedAccount is nil")
return
}

accountNameLabel.setText(acct.accountNumber)
balanceLabel.setText("Balance: $\(acct.balance)")
availableFundsLabel.setText("Available: $\(acct.limit - acct.balance)")
let date = DateFormatter.localizedString(from: acct.paymentDueDate, dateStyle: .medium, timeStyle: .none)
nextPaymentDueLabel.setText(date)
}
}
Expand Up @@ -31,15 +31,11 @@ class AccountTableInterfaceController: WKInterfaceController {
super.didDeactivate()
}

override func table(_ table: WKInterfaceTable, didSelectRowAt rowIndex: Int) {
acctDict["acct"] = accounts[rowIndex]
}

override func contextForSegue(withIdentifier segueIdentifier: String) -> Any? {
override func contextForSegue(withIdentifier segueIdentifier: String, in table: WKInterfaceTable, rowIndex: Int) -> Any? {
if segueIdentifier == "showAccountDetails" {
acctDict.updateValue(accounts[rowIndex], forKey: "acct")
return acctDict
}

return nil
}

Expand Down

0 comments on commit 472f648

Please sign in to comment.