Skip to content

Swf 11 recent transactions #9

Merged
merged 7 commits into from Mar 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions SynchronyFinancial/.swiftlint.yml
@@ -0,0 +1,5 @@
disabled_rules:
- line_length
- identifier_name
excluded:
- Pods
Expand Up @@ -100,7 +100,7 @@
</group>
<connections>
<outlet property="accountName" destination="Tl1-Kc-YJS" id="cgD-CY-lzh"/>
<segue destination="yrN-yp-gkH" kind="push" identifier="showAccountDetails" id="geu-70-EU1"/>
<segue destination="yrN-yp-gkH" kind="modal" identifier="showAccountDetails" id="geu-70-EU1"/>
</connections>
</tableRow>
</items>
Expand Down Expand Up @@ -131,10 +131,40 @@
<outlet property="availableFundsLabel" destination="q0b-tb-dAb" id="rcl-Tl-bDh"/>
<outlet property="balanceLabel" destination="mdb-QX-GuO" id="2Dj-nO-AM8"/>
<outlet property="nextPaymentDueLabel" destination="CPc-qk-Z2y" id="AzY-pn-EMY"/>
<segue destination="Jfd-Hv-PHe" kind="relationship" relationship="nextPage" id="fqW-qd-CCS"/>
</connections>
</controller>
</objects>
<point key="canvasLocation" x="755" y="-53.5"/>
</scene>
<!--Transactions Interface Controller-->
<scene sceneID="yXO-yR-k6b">
<objects>
<controller id="Jfd-Hv-PHe" customClass="TransactionsInterfaceController" customModule="SynchronyFinancial_WatchKit_Extension">
<items>
<table alignment="left" id="OQb-xu-Ynf">
<items>
<tableRow identifier="transactionCell" id="ICl-8S-VHQ" customClass="TransactionCell" customModule="SynchronyFinancial_WatchKit_Extension">
<group key="rootItem" width="1" height="49" alignment="left" layout="vertical" id="GP6-Ec-AVa">
<items>
<label width="1" alignment="left" text="Label" textAlignment="left" id="Hm4-1L-Cyl"/>
<label width="1" alignment="left" text="Label" textAlignment="right" id="Gxn-sX-7gs"/>
</items>
</group>
<connections>
<outlet property="transactionLabel" destination="Hm4-1L-Cyl" id="hYO-F0-S1A"/>
<outlet property="valueLabel" destination="Gxn-sX-7gs" id="COh-0S-dY7"/>
</connections>
</tableRow>
</items>
</table>
</items>
<connections>
<outlet property="transactionsTable" destination="OQb-xu-Ynf" id="eg6-n7-ldT"/>
</connections>
</controller>
</objects>
<point key="canvasLocation" x="1086" y="-54"/>
</scene>
</scenes>
</document>
Expand Up @@ -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
}
Expand Down
Expand Up @@ -8,7 +8,6 @@
import WatchKit

//swiftlint:disable line_length
class ExtensionDelegate: NSObject, WKExtensionDelegate {

func applicationDidFinishLaunching() {
Expand Down
@@ -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!
}
@@ -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..<transactionsTable.numberOfRows {
if let row = transactionsTable.rowController(at: index) as? TransactionCell {
row.transactionLabel.setText(transactions[index].merchantID)
row.valueLabel.setText(String(format: "$%.2f", transactions[index].amount))
row.valueLabel.setTextColor(transactions[index].type == .purchase ? UIColor.red : UIColor.green)
}
}
}
}
Expand Up @@ -17,6 +17,8 @@
48F2430F2214CC2200B9C894 /* Transaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48F2430C2214CBF700B9C894 /* Transaction.swift */; };
673F396E21A644570051469E /* MainMenuInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 673F396C21A644460051469E /* MainMenuInterfaceController.swift */; };
673F397021A652A00051469E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 673F396F21A652A00051469E /* Assets.xcassets */; };
676392B422429DC800740A8C /* TransactionsInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 676392B322429DC800740A8C /* TransactionsInterfaceController.swift */; };
676392B62242A3F800740A8C /* TransactionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 676392B52242A3F800740A8C /* TransactionCell.swift */; };
678C38842230950100FEAAF6 /* AccountDetailsInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 678C38832230950100FEAAF6 /* AccountDetailsInterfaceController.swift */; };
678C3885223098C400FEAAF6 /* Account.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48F2430B2214CBF700B9C894 /* Account.swift */; };
678C388622309F7D00FEAAF6 /* AccountCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48DA0057221D12E70081A500 /* AccountCell.swift */; };
Expand Down Expand Up @@ -85,6 +87,8 @@
4EA10823B2E5A7A4FEF31740 /* libPods-SynchronyFinancial WatchKit App.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-SynchronyFinancial WatchKit App.a"; sourceTree = BUILT_PRODUCTS_DIR; };
673F396C21A644460051469E /* MainMenuInterfaceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MainMenuInterfaceController.swift; sourceTree = "<group>"; };
673F396F21A652A00051469E /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
676392B322429DC800740A8C /* TransactionsInterfaceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransactionsInterfaceController.swift; sourceTree = "<group>"; };
676392B52242A3F800740A8C /* TransactionCell.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransactionCell.swift; sourceTree = "<group>"; };
678C38832230950100FEAAF6 /* AccountDetailsInterfaceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountDetailsInterfaceController.swift; sourceTree = "<group>"; };
67BAC265219E254700713FEF /* SynchronyFinancial.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SynchronyFinancial.app; sourceTree = BUILT_PRODUCTS_DIR; };
67BAC268219E254700713FEF /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -183,12 +187,14 @@
67BAC28A219E254900713FEF /* SynchronyFinancial WatchKit Extension */ = {
isa = PBXGroup;
children = (
676392B322429DC800740A8C /* TransactionsInterfaceController.swift */,
673F396C21A644460051469E /* MainMenuInterfaceController.swift */,
67BAC28D219E254900713FEF /* ExtensionDelegate.swift */,
48F243062214C98600B9C894 /* AccountTableInterfaceController.swift */,
678C38832230950100FEAAF6 /* AccountDetailsInterfaceController.swift */,
67BAC291219E254900713FEF /* Assets.xcassets */,
48DA0057221D12E70081A500 /* AccountCell.swift */,
676392B52242A3F800740A8C /* TransactionCell.swift */,
67BAC293219E254900713FEF /* Info.plist */,
);
path = "SynchronyFinancial WatchKit Extension";
Expand Down Expand Up @@ -457,7 +463,9 @@
678C38842230950100FEAAF6 /* AccountDetailsInterfaceController.swift in Sources */,
673F396E21A644570051469E /* MainMenuInterfaceController.swift in Sources */,
48F243072214C98600B9C894 /* AccountTableInterfaceController.swift in Sources */,
676392B62242A3F800740A8C /* TransactionCell.swift in Sources */,
48F2430F2214CC2200B9C894 /* Transaction.swift in Sources */,
676392B422429DC800740A8C /* TransactionsInterfaceController.swift in Sources */,
48DA0058221D12E70081A500 /* AccountCell.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
1 change: 0 additions & 1 deletion SynchronyFinancial/SynchronyFinancial/AppDelegate.swift
Expand Up @@ -8,7 +8,6 @@
import UIKit

//swiftlint:disable line_length
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

Expand Down