-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10 from rrk12005/SWF-12-make-payment-ui
Swf 12 make payment ui
- Loading branch information
Showing
7 changed files
with
257 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
SynchronyFinancial/SynchronyFinancial WatchKit Extension/PayBillInterfaceController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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)") | ||
} | ||
} | ||
} |
57 changes: 57 additions & 0 deletions
57
...onyFinancial/SynchronyFinancial WatchKit Extension/PaymentDetailInterfaceController.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
} | ||
} |
Oops, something went wrong.