Skip to content

Swf 10 account details #8

Merged
merged 14 commits into from Mar 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -51,21 +51,120 @@
<controller id="FsK-xr-8Fi">
<items>
<label width="1" alignment="center" text="Credit Wellness" textAlignment="center" id="eqA-XH-rlH"/>
<imageView height="74" alignment="left" id="sOx-i7-XUh"/>
<button width="1" alignment="left" title="Details" id="meA-87-moe">
<connections>
<segue destination="heN-QU-cZt" kind="push" id="lQr-M3-AsC"/>
</connections>
</button>
</items>
</controller>
</objects>
<point key="canvasLocation" x="414" y="258"/>
<point key="canvasLocation" x="414" y="516"/>
</scene>
<!--Interface Controller-->
<scene sceneID="FrP-2H-M8Z">
<objects>
<controller id="heN-QU-cZt">
<items>
<table alignment="left" id="HZU-q7-cqT">
<items>
<tableRow id="kMl-oM-kc4">
<group key="rootItem" width="1" height="44" alignment="left" layout="vertical" id="oDn-1q-Ilf">
<items>
<label alignment="left" text="Label" id="7l8-Yc-iLh"/>
<label width="136" alignment="left" verticalAlignment="center" text="Label" textAlignment="right" id="vwx-Lu-kir"/>
</items>
</group>
</tableRow>
</items>
</table>
</items>
</controller>
</objects>
<point key="canvasLocation" x="755" y="516"/>
</scene>
<!--Account Table Interface Controller-->
<scene sceneID="5Qe-Th-pL8">
<objects>
<controller id="Rpu-25-8st">
<controller hidesWhenLoading="NO" id="Rpu-25-8st" customClass="AccountTableInterfaceController" customModule="SynchronyFinancial_WatchKit_Extension">
<items>
<label width="1" alignment="center" text="Accounts" textAlignment="center" id="JYm-yy-xrH"/>
<table alignment="left" id="To8-Ze-tMX">
<items>
<tableRow identifier="account" id="5xi-FS-LlJ" customClass="AccountCell" customModule="SynchronyFinancial_WatchKit_Extension">
<group key="rootItem" width="1" height="44" alignment="left" layout="vertical" id="mYi-9N-Ue7">
<items>
<label alignment="left" text="Label" id="Tl1-Kc-YJS"/>
</items>
</group>
<connections>
<outlet property="accountName" destination="Tl1-Kc-YJS" id="cgD-CY-lzh"/>
<segue destination="yrN-yp-gkH" kind="modal" identifier="showAccountDetails" id="geu-70-EU1"/>
</connections>
</tableRow>
</items>
</table>
</items>
<connections>
<outlet property="accountTable" destination="To8-Ze-tMX" id="oJb-Ry-7xR"/>
</connections>
</controller>
</objects>
<point key="canvasLocation" x="414" y="-53"/>
</scene>
<!--Account Details Interface Controller-->
<scene sceneID="ozX-Kj-4yZ">
<objects>
<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"/>
<segue destination="Jfd-Hv-PHe" kind="relationship" relationship="nextPage" id="fqW-qd-CCS"/>
</connections>
</controller>
</objects>
<point key="canvasLocation" x="755" y="-53.5"/>
</scene>
<!--Transactions Interface Controller-->
<scene sceneID="yXO-yR-k6b">
<objects>
<controller id="Jfd-Hv-PHe" customClass="TransactionsInterfaceController" customModule="SynchronyFinancial_WatchKit_Extension">
<items>
<table alignment="left" id="OQb-xu-Ynf">
<items>
<tableRow identifier="transactionCell" id="ICl-8S-VHQ" customClass="TransactionCell" customModule="SynchronyFinancial_WatchKit_Extension">
<group key="rootItem" width="1" height="49" alignment="left" layout="vertical" id="GP6-Ec-AVa">
<items>
<label width="1" alignment="left" text="Label" textAlignment="left" id="Hm4-1L-Cyl"/>
<label width="1" alignment="left" text="Label" textAlignment="right" id="Gxn-sX-7gs"/>
</items>
</group>
<connections>
<outlet property="transactionLabel" destination="Hm4-1L-Cyl" id="hYO-F0-S1A"/>
<outlet property="valueLabel" destination="Gxn-sX-7gs" id="COh-0S-dY7"/>
</connections>
</tableRow>
</items>
</table>
</items>
<connections>
<outlet property="transactionsTable" destination="OQb-xu-Ynf" id="eg6-n7-ldT"/>
</connections>
</controller>
</objects>
<point key="canvasLocation" x="414" y="-56"/>
<point key="canvasLocation" x="1086" y="-54"/>
</scene>
</scenes>
</document>
@@ -0,0 +1,14 @@
//
// Account.swift
// SynchronyFinancial WatchKit Extension
//
// Created by Monday on 2019/02/13.
// Copyright © 2019 Alan Maynard. All rights reserved.
//
import Foundation
import WatchKit

class AccountCell: NSObject {
@IBOutlet weak var accountName: WKInterfaceLabel!
}
@@ -0,0 +1,57 @@
//
// AccountDetailsInterfaceController.swift
// SynchronyFinancial WatchKit Extension
//
// Created by Alan Maynard on 3/6/19.
// Copyright © 2019 Alan Maynard. All rights reserved.
//
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)

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() {
// 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 configureForAccount() {
guard selectedAccount != nil, let acct = selectedAccount else {
NSLog("Error configuring AccountDetails. selectedAccount is nil")
return
}

let balanceFormatted = String(format: "%.2f", acct.balance)
let availableFormatted = String(format: "%.2f", acct.limit - acct.balance)
let date = DateFormatter.localizedString(from: acct.paymentDueDate, dateStyle: .medium, timeStyle: .none)

accountNameLabel.setText(acct.accountNumber)
balanceLabel.setText("Balance: $\(balanceFormatted)")
availableFundsLabel.setText("Available: $\(availableFormatted)")
nextPaymentDueLabel.setText(date)
}
}
@@ -0,0 +1,61 @@
//
// 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)

populateDemoData()
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].accountNumber)
}
}
}

private func populateDemoData() {
//swiftlint:disable line_length
accounts.append(Account(accountNumber: "TD Bank", limit: 500.00, transactions: [], paymentDueDate: Date(), cycleEndDate: Date()))
accounts.append(Account(accountNumber: "Care Credit", limit: 10000.00, transactions: [], paymentDueDate: Date(), cycleEndDate: Date()))
accounts.append(Account(accountNumber: "People's Bank", limit: 500.00, transactions: [], paymentDueDate: Date(), cycleEndDate: Date()))
accounts.append(Account(accountNumber: "Bank of America", limit: 10000.00, transactions: [], paymentDueDate: Date(), cycleEndDate: Date()))
}
}
Expand Up @@ -5,10 +5,20 @@
"scale" : "2x",
"screen-width" : "<=145"
},
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : ">161"
},
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : ">145"
},
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : ">183"
}
],
"info" : {
Expand Down
Expand Up @@ -5,10 +5,20 @@
"scale" : "2x",
"screen-width" : "<=145"
},
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : ">161"
},
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : ">145"
},
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : ">183"
}
],
"info" : {
Expand Down
Expand Up @@ -5,10 +5,20 @@
"scale" : "2x",
"screen-width" : "<=145"
},
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : ">161"
},
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : ">145"
},
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : ">183"
}
],
"info" : {
Expand Down
Expand Up @@ -5,10 +5,20 @@
"scale" : "2x",
"screen-width" : "<=145"
},
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : ">161"
},
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : ">145"
},
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : ">183"
}
],
"info" : {
Expand Down
Expand Up @@ -5,10 +5,20 @@
"scale" : "2x",
"screen-width" : "<=145"
},
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : ">161"
},
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : ">145"
},
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : ">183"
}
],
"info" : {
Expand Down
Expand Up @@ -5,10 +5,20 @@
"scale" : "2x",
"screen-width" : "<=145"
},
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : ">161"
},
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : ">145"
},
{
"idiom" : "watch",
"scale" : "2x",
"screen-width" : ">183"
}
],
"info" : {
Expand Down