Skip to content

Commit

Permalink
SWF-12 changes to support payment suite
Browse files Browse the repository at this point in the history
- had to abandon page based navigation in favor of being able to use push segues throughout payment suite
- put a button in place to allow viewing transactions
- implemented data passing through payment suite and button functionality to simulate authorizing payment
  • Loading branch information
ahm11003 committed Mar 28, 2019
1 parent b8d1b81 commit b75f5ca
Show file tree
Hide file tree
Showing 5 changed files with 86 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,18 +124,29 @@
<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"/>
<button width="1" alignment="left" title="Pay Bill" id="zeF-ky-mkm">
<connections>
<segue destination="XXR-hJ-s6t" kind="push" identifier="payBill" id="92c-pn-XpQ"/>
</connections>
</button>
<group width="1" alignment="left" id="ohQ-In-SGt">
<items>
<button width="67" alignment="left" title="Pay" id="zeF-ky-mkm">
<connections>
<action selector="payBillTapped" destination="yrN-yp-gkH" id="iQy-Ty-omn"/>
<segue destination="XXR-hJ-s6t" kind="push" identifier="payBill" id="jGh-Ix-ean"/>
</connections>
</button>
<button width="64" alignment="right" title="Recent" id="0HI-HK-yDl">
<connections>
<segue destination="Jfd-Hv-PHe" kind="push" identifier="showTransactions" id="bjb-v1-scE"/>
</connections>
</button>
</items>
</group>
</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"/>
<outlet property="payButton" destination="zeF-ky-mkm" id="v5U-Y5-shh"/>
<outlet property="transactionsButton" destination="0HI-HK-yDl" id="L5Z-M9-wgO"/>
</connections>
</controller>
</objects>
Expand All @@ -146,16 +157,20 @@
<objects>
<controller identifier="PayMinimum" id="XXR-hJ-s6t" customClass="PayBillInterfaceController" customModule="SynchronyFinancial_WatchKit_App" customModuleProvider="target">
<items>
<label width="1" alignment="left" text="Label" textAlignment="center" id="X8I-Ob-Sza"/>
<label width="1" alignment="center" text="Label" textAlignment="center" id="X8I-Ob-Sza"/>
<button width="1" alignment="left" title="Button" id="qp2-zo-E5M">
<color key="titleColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="backgroundColor" red="0.15993532539999999" green="0.67110615969999998" blue="0.88774442669999998" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<connections>
<segue destination="t8d-XB-ngB" kind="push" identifier="PayMinimum" id="AFS-lo-piH"/>
<segue destination="t8d-XB-ngB" kind="push" identifier="PayAll" id="AFS-lo-piH"/>
</connections>
</button>
<label width="1" alignment="left" text="Label" textAlignment="center" id="HEu-0X-JkC"/>
<button width="1" alignment="left" title="Button" id="qVO-TJ-fFK">
<label width="1" height="38" alignment="center" text="Label" textAlignment="center" numberOfLines="2" id="HEu-0X-JkC"/>
<button width="1" alignment="center" title="Button" id="qVO-TJ-fFK">
<color key="titleColor" white="0.0" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<color key="backgroundColor" red="0.99121409650000003" green="0.90791553260000002" blue="0.3312966228" alpha="1" colorSpace="deviceRGB"/>
<connections>
<segue destination="t8d-XB-ngB" kind="push" identifier="PayAll" id="kTV-Eb-cpT"/>
<segue destination="t8d-XB-ngB" kind="push" identifier="PayMinimum" id="kTV-Eb-cpT"/>
</connections>
</button>
</items>
Expand All @@ -172,13 +187,21 @@
<!--Payment Detail Interface Controller-->
<scene sceneID="vQy-l8-oEp">
<objects>
<controller id="t8d-XB-ngB" customClass="PaymentDetailInterfaceController" customModule="SynchronyFinancial">
<controller id="t8d-XB-ngB" customClass="PaymentDetailInterfaceController" customModule="SynchronyFinancial_WatchKit_App" customModuleProvider="target">
<items>
<button width="1" height="65" alignment="left" title="Button" id="SZD-0B-PrF" userLabel="detailButton"/>
<label width="136" alignment="left" text="Label" textAlignment="center" id="mT0-3D-JGP"/>
<button width="1" height="49" alignment="left" title="Button" id="FgU-iZ-2XU" userLabel="paymentButton">
<label width="1" alignment="center" text="Pay From:" textAlignment="center" id="xE5-Zl-U7d"/>
<button width="1" height="40" alignment="left" title="Synchrony (1234)" id="SZD-0B-PrF" userLabel="detailButton">
<fontDescription key="font" type="system" pointSize="15"/>
</button>
<separator alignment="left" verticalAlignment="center" id="et0-Sq-Qxm">
<color key="color" white="0.66666666669999997" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</separator>
<label width="1" alignment="center" verticalAlignment="bottom" text="Confirm Payment" textAlignment="center" id="mT0-3D-JGP"/>
<button width="1" height="49" alignment="left" verticalAlignment="bottom" title="Button" id="FgU-iZ-2XU" userLabel="paymentButton">
<color key="titleColor" name="labelColor" catalog="System" colorSpace="catalog"/>
<color key="backgroundColor" red="0.16078431369999999" green="0.6705882353" blue="0.8862745098" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<connections>
<action selector="PaymentButton" destination="t8d-XB-ngB" id="vE0-OJ-F5S"/>
<action selector="paymentAction" destination="t8d-XB-ngB" id="Zjv-zI-wCI"/>
</connections>
</button>
</items>
Expand Down Expand Up @@ -222,6 +245,6 @@
</scene>
</scenes>
<inferredMetricsTieBreakers>
<segue reference="kTV-Eb-cpT"/>
<segue reference="AFS-lo-piH"/>
</inferredMetricsTieBreakers>
</document>
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,24 @@ class AccountDetailsInterfaceController: WKInterfaceController {
var selectedAccount: Account?
var dictForAcct: [String: Account] = [:]

@IBOutlet weak var transactionsButton: WKInterfaceButton!
@IBOutlet weak var payButton: WKInterfaceButton!
@IBOutlet weak var balanceLabel: WKInterfaceLabel!
@IBOutlet weak var availableFundsLabel: WKInterfaceLabel!
@IBOutlet weak var accountNameLabel: WKInterfaceLabel!
@IBOutlet weak var nextPaymentDueLabel: WKInterfaceLabel!

@IBAction func payBillTapped() {
if let acct = selectedAccount {
dictForAcct.updateValue(acct, forKey: "acct")
}
pushController(withName: "PayMinimum", context: dictForAcct)
}

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

payButton.setWidth(self.contentFrame.width / 2)
transactionsButton.setWidth(self.contentFrame.width / 2)
guard let data = context as? [String: Account] else {
NSLog("Error receiving context containing selected account in AccountDetailInterfaceController")
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class AccountTableInterfaceController: WKInterfaceController {

override func table(_ table: WKInterfaceTable, didSelectRowAt rowIndex: Int) {
acctDict.updateValue(accounts[rowIndex], forKey: "acct")
self.presentController(withNames: ["AccountDetails", "Transactions"], contexts: [self.acctDict, self.transactionDict])
self.pushController(withName: "AccountDetails", context: self.acctDict)
// self.presentController(withNames: ["AccountDetails", "Transactions"], contexts: [self.acctDict, self.transactionDict])
}

private func configureRows() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import Foundation

class PayBillInterfaceController: WKInterfaceController {
var acct: Account?
var payDict: [String: Any] = [:]

@IBOutlet weak var balanceLabel: WKInterfaceLabel!
@IBOutlet weak var payBalanceButton: WKInterfaceButton!
Expand Down Expand Up @@ -40,13 +41,23 @@ class PayBillInterfaceController: WKInterfaceController {
super.didDeactivate()
}

override func contextForSegue(withIdentifier segueIdentifier: String) -> Any? {
if segueIdentifier == "PayMinimum" {
payDict.updateValue(Double(acct?.minimumPayment ?? 0.0), forKey: "payment_amount")
} else if segueIdentifier == "PayAll" {
payDict.updateValue(Double(acct?.balance ?? 0.0), forKey: "payment_amount")
}
return payDict
}

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

let minimumFormatted = String(format: "%.2f", valid.minimumPayment)
let minimumFormatted = String(format: "$%.2f", valid.minimumPayment)
minimumLabel.setText("Minimum Payment: \(minimumFormatted)")
payMinimumButton.setTitle("Pay \(minimumFormatted)")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,37 @@ import Foundation
class PaymentDetailInterfaceController: WKInterfaceController {
var selectedAccount: Account?
var dictForAcct: [String: Account] = [:]
var paymentButtonArmed: Bool = false
var paymentAmount: Double = 0.0

@IBOutlet weak var detailButton: WKInterfaceButton!
@IBOutlet weak var amount: WKInterfaceLabel!
@IBOutlet weak var paymentButton: WKInterfaceButton!

override func awake(withContext context: Any?) {
super.awake(withContext: context)
guard let data = context as? [String: Any], let acct = data["acct"] as? Account, let amount = data["payment_amount"] as? Double else {
NSLog("Error getting account object and payment amount")
return
}

// Configure interface objects here.
self.paymentAmount = amount
self.selectedAccount = acct
paymentButton.setTitle(String(format: "Pay $%.2f", amount))
}

override func contextForSegue(withIdentifier segueIdentifier: String) -> Any? {
if segueIdentifier == "PayAll" || segueIdentifier == "PayMinimum" {
if let acct = selectedAccount {
dictForAcct.updateValue(acct, forKey: "acct")
return dictForAcct
}
@IBAction func paymentAction() {
if paymentButtonArmed {
popToRootController()
} else {
// animate(withDuration: 0.75) {
// self.paymentButton.setBackgroundColor(UIColor.init(red: 141, green: 241, blue: 48, alpha: 1.0))
// }

paymentButton.setBackgroundColor(#colorLiteral(red: 0.6092301607, green: 0.9366738796, blue: 0.2432599962, alpha: 1))
paymentButtonArmed = true
paymentButton.setTitle("Pay Now")
}
return nil
}

override func willActivate() {
Expand All @@ -42,11 +54,4 @@ class PaymentDetailInterfaceController: WKInterfaceController {
// This method is called when watch view controller is no longer visible
super.didDeactivate()
}
private func configure() {
//if acct {
detailButton.setTitle("Payment: Bank Of America")
amount.setText("")
paymentButton.setTitle("Pay now!")
//}
}
}

0 comments on commit b75f5ca

Please sign in to comment.