Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
SWF-17 More wellness implementation and improvements
- added static defaults for the “blurbs” used to describe wellness metrics
- used these in our new and existing metrics descriptions
- implemented passing of values to `AvgUtilization` and `HealthyAccounts` metrics
- set up calculation for these metrics in Wellness as well
  • Loading branch information
ahm11003 committed Apr 23, 2019
1 parent d170909 commit 433ebac
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 36 deletions.
Expand Up @@ -464,7 +464,7 @@
<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"/>
<imageView width="1" height="93" alignment="center" verticalAlignment="center" contentMode="scaleAspectFit" id="JDC-go-3sn"/>
<button width="1" alignment="left" verticalAlignment="bottom" title="Button" id="JxL-nb-z6E">
<connections>
<action selector="showDetails" destination="WY4-SK-U7W" id="Hie-sR-PE3"/>
Expand Down Expand Up @@ -492,7 +492,7 @@
</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">
<label width="0.5" height="1" alignment="center" alpha="0.0" 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>
Expand Down
Expand Up @@ -9,26 +9,33 @@
import WatchKit
import Foundation


class AvgUtilizationInterfaceController: WKInterfaceController {

@IBOutlet var avgUtilizationChart: WKInterfaceImage!

var didAnimate: Bool = false
var average: Double = 0.0
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()
guard let avg = context as? Double else {
NSLog("Error getting average utilization.")
return
}
average = avg
}

override func didDeactivate() {
// This method is called when watch view controller is no longer visible
super.didDeactivate()
override func didAppear() {
if !didAnimate {
avgUtilizationChart.setImageNamed("scores")
if average < 1.0 {
avgUtilizationChart.startAnimatingWithImages(in: NSRange(location: 0, length: 1), duration: 1, repeatCount: 1)
} else {
avgUtilizationChart.startAnimatingWithImages(in: NSRange(location: 1, length: Int(average)), duration: 1, repeatCount: 1)
}
didAnimate = true
}
}

@IBAction func showDetails() {
presentAlert(withTitle: "Average Utilization", message: Defaults.AVG_UTIL, preferredStyle: .alert, actions: [WKAlertAction(title: "Done", style: .default, handler: {})])
}
}
Expand Up @@ -9,26 +9,27 @@
import WatchKit
import Foundation


class HealthyAccountsInterfaceController: WKInterfaceController {

@IBOutlet var healthyCountLabel: WKInterfaceLabel!

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

// Configure interface objects here.
}
guard let data = context as? Int else {
NSLog("Error getting healthy account count.")
return
}

override func willActivate() {
// This method is called when watch view controller is about to be visible to user
super.willActivate()
healthyCountLabel.setText("\(data)")
}

override func didDeactivate() {
// This method is called when watch view controller is no longer visible
super.didDeactivate()
override func didAppear() {
super.didAppear()
animate(withDuration: 1.5) {
self.healthyCountLabel.setAlpha(1.0)
}
}

@IBAction func showDetails() {
presentAlert(withTitle: "Healthy Accounts", message: Defaults.HEALTHY_ACCTS, preferredStyle: .alert, actions: [WKAlertAction(title: "Done", style: .default, handler: {})])
}

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


class LastPaymentInterfaceController: WKInterfaceController {

@IBOutlet var descriptionLabel: WKInterfaceLabel!
@IBOutlet var valueLabel: WKInterfaceLabel!

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

// Configure interface objects here.
}

Expand All @@ -31,5 +29,6 @@ class LastPaymentInterfaceController: WKInterfaceController {
}

@IBAction func showDetails() {
presentAlert(withTitle: "Last Payment", message: Defaults.LAST_PAYMENT, preferredStyle: .alert, actions: [WKAlertAction(title: "Done", style: .default, handler: {})])
}
}
Expand Up @@ -54,6 +54,6 @@ class UtilizationTrendInterfaceController: WKInterfaceController {
}

@IBAction func showDetails() {
presentAlert(withTitle: "Trends", message: "Lowering your utilization over time can help reduce the amount of interest accrued on your accounts.", preferredStyle: .alert, actions: [WKAlertAction(title: "Done", style: .default, handler: {})])
presentAlert(withTitle: "Trends", message: Defaults.UTIL_TRENDS, preferredStyle: .alert, actions: [WKAlertAction(title: "Done", style: .default, handler: {})])
}
}
Expand Up @@ -65,6 +65,6 @@ class UtilizationInterfaceController: WKInterfaceController {
}

@IBAction func showDetails() {
presentAlert(withTitle: "Utilization Details", message: "Credit utilization is the ratio of credit used compared to total credit. Ideally, this value should be 20% or below.", preferredStyle: .alert, actions: [WKAlertAction(title: "Done", style: .default, handler: {})])
presentAlert(withTitle: "Utilization Details", message: Defaults.UTIL, preferredStyle: .alert, actions: [WKAlertAction(title: "Done", style: .default, handler: {})])
}
}
17 changes: 12 additions & 5 deletions SynchronyFinancial/SynchronyFinancial/Defaults.swift
Expand Up @@ -22,6 +22,13 @@ final class Defaults {
static let token = UserDefaults.standard.string(forKey: "access_token") ?? ""
static let authHeader = ["Authorization": "Bearer \(token)"]

// MARK: - Wellness Detail Blurbs
static let UTIL = "Credit utilization is the ratio of credit used compared to total credit. Ideally, this value should be 30% or below."
static let UTIL_TRENDS = "Lowering your utilization over time can help reduce the amount of interest accrued on your accounts."
static let AVG_UTIL = "Average Utilization shows the mean credit utilization across all of your CareCredit accounts"
static let LAST_PAYMENT = "Making monthly payments at this rate (excluding interests), you can eliminate your balance in the noted time period."
static let HEALTHY_ACCTS = "Healthy accounts shows how many of your CareCredit accounts stand with a utilization at 30% or below."

static let careCreditDateFormatter: DateFormatter = {
var formatter = DateFormatter()
formatter.dateFormat = "yyyyMMdd"
Expand All @@ -40,13 +47,13 @@ final class Defaults {
"mobile_longitude": 0.0],
"password": "Test12test",
"scope": "default",
"username": "carecredit"]
"username": "hhgregg2088"]
}()

// this header is used for multi-account and fetch banks resources
static var headerForMulti: [String: Any] = {
return ["header": defaultHeader,
"username": "carecredit"]
"username": "hhgregg2088"]
}()

static var headerForTransaction: [String: Any] = {
Expand All @@ -65,7 +72,7 @@ final class Defaults {
"header": defaultHeader,
"scope_indicator": "B",
"start_date": start_date,
"username": "carecredit"]
"username": "hhgregg2088"]
}()

static var headerForCancelPmt: [String: Any] = {
Expand All @@ -83,7 +90,7 @@ final class Defaults {
"scope_indicator": "B",
"payment_confirmation_number": pmt_confirmation,
"payment_id": payment_id,
"username": "carecredit"]
"username": "hhgregg2088"]
}()

static var headerForPmt: [String: Any] = {
Expand All @@ -99,6 +106,6 @@ final class Defaults {
"payment_amount": 123.45,
"payment_amount_type": "CBL",
"scheduled_payment_post_date": "20190306",
"username": "carecredit"]
"username": "hhgregg2088"]
}()
}

0 comments on commit 433ebac

Please sign in to comment.