Skip to content

Swe 23 transaction details #14

Merged
merged 4 commits into from Apr 8, 2019
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file
Failed to load files.

Always

Just for now

Next

SWE-23 Implement modal view to show transaction details

- preliminary design for screen to “pop up” and show transaction details
- opted for a more robust approach than a simple `WKAlert` in order to have multiple labels for values such as date, amount, etc
- Cancel Payment button hides/shows for qualifying transactions
  • Loading branch information
ahm11003 committed Apr 3, 2019
commit ce07b1f589f55b9882eb040ad4fa636a1090ba0b
@@ -253,6 +253,29 @@
</objects>
<point key="canvasLocation" x="1085" y="-229"/>
</scene>
<!--TransactionDetails-->
<scene sceneID="aqX-eB-bdU">
<objects>
<controller identifier="TransactionDetails" id="LeA-fL-4Wb" customClass="TransactionDetailsInterfaceController" customModule="SynchronyFinancial_WatchKit_App" customModuleProvider="target">
<items>
<label width="1" alignment="center" text="Scheduled Online Payment Processing" textAlignment="center" numberOfLines="2" minimumScaleFactor="0.69999999999999996" id="z1i-je-74F">
<fontDescription key="font" type="boldSystem" pointSize="15"/>
</label>
<separator alignment="left" id="HuQ-dl-7Ni"/>
<label width="1" alignment="center" verticalAlignment="center" text="Label" textAlignment="center" id="F4A-wp-ECw"/>
<label width="1" alignment="center" verticalAlignment="center" text="Label" textAlignment="center" id="d4y-NP-GbP"/>
<button width="1" alignment="center" verticalAlignment="bottom" title="Cancel Payment" id="4Rt-Xc-Vdh"/>
</items>
<connections>
<outlet property="amountLabel" destination="d4y-NP-GbP" id="WOU-uA-pCu"/>
<outlet property="cancelButton" destination="4Rt-Xc-Vdh" id="TLc-0k-RFv"/>
<outlet property="dateLabel" destination="F4A-wp-ECw" id="J5W-xg-g3R"/>
<outlet property="transactionName" destination="z1i-je-74F" id="i76-Qo-iL9"/>
</connections>
</controller>
</objects>
<point key="canvasLocation" x="1420" y="-229"/>
</scene>
</scenes>
<inferredMetricsTieBreakers>
<segue reference="AFS-lo-piH"/>
@@ -0,0 +1,46 @@
//
// TransactionDetailsInterfaceController.swift
// SynchronyFinancial WatchKit Extension
//
// Created by Alan Maynard on 4/2/19.
// Copyright © 2019 Alan Maynard. All rights reserved.
//
import WatchKit
import Foundation


class TransactionDetailsInterfaceController: WKInterfaceController {
@IBOutlet var transactionName: WKInterfaceLabel!
@IBOutlet var dateLabel: WKInterfaceLabel!
@IBOutlet var amountLabel: WKInterfaceLabel!
@IBOutlet var cancelButton: WKInterfaceButton!
override func awake(withContext context: Any?) {
super.awake(withContext: context)

guard let data = context as? [String: Any],
let transaction = data["transaction"] as? Transaction,
let merchant = data["merchant"] as? String,
let date = data["date"] as? Date,
let amount = data["amount"] as? Double else {
NSLog("Error receiving context in TransactionDetails.")
return
}

transactionName.setText(merchant)
dateLabel.setText("Date: \(DateFormatter.localizedString(from: date, dateStyle: .short, timeStyle: .none))")
amountLabel.setText(String(format: "Amount: $%.2f", amount))
cancelButton.setHidden(!transaction.isModifiable)
}

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()
}

}
@@ -35,6 +35,16 @@ class TransactionsInterfaceController: WKInterfaceController {
super.didDeactivate()
}

override func table(_ table: WKInterfaceTable, didSelectRowAt rowIndex: Int) {
let transaction = transactions[rowIndex]
let context: [String: Any] = ["transaction": transaction,
"merchant": transaction.merchantID,
"date": transaction.date,
"amount": transaction.amount]

presentController(withName: "TransactionDetails", context: context)
}

private func configureRows() {
// first sort our demo data in descending date order
transactions.sort(by: { $0.date > $1.date })
@@ -20,6 +20,7 @@
48F2430E2214CBF700B9C894 /* Transaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48F2430C2214CBF700B9C894 /* Transaction.swift */; };
48F2430F2214CC2200B9C894 /* Transaction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 48F2430C2214CBF700B9C894 /* Transaction.swift */; };
67228CD8224D6E2700CA29E4 /* WKInterfaceImage+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67228CD7224D6E2700CA29E4 /* WKInterfaceImage+Extensions.swift */; };
67293CF122542F15009E0E7A /* TransactionDetailsInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67293CF022542F15009E0E7A /* TransactionDetailsInterfaceController.swift */; };
673F396E21A644570051469E /* MainMenuInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 673F396C21A644460051469E /* MainMenuInterfaceController.swift */; };
673F397021A652A00051469E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 673F396F21A652A00051469E /* Assets.xcassets */; };
674BD1532239A39D0076AFD6 /* PayBillInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 674BD1522239A39D0076AFD6 /* PayBillInterfaceController.swift */; };
@@ -98,6 +99,7 @@
48F2430C2214CBF700B9C894 /* Transaction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Transaction.swift; sourceTree = "<group>"; };
4EA10823B2E5A7A4FEF31740 /* libPods-SynchronyFinancial WatchKit App.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-SynchronyFinancial WatchKit App.a"; sourceTree = BUILT_PRODUCTS_DIR; };
67228CD7224D6E2700CA29E4 /* WKInterfaceImage+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "WKInterfaceImage+Extensions.swift"; sourceTree = "<group>"; };
67293CF022542F15009E0E7A /* TransactionDetailsInterfaceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TransactionDetailsInterfaceController.swift; sourceTree = "<group>"; };
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>"; };
674BD1522239A39D0076AFD6 /* PayBillInterfaceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PayBillInterfaceController.swift; sourceTree = "<group>"; };
@@ -204,6 +206,7 @@
67BAC28A219E254900713FEF /* SynchronyFinancial WatchKit Extension */ = {
isa = PBXGroup;
children = (
67293CF022542F15009E0E7A /* TransactionDetailsInterfaceController.swift */,
674BD1522239A39D0076AFD6 /* PayBillInterfaceController.swift */,
481864A7224802BB0059CF7A /* PaymentDetailInterfaceController.swift */,
676392B322429DC800740A8C /* TransactionsInterfaceController.swift */,
@@ -489,6 +492,7 @@
678C38842230950100FEAAF6 /* AccountDetailsInterfaceController.swift in Sources */,
673F396E21A644570051469E /* MainMenuInterfaceController.swift in Sources */,
67E17B87223812C2008871FE /* Defaults.swift in Sources */,
67293CF122542F15009E0E7A /* TransactionDetailsInterfaceController.swift in Sources */,
1123372E223ABD6400B70925 /* FetchData.swift in Sources */,
48F243072214C98600B9C894 /* AccountTableInterfaceController.swift in Sources */,
676392B62242A3F800740A8C /* TransactionCell.swift in Sources */,
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.