-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from rrk12005/SWF-11-recent-transactions
Swf 11 recent transactions
- Loading branch information
Showing
8 changed files
with
112 additions
and
6 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
disabled_rules: | ||
- line_length | ||
- identifier_name | ||
excluded: | ||
- Pods |
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
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
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
16 changes: 16 additions & 0 deletions
16
SynchronyFinancial/SynchronyFinancial WatchKit Extension/TransactionCell.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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! | ||
} |
48 changes: 48 additions & 0 deletions
48
...ronyFinancial/SynchronyFinancial WatchKit Extension/TransactionsInterfaceController.swift
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) | ||
} | ||
} | ||
} | ||
} |
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
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