Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
SWF-13 able to choose bank that user would like to pay for. No passin…
…g of account info, just able to display chosen bank name
  • Loading branch information
rrk12005 committed Apr 6, 2019
1 parent 18c29c8 commit 0b6fb67
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 10 deletions.
Expand Up @@ -201,6 +201,7 @@
<objects> <objects>
<controller id="t8d-XB-ngB" customClass="PaymentDetailInterfaceController" customModule="SynchronyFinancial_WatchKit_App" customModuleProvider="target"> <controller id="t8d-XB-ngB" customClass="PaymentDetailInterfaceController" customModule="SynchronyFinancial_WatchKit_App" customModuleProvider="target">
<items> <items>
<imageView alignment="left" hidden="YES" id="fzG-LV-j7G"/>
<label width="1" alignment="center" text="Pay From:" textAlignment="center" id="xE5-Zl-U7d"/> <label width="1" alignment="center" text="Pay From:" textAlignment="center" id="xE5-Zl-U7d"/>
<button width="1" height="40" alignment="left" title="Select Bank" id="SZD-0B-PrF" userLabel="detailButton"> <button width="1" height="40" alignment="left" title="Select Bank" id="SZD-0B-PrF" userLabel="detailButton">
<fontDescription key="font" type="system" pointSize="15"/> <fontDescription key="font" type="system" pointSize="15"/>
Expand All @@ -221,9 +222,12 @@
</button> </button>
</items> </items>
<connections> <connections>
<outlet property="activityIndicator" destination="fzG-LV-j7G" id="zqA-Vd-Kjv"/>
<outlet property="amount" destination="mT0-3D-JGP" id="rff-wG-B82"/> <outlet property="amount" destination="mT0-3D-JGP" id="rff-wG-B82"/>
<outlet property="detailButton" destination="SZD-0B-PrF" id="xEw-gE-yIP"/> <outlet property="detailButton" destination="SZD-0B-PrF" id="xEw-gE-yIP"/>
<outlet property="payFrom" destination="xE5-Zl-U7d" id="62t-6n-KSD"/>
<outlet property="paymentButton" destination="FgU-iZ-2XU" id="yZe-dZ-nBV"/> <outlet property="paymentButton" destination="FgU-iZ-2XU" id="yZe-dZ-nBV"/>
<outlet property="separate" destination="et0-Sq-Qxm" id="JfK-S7-H9d"/>
</connections> </connections>
</controller> </controller>
</objects> </objects>
Expand Down
Expand Up @@ -16,33 +16,36 @@ class PaymentDetailInterfaceController: WKInterfaceController {
var paymentButtonArmed: Bool = false var paymentButtonArmed: Bool = false
var paymentAmount: Double = 0.0 var paymentAmount: Double = 0.0
var dictForBankAcct: [String:[BankAcct]] = [:] var dictForBankAcct: [String:[BankAcct]] = [:]

@IBOutlet var activityIndicator: WKInterfaceImage!
@IBOutlet weak var detailButton: WKInterfaceButton! @IBOutlet weak var detailButton: WKInterfaceButton!
@IBOutlet weak var amount: WKInterfaceLabel! @IBOutlet weak var amount: WKInterfaceLabel!
@IBOutlet weak var paymentButton: WKInterfaceButton! @IBOutlet weak var paymentButton: WKInterfaceButton!
@IBOutlet weak var payFrom: WKInterfaceLabel!
@IBOutlet weak var separate: WKInterfaceSeparator!


override func awake(withContext context: Any?) { override func awake(withContext context: Any?) {
configureInterfaceObjects(true)
activityIndicator.configureForActivityIndicator()
super.awake(withContext: context) 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 { 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") NSLog("Error getting account object and payment amount")
return return
} }

FetchData.getBankInfo{ accts, error in guard error == nil else { FetchData.getBankInfo{ accts, error in guard error == nil else {
NSLog("Error retrieving payment methods for account in paymentDetailInterfaceController.") NSLog("Error retrieving payment methods for account in paymentDetailInterfaceController.")
return return
} }

self.dictForBankAcct.updateValue(accts, forKey: "paymentOptions") self.dictForBankAcct.updateValue(accts, forKey: "paymentOptions")

self.configureInterfaceObjects(false)
//self.detailButton.setTitle("Hello")
self.activityIndicator.stopAnimatingAsIndicator()
} }
self.paymentAmount = amount self.paymentAmount = amount
self.selectedAccount = acct self.selectedAccount = acct
paymentButton.setTitle(String(format: "Pay $%.2f", amount)) paymentButton.setTitle(String(format: "Pay $%.2f", amount))
if let p1 = self.dictForBankAcct["paymentOptions"] {
UserDefaults.standard.set(p1[0], forKey: "default_bank_acct")
print("yes")
self.detailButton.setTitle(p1[0].bankName)
}
} }


@IBAction func paymentAction() { @IBAction func paymentAction() {
Expand All @@ -66,14 +69,31 @@ class PaymentDetailInterfaceController: WKInterfaceController {
override func willActivate() { override func willActivate() {
// This method is called when watch view controller is about to be visible to user // This method is called when watch view controller is about to be visible to user
super.willActivate() super.willActivate()
if let bankacct = UserDefaults.standard.value(forKey: "default_bank_acct") as? BankAcct { if let bankacct = UserDefaults.standard.string(forKey: "default_bank_acct"){
detailButton.setTitle(bankacct.bankName) detailButton.setTitle(bankacct)
} }
print("hots here")
} }


override func didDeactivate() { override func didDeactivate() {
// This method is called when watch view controller is no longer visible // This method is called when watch view controller is no longer visible
super.didDeactivate() super.didDeactivate()
} }


private func configureInterfaceObjects(_ hide: Bool) {
detailButton.setHidden(hide)
amount.setHidden(hide)
paymentButton.setHidden(hide)
payFrom.setHidden(hide)
separate.setHidden(hide)
/*if(!hide){
if let p1 = self.dictForBankAcct["paymentOptions"] {
let x = p1[0]
UserDefaults.standard.set(x, forKey: "default_bank_acct")
print("yes")
detailButton.setTitle(p1[0].bankName)
}
}*/
}

} }
Expand Up @@ -24,6 +24,7 @@ class PaymentOptionsInterfaceController: WKInterfaceController {
bankAccts = accts bankAccts = accts
print(bankAccts.count) print(bankAccts.count)
configureRows() configureRows()

} }
override func willActivate() { override func willActivate() {
// This method is called when watch view controller is about to be visible to user // This method is called when watch view controller is about to be visible to user
Expand All @@ -42,4 +43,10 @@ class PaymentOptionsInterfaceController: WKInterfaceController {
} }
} }
} }

override func table(_ table: WKInterfaceTable, didSelectRowAt rowIndex: Int) {
let acct = bankAccts[rowIndex]
UserDefaults.standard.set(acct.bankName, forKey: "default_bank_acct")
pop()
}
} }

0 comments on commit 0b6fb67

Please sign in to comment.