Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
SWF-12 ui, configuration for account
  • Loading branch information
ahm11003 committed Mar 13, 2019
1 parent e8c3eb3 commit cb640cc
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 16 deletions.
Expand Up @@ -127,7 +127,7 @@
<label width="1" alignment="left" text="Label" textAlignment="center" id="CPc-qk-Z2y"/>
<button width="1" alignment="left" title="Pay Bill" id="zeF-ky-mkm">
<connections>
<segue destination="8l2-lZ-A2A" kind="push" identifier="payBill" id="hkr-dn-mx3"/>
<segue destination="XXR-hJ-s6t" kind="push" identifier="payBill" id="92c-pn-XpQ"/>
</connections>
</button>
</items>
Expand All @@ -142,24 +142,24 @@
<point key="canvasLocation" x="755" y="-53.5"/>
</scene>
<!--Pay Bill Interface Controller-->
<scene sceneID="LZb-Zj-fBw">
<scene sceneID="Kfg-ZO-Pav">
<objects>
<controller id="8l2-lZ-A2A" customClass="PayBillInterfaceController" customModule="SynchronyFinancial">
<controller id="XXR-hJ-s6t" customClass="PayBillInterfaceController" customModule="SynchronyFinancial_WatchKit_App" customModuleProvider="target">
<items>
<label width="1" alignment="left" text="Label" textAlignment="center" id="yO7-4J-X9Y"/>
<button width="1" alignment="left" title="Button" id="Daj-Om-1Kd"/>
<label width="1" alignment="left" text="Label" textAlignment="center" id="6Ge-5p-oR1"/>
<button width="1" alignment="left" title="Button" id="jJU-Ri-dVH"/>
<label width="1" alignment="left" text="Label" textAlignment="center" id="X8I-Ob-Sza"/>
<button width="1" alignment="left" title="Button" id="qp2-zo-E5M"/>
<label width="1" alignment="left" text="Label" textAlignment="center" id="HEu-0X-JkC"/>
<button width="1" alignment="left" title="Button" id="qVO-TJ-fFK"/>
</items>
<connections>
<outlet property="balanceLabel" destination="yO7-4J-X9Y" id="6yH-xz-T1O"/>
<outlet property="minimumLabel" destination="6Ge-5p-oR1" id="fUS-vk-eUE"/>
<outlet property="payBalanceButton" destination="Daj-Om-1Kd" id="mXb-U5-UbA"/>
<outlet property="payMinimumButton" destination="jJU-Ri-dVH" id="St8-en-o4U"/>
<outlet property="balanceLabel" destination="X8I-Ob-Sza" id="AAb-KT-Hx3"/>
<outlet property="minimumLabel" destination="HEu-0X-JkC" id="9eE-J7-qNL"/>
<outlet property="payBalanceButton" destination="qp2-zo-E5M" id="5oo-dC-qbj"/>
<outlet property="payMinimumButton" destination="qVO-TJ-fFK" id="ycd-dO-8jr"/>
</connections>
</controller>
</objects>
<point key="canvasLocation" x="1105" y="-53"/>
<point key="canvasLocation" x="1084" y="-52"/>
</scene>
</scenes>
</document>
Expand Up @@ -11,6 +11,7 @@ import Foundation

class AccountDetailsInterfaceController: WKInterfaceController {
var selectedAccount: Account?
var dictForAcct: [String: Account] = [:]

@IBOutlet weak var balanceLabel: WKInterfaceLabel!
@IBOutlet weak var availableFundsLabel: WKInterfaceLabel!
Expand Down Expand Up @@ -41,9 +42,12 @@ class AccountDetailsInterfaceController: WKInterfaceController {

override func contextForSegue(withIdentifier segueIdentifier: String) -> Any? {
if segueIdentifier == "payBill" {
print("button was tapped")
if let acct = selectedAccount {
dictForAcct.updateValue(acct, forKey: "acct")
return dictForAcct
}
}

return nil
}

Expand Down
Expand Up @@ -9,8 +9,8 @@
import WatchKit
import Foundation


class PayBillInterfaceController: WKInterfaceController {
var acct: Account?

@IBOutlet weak var balanceLabel: WKInterfaceLabel!
@IBOutlet weak var payBalanceButton: WKInterfaceButton!
Expand All @@ -19,8 +19,15 @@ class PayBillInterfaceController: WKInterfaceController {

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
}

acct = data["acct"]
configure()
}

override func willActivate() {
Expand All @@ -33,4 +40,15 @@ class PayBillInterfaceController: WKInterfaceController {
super.didDeactivate()
}

private func configure() {
if let valid = acct {
let balanceFormatted = String(format: "%.2f", valid.balance)
balanceLabel.setText("Balance: \(balanceFormatted)")
payBalanceButton.setTitle("Pay \(balanceFormatted)")

let minimumFormatted = String(format: "%.2f", valid.minimumPayment)
minimumLabel.setText("Minimum Payment: \(minimumFormatted)")
payMinimumButton.setTitle("Pay \(minimumFormatted)")
}
}
}
2 changes: 2 additions & 0 deletions SynchronyFinancial/SynchronyFinancial/Account.swift
Expand Up @@ -14,6 +14,7 @@ class Account: NSObject {
var transactions: [Transaction]
var paymentDueDate: Date
var cycleEndDate: Date
var minimumPayment: Double

init(accountNumber: String, limit: Double, transactions: [Transaction], paymentDueDate: Date, cycleEndDate: Date) {
self.accountNumber = accountNumber
Expand All @@ -22,5 +23,6 @@ class Account: NSObject {
self.balance = transactions.map { $0.amount }.reduce(0.0, +)
self.paymentDueDate = paymentDueDate
self.cycleEndDate = cycleEndDate
self.minimumPayment = 25.00
}
}

0 comments on commit cb640cc

Please sign in to comment.