diff --git a/SynchronyFinancial/.swiftlint.yml b/SynchronyFinancial/.swiftlint.yml new file mode 100644 index 0000000..da47ce2 --- /dev/null +++ b/SynchronyFinancial/.swiftlint.yml @@ -0,0 +1,5 @@ +disabled_rules: + - line_length + - identifier_name +excluded: + - Pods diff --git a/SynchronyFinancial/SynchronyFinancial WatchKit App/Base.lproj/Interface.storyboard b/SynchronyFinancial/SynchronyFinancial WatchKit App/Base.lproj/Interface.storyboard index d2f0a7a..10ce75c 100644 --- a/SynchronyFinancial/SynchronyFinancial WatchKit App/Base.lproj/Interface.storyboard +++ b/SynchronyFinancial/SynchronyFinancial WatchKit App/Base.lproj/Interface.storyboard @@ -100,7 +100,7 @@ - + @@ -131,10 +131,40 @@ + + + + + + + + + + + + + + + + + + + +
+
+ + + +
+
+ +
diff --git a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/AccountTableInterfaceController.swift b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/AccountTableInterfaceController.swift index ddbffd5..baa7b73 100644 --- a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/AccountTableInterfaceController.swift +++ b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/AccountTableInterfaceController.swift @@ -31,11 +31,12 @@ class AccountTableInterfaceController: WKInterfaceController { super.didDeactivate() } - //swiftlint:disable:next line_length - override func contextForSegue(withIdentifier segueIdentifier: String, in table: WKInterfaceTable, rowIndex: Int) -> Any? { + 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 [acctDict] } return nil } diff --git a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/ExtensionDelegate.swift b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/ExtensionDelegate.swift index f573484..eed655b 100644 --- a/SynchronyFinancial/SynchronyFinancial WatchKit Extension/ExtensionDelegate.swift +++ b/SynchronyFinancial/SynchronyFinancial WatchKit Extension/ExtensionDelegate.swift @@ -8,7 +8,6 @@ import WatchKit -//swiftlint:disable line_length class ExtensionDelegate: NSObject, WKExtensionDelegate { func applicationDidFinishLaunching() { 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..