Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
278 changes: 4 additions & 274 deletions Loop Status Extension/Base.lproj/MainInterface.storyboard

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Loop Status Extension/StatusExtensionContext.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import Foundation
import HealthKit
import LoopUI

struct ReservoirContext {
let startDate: Date
Expand Down
47 changes: 37 additions & 10 deletions Loop Status Extension/StatusViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,47 @@
// Copyright © 2016 LoopKit Authors. All rights reserved.
//

import UIKit
import NotificationCenter
import HealthKit
import CoreData
import HealthKit
import LoopUI
import NotificationCenter
import UIKit

class StatusViewController: UIViewController, NCWidgetProviding {

@IBOutlet weak var loopCompletionHUD: LoopCompletionHUDView!
@IBOutlet weak var glucoseHUD: GlucoseHUDView!
@IBOutlet weak var basalRateHUD: BasalRateHUDView!
@IBOutlet weak var reservoirVolumeHUD: ReservoirVolumeHUDView!
@IBOutlet weak var batteryHUD: BatteryLevelHUDView!

@IBOutlet weak var hudView: HUDView!
@IBOutlet weak var subtitleLabel: UILabel!


var loopCompletionHUD: LoopCompletionHUDView! {
get {
return hudView.loopCompletionHUD
}
}

var glucoseHUD: GlucoseHUDView! {
get {
return hudView.glucoseHUD
}
}

var basalRateHUD: BasalRateHUDView! {
get {
return hudView.basalRateHUD
}
}

var reservoirVolumeHUD: ReservoirVolumeHUDView! {
get {
return hudView.reservoirVolumeHUD
}
}

var batteryHUD: BatteryLevelHUDView! {
get {
return hudView.batteryHUD
}
}

override func viewDidLoad() {
super.viewDidLoad()
subtitleLabel.alpha = 0
Expand Down
340 changes: 262 additions & 78 deletions Loop.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

345 changes: 67 additions & 278 deletions Loop/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Loop/Managers/DeviceDataManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import GlucoseKit
import HealthKit
import InsulinKit
import LoopKit
import LoopUI
import MinimedKit
import NightscoutUploadKit
import RileyLinkKit
Expand Down
2 changes: 1 addition & 1 deletion Loop/Managers/WatchDataManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ final class WatchDataManager: NSObject, WCSessionDelegate {
context.maxBolus = maxBolus

if let trend = self.deviceDataManager.sensorInfo?.trendType {
context.glucoseTrend = trend
context.glucoseTrendRawValue = trend.rawValue
}

completionHandler(context)
Expand Down
9 changes: 5 additions & 4 deletions Loop/Models/Glucose.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,16 @@
//

import Foundation
import LoopUI
import xDripG5


extension Glucose: SensorDisplayable {
var isStateValid: Bool {
public var isStateValid: Bool {
return state == .ok && status == .ok
}

var stateDescription: String {
public var stateDescription: String {
let status: String
switch self.status {
case .ok:
Expand All @@ -29,7 +30,7 @@ extension Glucose: SensorDisplayable {
return String(format: "%1$@ %2$@", String(describing: state), status)
}

var trendType: GlucoseTrend? {
public var trendType: GlucoseTrend? {
guard trend < Int(Int8.max) else {
return nil
}
Expand All @@ -52,7 +53,7 @@ extension Glucose: SensorDisplayable {
}
}

var isLocal: Bool {
public var isLocal: Bool {
return true
}
}
9 changes: 5 additions & 4 deletions Loop/Models/GlucoseG4.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import Foundation
import G4ShareSpy
import HealthKit
import LoopKit
import LoopUI


extension GlucoseG4: GlucoseValue {
Expand All @@ -24,23 +25,23 @@ extension GlucoseG4: GlucoseValue {


extension GlucoseG4: SensorDisplayable {
var isStateValid: Bool {
public var isStateValid: Bool {
return glucose >= 20
}

var stateDescription: String {
public var stateDescription: String {
if isStateValid {
return NSLocalizedString("OK", comment: "Sensor state description for the valid state")
} else {
return NSLocalizedString("Needs Attention", comment: "Sensor state description for the non-valid state")
}
}

var trendType: GlucoseTrend? {
public var trendType: GlucoseTrend? {
return GlucoseTrend(rawValue: Int(trend))
}

var isLocal: Bool {
public var isLocal: Bool {
return true
}
}
7 changes: 4 additions & 3 deletions Loop/Models/MySentryPumpStatusMessageBody.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@
//

import LoopKit
import LoopUI
import MinimedKit


extension MySentryPumpStatusMessageBody: SensorDisplayable {
var isStateValid: Bool {
public var isStateValid: Bool {
switch glucose {
case .active, .off:
return true
Expand All @@ -20,7 +21,7 @@ extension MySentryPumpStatusMessageBody: SensorDisplayable {
}
}

var trendType: GlucoseTrend? {
public var trendType: LoopUI.GlucoseTrend? {
guard case .active = glucose else {
return nil
}
Expand All @@ -39,7 +40,7 @@ extension MySentryPumpStatusMessageBody: SensorDisplayable {
}
}

var isLocal: Bool {
public var isLocal: Bool {
return true
}

Expand Down
17 changes: 14 additions & 3 deletions Loop/Models/ShareGlucose+GlucoseKit.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import Foundation
import HealthKit
import LoopKit
import LoopUI
import ShareClient


Expand All @@ -24,15 +25,25 @@ extension ShareGlucose: GlucoseValue {


extension ShareGlucose: SensorDisplayable {
var isStateValid: Bool {
public var isStateValid: Bool {
return glucose >= 20
}

var trendType: GlucoseTrend? {
public var trendType: GlucoseTrend? {
return GlucoseTrend(rawValue: Int(trend))
}

var isLocal: Bool {
public var isLocal: Bool {
return false
}
}

extension SensorDisplayable {
public var stateDescription: String {
if isStateValid {
return NSLocalizedString("OK", comment: "Sensor state description for the valid state")
} else {
return NSLocalizedString("Needs Attention", comment: "Sensor state description for the non-valid state")
}
}
}
41 changes: 32 additions & 9 deletions Loop/View Controllers/StatusTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import GlucoseKit
import HealthKit
import InsulinKit
import LoopKit
import LoopUI
import SwiftCharts


Expand Down Expand Up @@ -759,18 +760,28 @@ final class StatusTableViewController: UITableViewController, UIGestureRecognize

// MARK: - HUDs

@IBOutlet weak var loopCompletionHUD: LoopCompletionHUDView!

@IBOutlet weak var glucoseHUD: GlucoseHUDView! {
@IBOutlet weak var hudView: HUDView! {
didSet {
let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(openCGMApp(_:)))
glucoseHUD.addGestureRecognizer(tapGestureRecognizer)

if cgmAppURL != nil {
glucoseHUD.accessibilityHint = NSLocalizedString("Launches CGM app", comment: "Glucose HUD accessibility hint")
}
}
}

var loopCompletionHUD: LoopCompletionHUDView! {
get {
return hudView.loopCompletionHUD
}
}

var glucoseHUD: GlucoseHUDView! {
get {
return hudView.glucoseHUD
}
}

private var cgmAppURL: URL? {
if let url = URL(string: "dexcomcgm://"), UIApplication.shared.canOpenURL(url) {
Expand All @@ -788,9 +799,21 @@ final class StatusTableViewController: UITableViewController, UIGestureRecognize
}
}

@IBOutlet weak var basalRateHUD: BasalRateHUDView!

@IBOutlet weak var reservoirVolumeHUD: ReservoirVolumeHUDView!

@IBOutlet weak var batteryLevelHUD: BatteryLevelHUDView!
var basalRateHUD: BasalRateHUDView! {
get {
return hudView.basalRateHUD
}
}

var reservoirVolumeHUD: ReservoirVolumeHUDView! {
get {
return hudView.reservoirVolumeHUD
}
}

var batteryLevelHUD: BatteryLevelHUDView! {
get {
return hudView.batteryHUD
}
}
}
14 changes: 9 additions & 5 deletions Loop/Views/ButtonTableViewCell.xib
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="10117" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="11542" systemVersion="16B2657" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES">
<device id="retina4_7" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="10085"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="11524"/>
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<objects>
<placeholder placeholderIdentifier="IBFilesOwner" id="-1" userLabel="File's Owner"/>
Expand All @@ -12,11 +16,11 @@
<rect key="frame" x="0.0" y="0.0" width="427" height="44"/>
<autoresizingMask key="autoresizingMask"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="QMd-B1-jne" id="T9r-tL-wAO">
<rect key="frame" x="0.0" y="0.0" width="427" height="43.5"/>
<rect key="frame" x="0.0" y="0.0" width="427" height="43"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="oI5-48-SHZ">
<rect key="frame" x="181.5" y="8" width="64" height="27"/>
<rect key="frame" x="182" y="8" width="64" height="27"/>
<constraints>
<constraint firstAttribute="width" relation="greaterThanOrEqual" constant="64" id="hrG-HQ-FHS"/>
</constraints>
Expand Down
6 changes: 6 additions & 0 deletions LoopUI/Assets.xcassets/reservoir/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import HealthKit
// Code in this extension is duplicated from:
// https://github.com/LoopKit/LoopKit/blob/master/LoopKit/HKUnit.swift
// to avoid pulling in the LoopKit extension since it's not extension-API safe.
public extension HKUnit {
extension HKUnit {
// A formatting helper for determining the preferred decimal style for a given unit
var preferredMinimumFractionDigits: Int {
if self.unitString == "mg/dL" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import HealthKit


extension NumberFormatter {
static func glucoseFormatter(for unit: HKUnit) -> NumberFormatter {
public static func glucoseFormatter(for unit: HKUnit) -> NumberFormatter {
let numberFormatter = NumberFormatter()
numberFormatter.numberStyle = .decimal
numberFormatter.minimumFractionDigits = unit.preferredMinimumFractionDigits
Expand Down
26 changes: 13 additions & 13 deletions Loop/Extensions/UIColor.swift → LoopUI/Extensions/UIColor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@ import UIKit


extension UIColor {
@nonobjc static var tintColor: UIColor? = nil
@nonobjc public static var tintColor: UIColor? = nil

@nonobjc static let secondaryLabelColor = UIColor.HIGGrayColor()
@nonobjc public static let secondaryLabelColor = UIColor.HIGGrayColor()

@nonobjc static let cellBackgroundColor = UIColor(white: 239 / 255, alpha: 1)
@nonobjc public static let cellBackgroundColor = UIColor(white: 239 / 255, alpha: 1)

@nonobjc static let gridColor = UIColor(white: 193 / 255, alpha: 1)
@nonobjc public static let gridColor = UIColor(white: 193 / 255, alpha: 1)

@nonobjc static let glucoseTintColor = UIColor(red: 0 / 255, green: 176 / 255, blue: 255 / 255, alpha: 1)
@nonobjc public static let glucoseTintColor = UIColor(red: 0 / 255, green: 176 / 255, blue: 255 / 255, alpha: 1)

@nonobjc static let IOBTintColor = UIColor.HIGOrangeColor()
@nonobjc public static let IOBTintColor = UIColor.HIGOrangeColor()

@nonobjc static let COBTintColor = UIColor(red: 99 / 255, green: 218 / 255, blue: 56 / 255, alpha: 1)
@nonobjc public static let COBTintColor = UIColor(red: 99 / 255, green: 218 / 255, blue: 56 / 255, alpha: 1)

@nonobjc static let doseTintColor = UIColor.HIGOrangeColor()
@nonobjc public static let doseTintColor = UIColor.HIGOrangeColor()

@nonobjc static let freshColor = UIColor.HIGGreenColor()
@nonobjc public static let freshColor = UIColor.HIGGreenColor()

@nonobjc static let agingColor = UIColor.HIGYellowColor()
@nonobjc public static let agingColor = UIColor.HIGYellowColor()

@nonobjc static let staleColor = UIColor.HIGRedColor()
@nonobjc public static let staleColor = UIColor.HIGRedColor()

@nonobjc static let unknownColor = UIColor(red: 198 / 255, green: 199 / 255, blue: 201 / 255, alpha: 1)
@nonobjc public static let unknownColor = UIColor(red: 198 / 255, green: 199 / 255, blue: 201 / 255, alpha: 1)

@nonobjc static let deleteColor = UIColor.HIGRedColor()
@nonobjc public static let deleteColor = UIColor.HIGRedColor()

// MARK: - HIG colors
// See: https://developer.apple.com/ios/human-interface-guidelines/visual-design/color/
Expand Down
Loading