Skip to content

Swf 17 credit health #17

Merged
merged 26 commits into from May 1, 2019
Merged
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
38a78cf
radial progress indicators and page-based nav
ahm11003 Feb 13, 2019
5d7cb80
Added Balance, Utilization, and AccountNumber Controllers. Added PLis…
Mar 6, 2019
10e6442
PList Functions
ahm11003 Mar 6, 2019
c212e13
Merge pull request #5 from rrk12005/demo-radial-style-progress-indica…
jod13004 Mar 6, 2019
83e5766
Added Utilization score calculation
Mar 28, 2019
3be3eef
Renamed files to more accurately represent them. Changed wellness rad…
Mar 29, 2019
5a821f7
no message
Mar 29, 2019
a2f3c9d
Merge branch 'master' into SWF-17-credit-health
ahm11003 Apr 9, 2019
9303329
- Functions for utilization and account (temporary) metrics.
Apr 11, 2019
3599c77
SWF-17 remove storyboard segue
ahm11003 Apr 11, 2019
2c07f8e
SWF-17 pass our metrics to page hierarchy
ahm11003 Apr 11, 2019
416c2ea
SWF-17 credit utilization improvements
ahm11003 Apr 17, 2019
3e7ddcd
SWE-17 remove unused classes and files
ahm11003 Apr 17, 2019
8e8dec7
SWF-17 fix logical error leading to bad utilization score
ahm11003 Apr 17, 2019
a5c4ac1
SWF-17 remove unused class
ahm11003 Apr 17, 2019
85fd3e2
SWF-17 new class to display trends in credit utilization
ahm11003 Apr 17, 2019
4f67b56
SWF-17 new image assets, implementation for utilization trend
ahm11003 Apr 17, 2019
23fb930
SWF-17 Added basic details for utilization trends
ahm11003 Apr 17, 2019
80acdbf
Merge branch 'master' into SWF-17-credit-health
ahm11003 Apr 17, 2019
ddbc228
SWF-17 More wellness implementation
ahm11003 Apr 23, 2019
4a55d89
SWF-17 more wellness configuration
ahm11003 Apr 23, 2019
d170909
SWF-17 remove unused code
ahm11003 Apr 23, 2019
433ebac
SWF-17 More wellness implementation and improvements
ahm11003 Apr 23, 2019
17dd1df
SWF-17 metric calculations
ahm11003 Apr 23, 2019
a949599
SWF-17 clean up how we receive data for utilization
ahm11003 Apr 23, 2019
f84701b
SWF-17 new image assets, wellness calculation
ahm11003 Apr 24, 2019
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.
+53 −47
Diff settings

Always

Just for now

PList Functions

- change plist structure to array for easier reading from plist
- populate radial indicators with values
- set up check to only animate once
  • Loading branch information...
ahm11003 committed Mar 6, 2019
commit 10e6442e7c6b2ba612a49a951c410156233bc071
@@ -1,24 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Account1</key>
<array>
<array>
<integer>2000</integer>
<integer>8000</integer>
<integer>2</integer>
</array>
<key>Account2</key>
<array>
<integer>1300</integer>
<real>5000</real>
<integer>5</integer>
</array>
<key>Account 3</key>
<array>
<integer>4000</integer>
<integer>10000</integer>
<integer>3</integer>
</array>
</dict>
</array>
</plist>
@@ -11,20 +11,27 @@ import Foundation


class BalanceInterfaceController: WKInterfaceController {
var util: Int?
var didAnimate: Bool = false

@IBOutlet weak var image2: WKInterfaceImage!
override func awake(withContext context: Any?) {
super.awake(withContext: context)

// get plist data to generate balance metric
var plistValues = PlistUtil.readPlist(for: .balance)
let balance = plistValues[0][0]
let credit = plistValues[0][1] > 0 ? plistValues[0][1] : 1

util = Int(round((Double(balance)/Double(credit)) * 100))
}

override func didAppear() {
// Called when watch interface is visible to user
/*var plistValues = [String]()
plistValues = PlistUtil.readPlist(namePlist: "PropertyList", key: "Account1")
let balance: Int = Int(plistValues[0])!
let credit: Int = Int(plistValues[1])!
let util = (balance/credit * 10)*/
image2.setImageNamed("scores")
image2.startAnimatingWithImages(in: NSRange(location: 0, length: 66), duration: 1.5, repeatCount: 1)
if !didAnimate {
image2.startAnimatingWithImages(in: NSRange(location: 0, length: util ?? 0), duration: 1.5, repeatCount: 1)
didAnimate = true
}
//image2.stopAnimating()
}

@@ -8,36 +8,27 @@
import Foundation

public enum PlistDataType: String {
case balance = "BalanceInfo"
case transaction = "Transcation"
case account = "Account"
}

class PlistUtil {

static func readPlist(namePlist: String, key: String) -> [String]{
let paths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true) as NSArray
let documentsDirectory = paths.object(at: 0) as! NSString
let path = documentsDirectory.appendingPathComponent(namePlist+".plist")

var output:AnyObject = false as AnyObject

if let dict = NSMutableDictionary(contentsOfFile: path){
output = dict.object(forKey: key)! as AnyObject
}else{
if let privPath = Bundle.main.path(forResource: namePlist, ofType: "plist"){
if let dict = NSMutableDictionary(contentsOfFile: privPath){
output = dict.object(forKey: key)! as AnyObject
}else{
output = false as AnyObject
print("error_read")
}
}else{
output = false as AnyObject
print("error_read")
static func readPlist(for data: PlistDataType) -> [[Int]] {
var balances = [[Int]]()
if let file = Bundle.main.path(forResource: data.rawValue, ofType: "plist"),
let array = NSArray.init(contentsOfFile: file) {
array.forEach {
guard let balance = $0 as? [AnyHashable],
let b = balance[0] as? Int,
let credit = balance[1] as? Int,
let age = balance[2] as? Int else { return }
balances.append([b, credit, age])
}
}
print("plist_read \(output)")
return output as! [String]

return balances
}


}

/*Borrowed from
https://github.com/soonin/IOS-Swift-PlistReadAndWrite/blob/master/IOS-Swift-PlistReadAndWrite/PlistReadAndWrite.swift */
@@ -9,18 +9,29 @@
import WatchKit
import Foundation


class UtilizationInterfaceController: WKInterfaceController {
var didAnimate: Bool = false
var util: Int?

@IBOutlet weak var image3: WKInterfaceImage!

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

// get plist data to generate utilization metric
var plistValues = PlistUtil.readPlist(for: .balance)
let balance = plistValues[0][0]
let credit = plistValues[0][1] > 0 ? plistValues[0][1] : 1

util = Int(round((Double(balance)/Double(credit)) * 100))
}

override func didAppear() {
// Called when watch interface is visible to user
image3.setImageNamed("scores")
image3.startAnimatingWithImages(in: NSRange(location: 0, length: 46), duration: 1.5, repeatCount: 1)
if !didAnimate {
image3.setImageNamed("scores")
image3.startAnimatingWithImages(in: NSRange(location: 1, length: util ?? 0), duration: 1.5, repeatCount: 1)
didAnimate = true
}
}

override func willActivate() {
@@ -26,7 +26,7 @@
67C8DD8321ED323B0063A01B /* CircleIndicator.sks in Resources */ = {isa = PBXBuildFile; fileRef = 67C8DD8221ED323B0063A01B /* CircleIndicator.sks */; };
67C8DD8521ED3B5A0063A01B /* WellnessInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 67C8DD8421ED3B5A0063A01B /* WellnessInterfaceController.swift */; };
9BCE39732227138E00B7A992 /* BalanceInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BCE39722227138E00B7A992 /* BalanceInterfaceController.swift */; };
9BCE39752227712500B7A992 /* Property List.plist in Resources */ = {isa = PBXBuildFile; fileRef = 9BCE39742227712500B7A992 /* Property List.plist */; };
9BCE39752227712500B7A992 /* BalanceInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 9BCE39742227712500B7A992 /* BalanceInfo.plist */; };
9BCE39772227731800B7A992 /* UtilizationfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BCE39762227731800B7A992 /* UtilizationfaceController.swift */; };
9BCE39792227839B00B7A992 /* AccountNumberInterfaceController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BCE39782227839B00B7A992 /* AccountNumberInterfaceController.swift */; };
9BCE397D222F5A2800B7A992 /* PlistUtil.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9BCE397C222F5A2800B7A992 /* PlistUtil.swift */; };
@@ -99,7 +99,7 @@
67C8DD8221ED323B0063A01B /* CircleIndicator.sks */ = {isa = PBXFileReference; lastKnownFileType = file.sks; path = CircleIndicator.sks; sourceTree = "<group>"; };
67C8DD8421ED3B5A0063A01B /* WellnessInterfaceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WellnessInterfaceController.swift; sourceTree = "<group>"; };
9BCE39722227138E00B7A992 /* BalanceInterfaceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BalanceInterfaceController.swift; sourceTree = "<group>"; };
9BCE39742227712500B7A992 /* Property List.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Property List.plist"; sourceTree = "<group>"; };
9BCE39742227712500B7A992 /* BalanceInfo.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = BalanceInfo.plist; sourceTree = "<group>"; };
9BCE39762227731800B7A992 /* UtilizationfaceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UtilizationfaceController.swift; sourceTree = "<group>"; };
9BCE39782227839B00B7A992 /* AccountNumberInterfaceController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AccountNumberInterfaceController.swift; sourceTree = "<group>"; };
9BCE397C222F5A2800B7A992 /* PlistUtil.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PlistUtil.swift; sourceTree = "<group>"; };
@@ -192,7 +192,7 @@
9BCE397C222F5A2800B7A992 /* PlistUtil.swift */,
67BAC291219E254900713FEF /* Assets.xcassets */,
67BAC293219E254900713FEF /* Info.plist */,
9BCE39742227712500B7A992 /* Property List.plist */,
9BCE39742227712500B7A992 /* BalanceInfo.plist */,
);
path = "SynchronyFinancial WatchKit Extension";
sourceTree = "<group>";
@@ -335,7 +335,7 @@
isa = PBXResourcesBuildPhase;
buildActionMask = 2147483647;
files = (
9BCE39752227712500B7A992 /* Property List.plist in Resources */,
9BCE39752227712500B7A992 /* BalanceInfo.plist in Resources */,
67BAC292219E254900713FEF /* Assets.xcassets in Resources */,
67C8DD8321ED323B0063A01B /* CircleIndicator.sks in Resources */,
);
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.