Skip to content
Permalink
4f67b56ea0
Switch branches/tags

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?
Go to file
 
 
Cannot retrieve contributors at this time
56 lines (48 sloc) 1.66 KB
//
// UtilizationTrendInterfaceController.swift
// SynchronyFinancial WatchKit Extension
//
// Created by Alan Maynard on 4/17/19.
// Copyright © 2019 Alan Maynard. All rights reserved.
//
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)
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 didAppear() {
// This method is called when watch view controller is about to be visible to user
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.")
}
}
}
}