Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
SynchronyFinancialWatchApp/SynchronyFinancial/SynchronyFinancial WatchKit Extension/PaymentDetailInterfaceController.swift
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
99 lines (85 sloc)
3.47 KB
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
// | |
// 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 | |
var dictForBankAcct: [String:[BankAcct]] = [:] | |
@IBOutlet var activityIndicator: WKInterfaceImage! | |
@IBOutlet weak var detailButton: WKInterfaceButton! | |
@IBOutlet weak var amount: WKInterfaceLabel! | |
@IBOutlet weak var paymentButton: WKInterfaceButton! | |
@IBOutlet weak var payFrom: WKInterfaceLabel! | |
@IBOutlet weak var separate: WKInterfaceSeparator! | |
override func awake(withContext context: Any?) { | |
configureInterfaceObjects(true) | |
activityIndicator.configureForActivityIndicator() | |
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 | |
} | |
FetchData.getBankInfo{ accts, error in guard error == nil else { | |
NSLog("Error retrieving payment methods for account in paymentDetailInterfaceController.") | |
return | |
} | |
self.dictForBankAcct.updateValue(accts, forKey: "paymentOptions") | |
self.configureInterfaceObjects(false) | |
//self.detailButton.setTitle("Hello") | |
self.activityIndicator.stopAnimatingAsIndicator() | |
} | |
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") | |
} | |
} | |
@IBAction func bankAccountsTapped() { | |
self.pushController(withName: "PaymentOptions", context: self.dictForBankAcct) | |
} | |
override func willActivate() { | |
// This method is called when watch view controller is about to be visible to user | |
super.willActivate() | |
if let bankacct = UserDefaults.standard.string(forKey: "default_bank_acct"){ | |
detailButton.setTitle(bankacct) | |
} | |
print("hots here") | |
} | |
override func didDeactivate() { | |
// This method is called when watch view controller is no longer visible | |
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) | |
} | |
}*/ | |
} | |
} |