diff --git a/SynchronyFinancial/SynchronyFinancial WatchKit App/Base.lproj/Interface.storyboard b/SynchronyFinancial/SynchronyFinancial WatchKit App/Base.lproj/Interface.storyboard index db708d7..10ce75c 100644 --- a/SynchronyFinancial/SynchronyFinancial WatchKit App/Base.lproj/Interface.storyboard +++ b/SynchronyFinancial/SynchronyFinancial WatchKit App/Base.lproj/Interface.storyboard @@ -51,21 +51,120 @@ - + + + + + + + + + + + + + + +
+
+
+
+ +
+ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + +
- +
diff --git a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/AccountCell.swift b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/AccountCell.swift new file mode 100644 index 0000000..8bba624 --- /dev/null +++ b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/AccountCell.swift @@ -0,0 +1,14 @@ +// +// Account.swift +// SynchronyFinancial WatchKit Extension +// +// Created by Monday on 2019/02/13. +// Copyright © 2019 Alan Maynard. All rights reserved. +// + +import Foundation +import WatchKit + +class AccountCell: NSObject { + @IBOutlet weak var accountName: WKInterfaceLabel! +} diff --git a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/AccountDetailsInterfaceController.swift b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/AccountDetailsInterfaceController.swift new file mode 100644 index 0000000..cacf7c1 --- /dev/null +++ b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/AccountDetailsInterfaceController.swift @@ -0,0 +1,57 @@ +// +// AccountDetailsInterfaceController.swift +// SynchronyFinancial WatchKit Extension +// +// Created by Alan Maynard on 3/6/19. +// Copyright © 2019 Alan Maynard. All rights reserved. +// + +import WatchKit +import Foundation + +class AccountDetailsInterfaceController: WKInterfaceController { + var selectedAccount: Account? + + @IBOutlet weak var balanceLabel: WKInterfaceLabel! + @IBOutlet weak var availableFundsLabel: WKInterfaceLabel! + @IBOutlet weak var accountNameLabel: WKInterfaceLabel! + @IBOutlet weak var nextPaymentDueLabel: WKInterfaceLabel! + + override func awake(withContext context: Any?) { + super.awake(withContext: context) + + guard let data = context as? [String: Account] else { + NSLog("Error receiving context containing selected account in AccountDetailInterfaceController") + return + } + + selectedAccount = data["acct"] + configureForAccount() + } + + 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() + } + + private func configureForAccount() { + guard selectedAccount != nil, let acct = selectedAccount else { + NSLog("Error configuring AccountDetails. selectedAccount is nil") + return + } + + let balanceFormatted = String(format: "%.2f", acct.balance) + let availableFormatted = String(format: "%.2f", acct.limit - acct.balance) + let date = DateFormatter.localizedString(from: acct.paymentDueDate, dateStyle: .medium, timeStyle: .none) + + accountNameLabel.setText(acct.accountNumber) + balanceLabel.setText("Balance: $\(balanceFormatted)") + availableFundsLabel.setText("Available: $\(availableFormatted)") + nextPaymentDueLabel.setText(date) + } +} diff --git a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/AccountTableInterfaceController.swift b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/AccountTableInterfaceController.swift new file mode 100644 index 0000000..baa7b73 --- /dev/null +++ b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/AccountTableInterfaceController.swift @@ -0,0 +1,61 @@ +// +// AccountTableInterfaceController.swift +// SynchronyFinancial WatchKit Extension +// +// Created by Monday on 2019/02/13. +// Copyright © 2019 Alan Maynard. All rights reserved. +// + +import WatchKit +import Foundation + +class AccountTableInterfaceController: WKInterfaceController { + var accounts: [Account] = [] + var acctDict: [String: Account] = [:] + + @IBOutlet weak var accountTable: WKInterfaceTable! + override func awake(withContext context: Any?) { + super.awake(withContext: context) + + populateDemoData() + configureRows() + } + + 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 contextsForSegue(withIdentifier segueIdentifier: String, in table: WKInterfaceTable, rowIndex: Int) -> [Any]? { + if segueIdentifier == "showAccountDetails" { + // account data is passed to the first interface controller in our new navigation stack + // if we want to pass to subsequent interface controllers, we would add them in corresponding order + acctDict.updateValue(accounts[rowIndex], forKey: "acct") + return [acctDict] + } + return nil + } + + private func configureRows() { + accountTable.setNumberOfRows(accounts.count, withRowType: "account") + + for index in 0..161" + }, { "idiom" : "watch", "scale" : "2x", "screen-width" : ">145" + }, + { + "idiom" : "watch", + "scale" : "2x", + "screen-width" : ">183" } ], "info" : { diff --git a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/Assets.xcassets/Complication.complicationset/Extra Large.imageset/Contents.json b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/Assets.xcassets/Complication.complicationset/Extra Large.imageset/Contents.json index f84499b..aefef29 100644 --- a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/Assets.xcassets/Complication.complicationset/Extra Large.imageset/Contents.json +++ b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/Assets.xcassets/Complication.complicationset/Extra Large.imageset/Contents.json @@ -5,10 +5,20 @@ "scale" : "2x", "screen-width" : "<=145" }, + { + "idiom" : "watch", + "scale" : "2x", + "screen-width" : ">161" + }, { "idiom" : "watch", "scale" : "2x", "screen-width" : ">145" + }, + { + "idiom" : "watch", + "scale" : "2x", + "screen-width" : ">183" } ], "info" : { diff --git a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Bezel.imageset/Contents.json b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Bezel.imageset/Contents.json index f84499b..aefef29 100644 --- a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Bezel.imageset/Contents.json +++ b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Bezel.imageset/Contents.json @@ -5,10 +5,20 @@ "scale" : "2x", "screen-width" : "<=145" }, + { + "idiom" : "watch", + "scale" : "2x", + "screen-width" : ">161" + }, { "idiom" : "watch", "scale" : "2x", "screen-width" : ">145" + }, + { + "idiom" : "watch", + "scale" : "2x", + "screen-width" : ">183" } ], "info" : { diff --git a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Circular.imageset/Contents.json b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Circular.imageset/Contents.json index f84499b..aefef29 100644 --- a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Circular.imageset/Contents.json +++ b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Circular.imageset/Contents.json @@ -5,10 +5,20 @@ "scale" : "2x", "screen-width" : "<=145" }, + { + "idiom" : "watch", + "scale" : "2x", + "screen-width" : ">161" + }, { "idiom" : "watch", "scale" : "2x", "screen-width" : ">145" + }, + { + "idiom" : "watch", + "scale" : "2x", + "screen-width" : ">183" } ], "info" : { diff --git a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Corner.imageset/Contents.json b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Corner.imageset/Contents.json index f84499b..aefef29 100644 --- a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Corner.imageset/Contents.json +++ b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Corner.imageset/Contents.json @@ -5,10 +5,20 @@ "scale" : "2x", "screen-width" : "<=145" }, + { + "idiom" : "watch", + "scale" : "2x", + "screen-width" : ">161" + }, { "idiom" : "watch", "scale" : "2x", "screen-width" : ">145" + }, + { + "idiom" : "watch", + "scale" : "2x", + "screen-width" : ">183" } ], "info" : { diff --git a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Large Rectangular.imageset/Contents.json b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Large Rectangular.imageset/Contents.json index f84499b..aefef29 100644 --- a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Large Rectangular.imageset/Contents.json +++ b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/Assets.xcassets/Complication.complicationset/Graphic Large Rectangular.imageset/Contents.json @@ -5,10 +5,20 @@ "scale" : "2x", "screen-width" : "<=145" }, + { + "idiom" : "watch", + "scale" : "2x", + "screen-width" : ">161" + }, { "idiom" : "watch", "scale" : "2x", "screen-width" : ">145" + }, + { + "idiom" : "watch", + "scale" : "2x", + "screen-width" : ">183" } ], "info" : { diff --git a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/Assets.xcassets/Complication.complicationset/Modular.imageset/Contents.json b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/Assets.xcassets/Complication.complicationset/Modular.imageset/Contents.json index f84499b..aefef29 100644 --- a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/Assets.xcassets/Complication.complicationset/Modular.imageset/Contents.json +++ b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/Assets.xcassets/Complication.complicationset/Modular.imageset/Contents.json @@ -5,10 +5,20 @@ "scale" : "2x", "screen-width" : "<=145" }, + { + "idiom" : "watch", + "scale" : "2x", + "screen-width" : ">161" + }, { "idiom" : "watch", "scale" : "2x", "screen-width" : ">145" + }, + { + "idiom" : "watch", + "scale" : "2x", + "screen-width" : ">183" } ], "info" : { diff --git a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/Assets.xcassets/Complication.complicationset/Utilitarian.imageset/Contents.json b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/Assets.xcassets/Complication.complicationset/Utilitarian.imageset/Contents.json index f84499b..aefef29 100644 --- a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/Assets.xcassets/Complication.complicationset/Utilitarian.imageset/Contents.json +++ b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/Assets.xcassets/Complication.complicationset/Utilitarian.imageset/Contents.json @@ -5,10 +5,20 @@ "scale" : "2x", "screen-width" : "<=145" }, + { + "idiom" : "watch", + "scale" : "2x", + "screen-width" : ">161" + }, { "idiom" : "watch", "scale" : "2x", "screen-width" : ">145" + }, + { + "idiom" : "watch", + "scale" : "2x", + "screen-width" : ">183" } ], "info" : { diff --git a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/TransactionCell.swift b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/TransactionCell.swift new file mode 100644 index 0000000..e9d39bd --- /dev/null +++ b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/TransactionCell.swift @@ -0,0 +1,16 @@ +// +// TransactionCell.swift +// SynchronyFinancial WatchKit Extension +// +// Created by Alan Maynard on 3/20/19. +// Copyright © 2019 Alan Maynard. All rights reserved. +// + +import Foundation +import WatchKit + +class TransactionCell: NSObject { + + @IBOutlet weak var transactionLabel: WKInterfaceLabel! + @IBOutlet weak var valueLabel: WKInterfaceLabel! +} diff --git a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/TransactionsInterfaceController.swift b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/TransactionsInterfaceController.swift new file mode 100644 index 0000000..5fe7f07 --- /dev/null +++ b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/TransactionsInterfaceController.swift @@ -0,0 +1,48 @@ +// +// TransactionsInterfaceController.swift +// SynchronyFinancial WatchKit Extension +// +// Created by Alan Maynard on 3/20/19. +// Copyright © 2019 Alan Maynard. All rights reserved. +// + +import WatchKit +import Foundation + +class TransactionsInterfaceController: WKInterfaceController { + @IBOutlet weak var transactionsTable: WKInterfaceTable! + var transactions: [Transaction] = [] + + override func awake(withContext context: Any?) { + super.awake(withContext: context) + for i in 0..<5 { + transactions.append(Transaction(type: .purchase, amount: 50.00 * Double(i), merchantID: "WalMart Store 1245\(i)", date: Calendar.current.date(byAdding: .day, value: -i, to: Date()) ?? Date())) + transactions.append(Transaction(type: .reimbursement, amount: 12.5 * Double(i), merchantID: "Thank You", date: Calendar.current.date(byAdding: .day, value: -i, to: Date()) ?? Date())) + } + configureRows() + } + + 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() + } + + private func configureRows() { + // first sort our demo data in descending date order + transactions.sort(by: { $0.date > $1.date }) + transactionsTable.setNumberOfRows(transactions.count, withRowType: "transactionCell") + + for index in 0..