Skip to content

Swf 12 make payment ui #10

Merged
merged 7 commits into from Mar 29, 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
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="14460.31" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="Qge-pO-HLc">
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="14490.70" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="Qge-pO-HLc">
<device id="watch38" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="watchOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="14460.16"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="14490.21"/>
</dependencies>
<scenes>
<!--Main Menu Interface Controller-->
Expand Down Expand Up @@ -100,7 +100,6 @@
</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>
Expand All @@ -113,10 +112,10 @@
</objects>
<point key="canvasLocation" x="414" y="-53"/>
</scene>
<!--Account Details Interface Controller-->
<!--AccountDetails-->
<scene sceneID="ozX-Kj-4yZ">
<objects>
<controller id="yrN-yp-gkH" customClass="AccountDetailsInterfaceController" customModule="SynchronyFinancial_WatchKit_Extension">
<controller identifier="AccountDetails" 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"/>
Expand All @@ -125,22 +124,100 @@
<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"/>
<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>
<point key="canvasLocation" x="755" y="-231"/>
</scene>
<!--PayMinimum-->
<scene sceneID="Kfg-ZO-Pav">
<objects>
<controller identifier="PayMinimum" id="XXR-hJ-s6t" customClass="PayBillInterfaceController" customModule="SynchronyFinancial_WatchKit_App" customModuleProvider="target">
<items>
<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="PayAll" id="AFS-lo-piH"/>
</connections>
</button>
<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="PayMinimum" id="kTV-Eb-cpT"/>
</connections>
</button>
</items>
<connections>
<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="755" y="186"/>
</scene>
<!--Payment Detail Interface Controller-->
<scene sceneID="vQy-l8-oEp">
<objects>
<controller id="t8d-XB-ngB" customClass="PaymentDetailInterfaceController" customModule="SynchronyFinancial_WatchKit_App" customModuleProvider="target">
<items>
<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="paymentAction" destination="t8d-XB-ngB" id="Zjv-zI-wCI"/>
</connections>
</button>
</items>
<connections>
<outlet property="amount" destination="mT0-3D-JGP" id="rff-wG-B82"/>
<outlet property="detailButton" destination="SZD-0B-PrF" id="xEw-gE-yIP"/>
<outlet property="paymentButton" destination="FgU-iZ-2XU" id="yZe-dZ-nBV"/>
</connections>
</controller>
</objects>
<point key="canvasLocation" x="755" y="-53.5"/>
<point key="canvasLocation" x="1085" y="186"/>
</scene>
<!--Transactions Interface Controller-->
<!--Transactions-->
<scene sceneID="yXO-yR-k6b">
<objects>
<controller id="Jfd-Hv-PHe" customClass="TransactionsInterfaceController" customModule="SynchronyFinancial_WatchKit_Extension">
<controller identifier="Transactions" id="Jfd-Hv-PHe" customClass="TransactionsInterfaceController" customModule="SynchronyFinancial_WatchKit_Extension">
<items>
<table alignment="left" id="OQb-xu-Ynf">
<items>
Expand All @@ -164,7 +241,10 @@
</connections>
</controller>
</objects>
<point key="canvasLocation" x="1086" y="-54"/>
<point key="canvasLocation" x="1085" y="-229"/>
</scene>
</scenes>
<inferredMetricsTieBreakers>
<segue reference="AFS-lo-piH"/>
</inferredMetricsTieBreakers>
</document>
Expand Up @@ -11,15 +11,26 @@ import Foundation

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 All @@ -39,6 +50,17 @@ class AccountDetailsInterfaceController: WKInterfaceController {
super.didDeactivate()
}

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

return nil
}

private func configureForAccount() {
guard selectedAccount != nil, let acct = selectedAccount else {
NSLog("Error configuring AccountDetails. selectedAccount is nil")
Expand Down
Expand Up @@ -12,6 +12,7 @@ import Foundation
class AccountTableInterfaceController: WKInterfaceController {
var accounts: [Account] = []
var acctDict: [String: Account] = [:]
var transactionDict: [String: [Transaction]] = [:]

@IBOutlet weak var accountTable: WKInterfaceTable!
override func awake(withContext context: Any?) {
Expand Down Expand Up @@ -41,6 +42,12 @@ class AccountTableInterfaceController: WKInterfaceController {
return nil
}

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

private func configureRows() {
accountTable.setNumberOfRows(accounts.count, withRowType: "account")

Expand Down
@@ -0,0 +1,65 @@
//
// PayBillInterfaceController.swift
// SynchronyFinancial
//
// Created by Alan Maynard on 3/13/19.
// Copyright © 2019 Alan Maynard. All rights reserved.
//

import WatchKit
import Foundation

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

@IBOutlet weak var balanceLabel: WKInterfaceLabel!
@IBOutlet weak var payBalanceButton: WKInterfaceButton!
@IBOutlet weak var minimumLabel: WKInterfaceLabel!
@IBOutlet weak var payMinimumButton: WKInterfaceButton!

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() {
// 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 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 {
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)
minimumLabel.setText("Minimum Payment: \(minimumFormatted)")
payMinimumButton.setTitle("Pay \(minimumFormatted)")
}
}
}
@@ -0,0 +1,57 @@
//
// PaymentDetailInterfaceController.swift
// SynchronyFinancial
//
// Created by Monday on 2019/03/24.
// Copyright © 2019 Alan Maynard. All rights reserved.
//

import WatchKit
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
}

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

@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")
}
}

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()
}
}