Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
SWF-17 new image assets, implementation for utilization trend
- currently we generate a random number between 0 and the credit limit of an account in order to “simulate” trend compared to previous statement utilization
- added some nice images to further display the trends
  • Loading branch information
ahm11003 committed Apr 17, 2019
1 parent 85fd3e2 commit 4f67b56
Show file tree
Hide file tree
Showing 12 changed files with 105 additions and 14 deletions.
Expand Up @@ -56,7 +56,9 @@
<objects>
<controller id="FsK-xr-8Fi" customClass="WellnessInterfaceController" customModule="SynchronyFinancial_WatchKit_Extension">
<items>
<label width="1" alignment="center" text="Credit Wellness" textAlignment="center" id="eqA-XH-rlH"/>
<label width="1" alignment="center" text="Credit Wellness" textAlignment="center" id="eqA-XH-rlH">
<fontDescription key="font" type="boldSystem" pointSize="16"/>
</label>
<imageView width="1" height="86" alignment="center" verticalAlignment="center" image="scores" contentMode="scaleAspectFit" initiallyAnimated="NO" animationDuration="2" id="aTf-mo-FEr"/>
<button width="1" alignment="center" verticalAlignment="bottom" title="Breakdown" id="yYk-gv-I5B">
<fontDescription key="font" type="system" pointSize="13"/>
Expand All @@ -72,16 +74,25 @@
</objects>
<point key="canvasLocation" x="23" y="602"/>
</scene>
<!--AccountScore-->
<!--UtilizationTrend-->
<scene sceneID="jxS-9m-lB7">
<objects>
<controller identifier="AccountScore" id="Mki-ad-UCC" customClass="UtilizationTrendInterfaceController" customModule="SynchronyFinancial_WatchKit_Extension">
<controller identifier="UtilizationTrend" id="Mki-ad-UCC" customClass="UtilizationTrendInterfaceController" customModule="SynchronyFinancial_WatchKit_Extension">
<items>
<label width="1" alignment="left" text="Utilization Trends" textAlignment="center" id="0ed-0W-LKq"/>
<imageView width="1" height="120" alignment="center" verticalAlignment="center" image="scores" contentMode="scaleAspectFit" initiallyAnimated="NO" id="RlX-Hj-mTY"/>
<label width="1" alignment="left" text="Utilization Trends" textAlignment="center" id="0ed-0W-LKq">
<fontDescription key="font" type="boldSystem" pointSize="15"/>
</label>
<group width="1" alignment="left" verticalAlignment="center" id="FNM-AZ-gSn">
<items>
<label width="0.59999999999999998" widthAdjustment="2" height="75" alignment="right" alpha="0.0" text="Down from 75% last statement" textAlignment="center" numberOfLines="4" minimumScaleFactor="0.59999999999999998" id="YAS-g2-ZSX"/>
<imageView width="0.40000000000000002" height="69" alignment="left" verticalAlignment="center" alpha="0.0" image="arrow_down" contentMode="scaleAspectFit" initiallyAnimated="NO" id="RlX-Hj-mTY"/>
</items>
</group>
<button width="1" alignment="left" verticalAlignment="bottom" title="Details" id="dAi-xm-mph"/>
</items>
<connections>
<outlet property="image2" destination="RlX-Hj-mTY" id="9Ni-gP-7T5"/>
<outlet property="trendImage" destination="RlX-Hj-mTY" id="pc0-UO-40U"/>
<outlet property="trendLabel" destination="YAS-g2-ZSX" id="o4S-5g-JUe"/>
<segue destination="RNe-Ul-1jm" kind="relationship" relationship="nextPage" id="idj-33-lnN"/>
</connections>
</controller>
Expand Down Expand Up @@ -321,7 +332,9 @@
<items>
<group width="1" height="1" alignment="left" layout="vertical" id="ad4-JN-O9D">
<items>
<label width="1" alignment="left" text="Credit Utilization" textAlignment="center" id="Rzj-RR-iat"/>
<label width="1" alignment="left" text="Credit Utilization" textAlignment="center" id="Rzj-RR-iat">
<fontDescription key="font" type="boldSystem" pointSize="16"/>
</label>
<imageView width="1" height="100" alignment="center" verticalAlignment="center" image="scores" contentMode="scaleAspectFit" initiallyAnimated="NO" id="MkL-48-J8l"/>
<button width="1" alignment="left" verticalAlignment="center" title="Details" id="AR5-QD-8ad">
<connections>
Expand Down
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "arrow_down.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "arrow_down@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "arrow_down@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -0,0 +1,23 @@
{
"images" : [
{
"idiom" : "universal",
"filename" : "arrow_up.png",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "arrow_up@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "arrow_up@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Expand Up @@ -9,23 +9,48 @@
import WatchKit
import Foundation


class UtilizationTrendInterfaceController: WKInterfaceController {
@IBOutlet var trendImage: WKInterfaceImage!
@IBOutlet var trendLabel: WKInterfaceLabel!

var previousUtilization: Int?
var currentUtilization: Int?

override func awake(withContext context: Any?) {
super.awake(withContext: context)

// Configure interface objects here.
guard let data = context as? [Int], data.count == 2 else {
NSLog("Error getting utilization data from wellness.")
return
}
previousUtilization = data[1]
currentUtilization = data[0]
configure()
}

override func willActivate() {
override func didAppear() {
// This method is called when watch view controller is about to be visible to user
super.willActivate()
super.didAppear()
animate(withDuration: 1.5) {
self.trendImage.setAlpha(1.0)
self.trendLabel.setAlpha(1.0)
}
}

override func didDeactivate() {
// This method is called when watch view controller is no longer visible
super.didDeactivate()
}

private func configure() {
if let prev = previousUtilization, let curr = currentUtilization {
if prev > curr {
trendImage.setImageNamed("arrow_down")
trendLabel.setText("Down from \(prev)% last statement.")
} else {
trendImage.setImageNamed("arrow_up")
trendLabel.setText("Up from \(prev)% last statement.")
}
}
}

}
Expand Up @@ -9,14 +9,14 @@
import WatchKit
import Foundation


class WellnessInterfaceController: WKInterfaceController {
var accounts: [Account] = []
var transactions: [Transaction] = []
var transactionDict: [String: [Transaction]] = [:]
var wellnessScore: Int?
var utilizationScore: Int = 0
var paymentScore: Int = 0
var previousUtil: Int = 0

@IBOutlet weak var image: WKInterfaceImage!

Expand Down Expand Up @@ -56,13 +56,16 @@ class WellnessInterfaceController: WKInterfaceController {
private func calculateUtilization() {
var totalBalance: Double = 0
var totalCredit: Double = 0
var previous: Double = 0

accounts.forEach {
totalCredit += $0.creditLimit
totalBalance += $0.curBalance
previous += Double(arc4random_uniform(UInt32($0.creditLimit)))
}

utilizationScore = Int((totalBalance / totalCredit) * 100)
previousUtil = Int((previous / totalCredit) * 100)
}

private func calculateWellness() {
Expand All @@ -89,6 +92,8 @@ class WellnessInterfaceController: WKInterfaceController {
}*/

@IBAction func moreButtonTapped() {
presentController(withNames: ["UtilizationScore", "PaymentScore"], contexts: [utilizationScore, paymentScore])
let pages = ["UtilizationScore", "UtilizationTrend", "PaymentScore"]
let contexts: [Any] = [utilizationScore, [utilizationScore, previousUtil], paymentScore]
presentController(withNames: pages, contexts: contexts)
}
}
Expand Up @@ -26,6 +26,7 @@
676392B422429DC800740A8C /* TransactionsInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 676392B322429DC800740A8C /* TransactionsInterfaceController.swift */; };
676392B62242A3F800740A8C /* TransactionCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 676392B52242A3F800740A8C /* TransactionCell.swift */; };
678535932267D706000DF272 /* UtilizationTrendInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 678535922267D706000DF272 /* UtilizationTrendInterfaceController.swift */; };
678535942267D9BC000DF272 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 67BAC291219E254900713FEF /* Assets.xcassets */; };
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 @@ -359,6 +360,7 @@
buildActionMask = 2147483647;
files = (
48F2430A2214CBA200B9C894 /* Interface.storyboard in Resources */,
678535942267D9BC000DF272 /* Assets.xcassets in Resources */,
673F397021A652A00051469E /* Assets.xcassets in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down

0 comments on commit 4f67b56

Please sign in to comment.