Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
SynchronyFinancialWatchApp/SynchronyFinancial/SynchronyFinancial WatchKit Extension/UtilizationfaceController.swift
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
70 lines (60 sloc)
2.23 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// BalanceInterfaceController.swift | |
// SynchronyFinancial WatchKit Extension | |
// | |
// Created by Jonathan Duarte on 2/18/19. | |
// Copyright © 2019 Alan Maynard. All rights reserved. | |
// | |
import WatchKit | |
import Foundation | |
class UtilizationInterfaceController: WKInterfaceController { | |
var didAnimate: Bool = false | |
var util: Double = 0 | |
var score: Int? | |
@IBOutlet weak var image3: WKInterfaceImage! | |
override func awake(withContext context: Any?) { | |
super.awake(withContext: context) | |
// resize according to screen size so we can display button below | |
image3.setHeight(contentFrame.height / 2) | |
image3.setWidth(contentFrame.height / 2) | |
image3.setHorizontalAlignment(.center) | |
score = context as? Int | |
// 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 = round((Double(balance)/Double(credit)) * 100) | |
switch util { | |
case 0...10: | |
score = 100 | |
case 11...20: | |
score = Int(round((100 - util) * 0.9)) | |
case 21...30: | |
score = Int(round((100 - util) * 0.85)) | |
case 31...60: | |
score = Int(round((100 - util) * 0.725)) | |
case 61...90: | |
score = Int(round((100 - util) * 0.6)) | |
default: | |
score = 1 | |
}*/ | |
} | |
override func didAppear() { | |
if !didAnimate { | |
image3.setImageNamed("scores") | |
image3.startAnimatingWithImages(in: NSRange(location: 1, length: score ?? 0), duration: 1.5, repeatCount: 1) | |
didAnimate = true | |
} | |
} | |
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() | |
} | |
@IBAction func showDetails() { | |
presentAlert(withTitle: "Utilization Details", message: Defaults.UTIL, preferredStyle: .alert, actions: [WKAlertAction(title: "Done", style: .default, handler: {})]) | |
} | |
} |