From e05e55c44e2d1aebc5f69a4a0b2cfa2777d1f322 Mon Sep 17 00:00:00 2001 From: Alan Maynard Date: Tue, 12 Mar 2019 12:03:22 -0400 Subject: [PATCH 1/5] SWF-14 added .swiftlint.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - disabled rules for silly things like line length and short identifier names - don’t run swiftlint in our pods directory, since we shouldn’t be changing anything there --- SynchronyFinancial/.swiftlint.yml | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 SynchronyFinancial/.swiftlint.yml 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 From 4217f757b590cf97af2bebea5166b4c8d9baf3a5 Mon Sep 17 00:00:00 2001 From: Alan Maynard Date: Tue, 12 Mar 2019 12:03:52 -0400 Subject: [PATCH 2/5] SWF-14 remove tags to disable swiftlint warnings - these can be removed as a result of adding .swiftlint.yml --- .../ExtensionDelegate.swift | 1 - SynchronyFinancial/SynchronyFinancial/AppDelegate.swift | 1 - 2 files changed, 2 deletions(-) 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/AppDelegate.swift b/SynchronyFinancial/SynchronyFinancial/AppDelegate.swift index 4122478..4a3443e 100644 --- a/SynchronyFinancial/SynchronyFinancial/AppDelegate.swift +++ b/SynchronyFinancial/SynchronyFinancial/AppDelegate.swift @@ -8,7 +8,6 @@ import UIKit -//swiftlint:disable line_length @UIApplicationMain class AppDelegate: UIResponder, UIApplicationDelegate { From 1b6bc34dc00c1dbf2e6c471c81725526c6272a75 Mon Sep 17 00:00:00 2001 From: Alan Maynard Date: Thu, 21 Mar 2019 12:50:09 -0400 Subject: [PATCH 3/5] SWF-11 Create new classes to support transaction display - `TransactionsInterfactController` will hold a table of recent transactions - `TransactionCell` provides a model for our table cell --- .../TransactionCell.swift | 16 +++++++ .../TransactionsInterfaceController.swift | 48 +++++++++++++++++++ .../project.pbxproj | 8 ++++ 3 files changed, 72 insertions(+) create mode 100644 SynchronyFinancial/SynchronyFinancial WatchKit Extension/TransactionCell.swift create mode 100644 SynchronyFinancial/SynchronyFinancial WatchKit Extension/TransactionsInterfaceController.swift 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.. Date: Thu, 21 Mar 2019 12:51:37 -0400 Subject: [PATCH 4/5] SWF-11 Storyboard changes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added TransactionsInterfaceController - In order to have a page based navigation allowing swipe between Account Details and Transactions, it was necessary to change the segue from the Accounts Table to “modal” type --- .../Base.lproj/Interface.storyboard | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) 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 @@ + + + + + + + + + + + + + + + + + + + +
+
+ + + +
+
+ +
From bb5623c50c3cbad4f9526bf35fc49fbbca89eb06 Mon Sep 17 00:00:00 2001 From: Alan Maynard Date: Thu, 21 Mar 2019 12:54:54 -0400 Subject: [PATCH 5/5] SWF-11 Change context for segue - As a result of the change to modal presentation, the function we must override has changed - Instead of returning the context for the next interface controller, we return an array of contexts, each corresponding to the interface controllers in the order they appear in the navigation stack (Account details is first, transactions is now second) - once web service is set up, transactions should be passed to TransactionsInterfactController from this function --- .../AccountTableInterfaceController.swift | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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 }