Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
SWF-17 More wellness implementation
- remove deprecated `PaymentScore` and all related logic to calculate this metric
- added classes `AvgUtilization`, `HealthyAccounts`, and `LastPayment` interface controllers to display more metrics and add dynamic reports for users with multiple accounts
  • Loading branch information
ahm11003 committed Apr 23, 2019
1 parent 80acdbf commit ddbc228
Show file tree
Hide file tree
Showing 7 changed files with 168 additions and 115 deletions.
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="14460.31" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="Qge-pO-HLc">
<document type="com.apple.InterfaceBuilder.WatchKit.Storyboard" version="3.0" toolsVersion="14490.70" targetRuntime="watchKit" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="Qge-pO-HLc">
<device id="watch38" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="watchOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14460.20"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="14460.16"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBWatchKitPlugin" version="14490.21"/>
</dependencies>
<scenes>
<!--root-->
Expand Down Expand Up @@ -79,8 +79,8 @@
<objects>
<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">
<fontDescription key="font" type="boldSystem" pointSize="15"/>
<label width="1" alignment="left" text="Utilization Trends" textAlignment="center" minimumScaleFactor="0.90000000000000002" id="0ed-0W-LKq">
<fontDescription key="font" type="boldSystem" pointSize="16"/>
</label>
<group width="1" alignment="left" verticalAlignment="center" id="FNM-AZ-gSn">
<items>
Expand Down Expand Up @@ -305,7 +305,7 @@
</connections>
</controller>
</objects>
<point key="canvasLocation" x="1400" y="516"/>
<point key="canvasLocation" x="1722" y="186"/>
</scene>
<!--Transactions-->
<scene sceneID="yXO-yR-k6b">
Expand Down Expand Up @@ -416,26 +416,63 @@
</items>
<connections>
<outlet property="image3" destination="MkL-48-J8l" id="QRq-aZ-tTD"/>
<segue destination="k4M-kn-ZzM" kind="relationship" relationship="nextPage" id="VDf-IX-Y7J"/>
</connections>
</controller>
</objects>
<point key="canvasLocation" x="613" y="602"/>
</scene>
<!--PaymentScore-->
<scene sceneID="do4-GS-cad">
<!--LastPayment-->
<scene sceneID="VsC-Vr-IJF">
<objects>
<controller identifier="PaymentScore" id="k4M-kn-ZzM" customClass="ConsistencyInterfaceController" customModule="SynchronyFinancial_WatchKit_Extension">
<controller identifier="LastPayment" id="mId-Ii-HO4" customClass="LastPaymentInterfaceController" customModule="SynchronyFinancial_WatchKit_Extension">
<items>
<label width="1" height="20" alignment="left" text="Payment Score" textAlignment="center" id="5cf-d7-ssN"/>
<imageView width="1" height="120" alignment="center" verticalAlignment="center" image="scores" contentMode="scaleAspectFit" initiallyAnimated="NO" id="XsN-KK-JY4"/>
<label width="1" alignment="center" text="Last Payment" textAlignment="center" id="s3f-G9-0Lf">
<fontDescription key="font" type="boldSystem" pointSize="16"/>
</label>
</items>
</controller>
</objects>
<point key="canvasLocation" x="888" y="602"/>
</scene>
<!--AvgUtilization-->
<scene sceneID="w5c-8S-E5f">
<objects>
<controller identifier="AvgUtilization" id="WY4-SK-U7W" customClass="AvgUtilizationInterfaceController" customModule="SynchronyFinancial_WatchKit_Extension">
<items>
<label width="1" alignment="center" text="Average Utilization" textAlignment="center" minimumScaleFactor="0.80000000000000004" id="UGo-Sz-lKo">
<fontDescription key="font" type="boldSystem" pointSize="16"/>
</label>
<imageView width="1" height="93" alignment="center" verticalAlignment="center" id="JDC-go-3sn"/>
<button width="1" alignment="left" verticalAlignment="center" title="Button" id="JxL-nb-z6E"/>
</items>
</controller>
</objects>
<point key="canvasLocation" x="1188" y="602"/>
</scene>
<!--HealthyAccts-->
<scene sceneID="EXd-2K-21X">
<objects>
<controller identifier="HealthyAccts" id="uKU-6b-2xO" customClass="HealthyAccountsInterfaceController" customModule="SynchronyFinancial_WatchKit_Extension">
<items>
<label width="136" alignment="left" text="Healthy Accounts" textAlignment="center" minimumScaleFactor="0.80000000000000004" id="N2h-Jp-Si7">
<fontDescription key="font" type="boldSystem" pointSize="16"/>
</label>
<group width="1" height="86" alignment="left" id="kkT-69-aei">
<items>
<label width="0.5" height="1" alignment="center" text="99" textAlignment="center" id="tyj-DI-Sgf">
<color key="textColor" red="0.55326947770000001" green="0.94338613010000005" blue="0.18923908389999999" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="font" type="system" weight="heavy" pointSize="55"/>
</label>
<label width="0.5" height="1" alignment="right" text="Accounts with Good or better Utilization" textAlignment="center" numberOfLines="5" id="W6T-4E-azA">
<fontDescription key="font" type="system" pointSize="12"/>
</label>
</items>
</group>
<button width="1" alignment="left" title="Button" id="HTc-Qj-xOt"/>
</items>
<connections>
<outlet property="image4" destination="XsN-KK-JY4" id="fqD-Hx-YuD"/>
</connections>
</controller>
</objects>
<point key="canvasLocation" x="934" y="602"/>
<point key="canvasLocation" x="1460" y="602"/>
</scene>
</scenes>
<inferredMetricsTieBreakers>
Expand Down
@@ -0,0 +1,31 @@
//
// AvgUtilizationInterfaceController.swift
// SynchronyFinancial WatchKit Extension
//
// Created by Alan Maynard on 4/23/19.
// Copyright © 2019 Alan Maynard. All rights reserved.
//
import WatchKit
import Foundation


class AvgUtilizationInterfaceController: WKInterfaceController {

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

// Configure interface objects here.
}

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

}

This file was deleted.

@@ -0,0 +1,31 @@
//
// GoodAccountsInterfaceController.swift
// SynchronyFinancial WatchKit Extension
//
// Created by Alan Maynard on 4/23/19.
// Copyright © 2019 Alan Maynard. All rights reserved.
//
import WatchKit
import Foundation


class HealthyAccountsInterfaceController: WKInterfaceController {

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

// Configure interface objects here.
}

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

}
@@ -0,0 +1,31 @@
//
// LastPaymentInterfaceController.swift
// SynchronyFinancial WatchKit Extension
//
// Created by Alan Maynard on 4/23/19.
// Copyright © 2019 Alan Maynard. All rights reserved.
//
import WatchKit
import Foundation


class LastPaymentInterfaceController: WKInterfaceController {

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

// Configure interface objects here.
}

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

}
Expand Up @@ -15,7 +15,6 @@ class WellnessInterfaceController: WKInterfaceController {
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 All @@ -26,15 +25,6 @@ class WellnessInterfaceController: WKInterfaceController {
if let context = context as? [String: [Account]], let accts = context["accts"] {
accounts = accts
}
/*for index in 0..<accounts.count{
FetchData.fetchTransactionsFor(accountAlias: accounts[index].accountAlias) { transactions, error in
guard error == nil else {
NSLog("Error retrieving transactions for account.")
return
}
self.transactionDict.updateValue(self.transactions, forKey: "transactions")
}
}*/

calculateUtilization()
calculateWellness()
Expand Down Expand Up @@ -70,30 +60,18 @@ class WellnessInterfaceController: WKInterfaceController {

private func calculateWellness() {
let m1 = Double(utilizationScore) * 0.50
let m3 = Double(paymentScore) * 0.30
wellnessScore = Int(round(m1 + m3))
wellnessScore = Int(round(m1))
}

/*private func calculatePaymentsMissed() {
var lateCount: Int = 0
for index in 0..<accounts.count {
if let alias = selectedAccount?.accountAlias {
FetchData.fetchTransactionsFor(accountAlias: alias) { transactions, error in
guard error == nil else {
NSLog("Error retrieving transactions for account.")
return
}
self.transactionDict.updateValue(transactions, forKey: "transactions")
self.pushController(withName: "Transactions", context: self.transactionDict)
}
}
}
}*/

@IBAction func moreButtonTapped() {
let pages = ["UtilizationScore", "UtilizationTrend", "PaymentScore"]
let contexts: [Any] = [utilizationScore, [utilizationScore, previousUtil], paymentScore]
presentController(withNames: pages, contexts: contexts)
if accounts.count > 1 {
let pages = ["UtilizationScore", "UtilizationTrend", "AvgUtilization", "HealthyAccts"]
let contexts: [Any] = [utilizationScore, [utilizationScore, previousUtil], 35.5, 7]
presentController(withNames: pages, contexts: contexts)
} else {
let pages = ["UtilizationScore", "UtilizationTrend", "LastPayment"]
let contexts: [Any] = [utilizationScore, [utilizationScore, previousUtil], [10.00, 125.00]]
presentController(withNames: pages, contexts: contexts)
}
}
}

0 comments on commit ddbc228

Please sign in to comment.