Skip to content

Commit a3558d4

Browse files
Bharat Medirattaps2
authored andcommitted
Refactor HUD views into LoopUI framework (#284) (#330)
* Rough cut at moving HUD views into their own framework. * Move view code into the HUDViewKit framework directory * Remove HUDViewKit * Add GlucoseTrend and NSTimeInterval directly to WatchApp Extension so that it doesn't have to pull in HUDViewKit * Get all targets to compile with HUDViewKit 1. Make HKUnit extension internal and included it directly into all necessary targets to avoid a conflict with the same extension in LoopKit 2. Publicize any necessary HUDViewKit vars, funcs 3. Store the Int raw value for GlucoseTrend in WatchContext and create a computed property that returns it as a GlucoseTrend object to avoid the conflict where both Loop and WatchApp Extension have their own separate concept of GlucoseTrend. * Rename HUDViewKit to LoopUI * partway through moving layout * WIP * Resize stack view to fill container view * Embed LoopUI framework * Use NibLoadable for HUDView
1 parent 0b7afad commit a3558d4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+898
-733
lines changed

Loop Status Extension/Base.lproj/MainInterface.storyboard

Lines changed: 4 additions & 274 deletions
Large diffs are not rendered by default.

Loop Status Extension/StatusExtensionContext.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
import Foundation
1111
import HealthKit
12+
import LoopUI
1213

1314
struct ReservoirContext {
1415
let startDate: Date

Loop Status Extension/StatusViewController.swift

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,47 @@
66
// Copyright © 2016 LoopKit Authors. All rights reserved.
77
//
88

9-
import UIKit
10-
import NotificationCenter
11-
import HealthKit
129
import CoreData
10+
import HealthKit
11+
import LoopUI
12+
import NotificationCenter
13+
import UIKit
1314

1415
class StatusViewController: UIViewController, NCWidgetProviding {
15-
16-
@IBOutlet weak var loopCompletionHUD: LoopCompletionHUDView!
17-
@IBOutlet weak var glucoseHUD: GlucoseHUDView!
18-
@IBOutlet weak var basalRateHUD: BasalRateHUDView!
19-
@IBOutlet weak var reservoirVolumeHUD: ReservoirVolumeHUDView!
20-
@IBOutlet weak var batteryHUD: BatteryLevelHUDView!
16+
17+
@IBOutlet weak var hudView: HUDView!
2118
@IBOutlet weak var subtitleLabel: UILabel!
22-
19+
20+
var loopCompletionHUD: LoopCompletionHUDView! {
21+
get {
22+
return hudView.loopCompletionHUD
23+
}
24+
}
25+
26+
var glucoseHUD: GlucoseHUDView! {
27+
get {
28+
return hudView.glucoseHUD
29+
}
30+
}
31+
32+
var basalRateHUD: BasalRateHUDView! {
33+
get {
34+
return hudView.basalRateHUD
35+
}
36+
}
37+
38+
var reservoirVolumeHUD: ReservoirVolumeHUDView! {
39+
get {
40+
return hudView.reservoirVolumeHUD
41+
}
42+
}
43+
44+
var batteryHUD: BatteryLevelHUDView! {
45+
get {
46+
return hudView.batteryHUD
47+
}
48+
}
49+
2350
override func viewDidLoad() {
2451
super.viewDidLoad()
2552
subtitleLabel.alpha = 0

Loop.xcodeproj/project.pbxproj

Lines changed: 262 additions & 78 deletions
Large diffs are not rendered by default.

Loop/Base.lproj/Main.storyboard

Lines changed: 67 additions & 278 deletions
Large diffs are not rendered by default.

Loop/Managers/DeviceDataManager.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import GlucoseKit
1414
import HealthKit
1515
import InsulinKit
1616
import LoopKit
17+
import LoopUI
1718
import MinimedKit
1819
import NightscoutUploadKit
1920
import RileyLinkKit

Loop/Managers/WatchDataManager.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ final class WatchDataManager: NSObject, WCSessionDelegate {
118118
context.maxBolus = maxBolus
119119

120120
if let trend = self.deviceDataManager.sensorInfo?.trendType {
121-
context.glucoseTrend = trend
121+
context.glucoseTrendRawValue = trend.rawValue
122122
}
123123

124124
completionHandler(context)

Loop/Models/Glucose.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77
//
88

99
import Foundation
10+
import LoopUI
1011
import xDripG5
1112

1213

1314
extension Glucose: SensorDisplayable {
14-
var isStateValid: Bool {
15+
public var isStateValid: Bool {
1516
return state == .ok && status == .ok
1617
}
1718

18-
var stateDescription: String {
19+
public var stateDescription: String {
1920
let status: String
2021
switch self.status {
2122
case .ok:
@@ -29,7 +30,7 @@ extension Glucose: SensorDisplayable {
2930
return String(format: "%1$@ %2$@", String(describing: state), status)
3031
}
3132

32-
var trendType: GlucoseTrend? {
33+
public var trendType: GlucoseTrend? {
3334
guard trend < Int(Int8.max) else {
3435
return nil
3536
}
@@ -52,7 +53,7 @@ extension Glucose: SensorDisplayable {
5253
}
5354
}
5455

55-
var isLocal: Bool {
56+
public var isLocal: Bool {
5657
return true
5758
}
5859
}

Loop/Models/GlucoseG4.swift

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import Foundation
1010
import G4ShareSpy
1111
import HealthKit
1212
import LoopKit
13+
import LoopUI
1314

1415

1516
extension GlucoseG4: GlucoseValue {
@@ -24,23 +25,23 @@ extension GlucoseG4: GlucoseValue {
2425

2526

2627
extension GlucoseG4: SensorDisplayable {
27-
var isStateValid: Bool {
28+
public var isStateValid: Bool {
2829
return glucose >= 20
2930
}
3031

31-
var stateDescription: String {
32+
public var stateDescription: String {
3233
if isStateValid {
3334
return NSLocalizedString("OK", comment: "Sensor state description for the valid state")
3435
} else {
3536
return NSLocalizedString("Needs Attention", comment: "Sensor state description for the non-valid state")
3637
}
3738
}
3839

39-
var trendType: GlucoseTrend? {
40+
public var trendType: GlucoseTrend? {
4041
return GlucoseTrend(rawValue: Int(trend))
4142
}
4243

43-
var isLocal: Bool {
44+
public var isLocal: Bool {
4445
return true
4546
}
4647
}

Loop/Models/MySentryPumpStatusMessageBody.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,12 @@
77
//
88

99
import LoopKit
10+
import LoopUI
1011
import MinimedKit
1112

1213

1314
extension MySentryPumpStatusMessageBody: SensorDisplayable {
14-
var isStateValid: Bool {
15+
public var isStateValid: Bool {
1516
switch glucose {
1617
case .active, .off:
1718
return true
@@ -20,7 +21,7 @@ extension MySentryPumpStatusMessageBody: SensorDisplayable {
2021
}
2122
}
2223

23-
var trendType: GlucoseTrend? {
24+
public var trendType: LoopUI.GlucoseTrend? {
2425
guard case .active = glucose else {
2526
return nil
2627
}
@@ -39,7 +40,7 @@ extension MySentryPumpStatusMessageBody: SensorDisplayable {
3940
}
4041
}
4142

42-
var isLocal: Bool {
43+
public var isLocal: Bool {
4344
return true
4445
}
4546

0 commit comments

Comments
 (0)