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
16 changes: 8 additions & 8 deletions Loop Status Extension/Base.lproj/MainInterface.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,17 @@
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="QEK-eF-fK6">
<rect key="frame" x="8" y="0.0" width="359" height="220"/>
<subviews>
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="d8d-rW-z8J" customClass="HUDView" customModule="LoopUI">
<view contentMode="scaleToFill" verticalHuggingPriority="252" translatesAutoresizingMaskIntoConstraints="NO" id="VIh-8L-VsB" customClass="HUDView" customModule="LoopUI">
<rect key="frame" x="0.0" y="0.0" width="359" height="70"/>
<constraints>
<constraint firstAttribute="height" constant="70" id="CMw-Lk-A0P"/>
<constraint firstAttribute="height" constant="70" placeholder="YES" id="DpL-aY-Gr3"/>
</constraints>
</stackView>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="3n2-yC-jGi">
<rect key="frame" x="0.0" y="70" width="359" height="40"/>
<rect key="frame" x="0.0" y="70" width="359" height="50"/>
<subviews>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" layoutMarginsFollowReadableWidth="YES" text="Eventually 92 mg/dL" textAlignment="right" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="9iF-xY-Bh4">
<rect key="frame" x="8" y="0.0" width="343" height="40"/>
<rect key="frame" x="8" y="0.0" width="343" height="50"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="40" id="aVA-Mg-CvQ"/>
</constraints>
Expand All @@ -50,8 +50,8 @@
<constraint firstAttribute="trailing" secondItem="9iF-xY-Bh4" secondAttribute="trailing" constant="8" id="x9b-EB-fji"/>
</constraints>
</view>
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="GVu-hk-PBg" customClass="ChartContainerView" customModule="LoopUI">
<rect key="frame" x="0.0" y="110" width="359" height="110"/>
<view contentMode="scaleToFill" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="GVu-hk-PBg" customClass="ChartContainerView" customModule="LoopUI">
<rect key="frame" x="0.0" y="120" width="359" height="100"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="height" relation="greaterThanOrEqual" priority="750" constant="100" id="rLK-f9-lLl"/>
Expand All @@ -75,7 +75,7 @@
<size key="freeformSize" width="375" height="220"/>
<connections>
<outlet property="glucoseChartContentView" destination="GVu-hk-PBg" id="gfZ-nx-P6V"/>
<outlet property="hudView" destination="d8d-rW-z8J" id="7Cp-BW-Kpc"/>
<outlet property="hudView" destination="VIh-8L-VsB" id="NsP-iq-J4a"/>
<outlet property="subtitleLabel" destination="9iF-xY-Bh4" id="PM8-hd-IB3"/>
</connections>
</viewController>
Expand Down
50 changes: 11 additions & 39 deletions Loop Status Extension/StatusViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,36 +61,6 @@ class StatusViewController: UIViewController, NCWidgetProviding {
var defaults: UserDefaults?
final var observationContext = 1

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.isHidden = true
Expand Down Expand Up @@ -125,11 +95,13 @@ class StatusViewController: UIViewController, NCWidgetProviding {
}

func widgetActiveDisplayModeDidChange(_ activeDisplayMode: NCWidgetDisplayMode, withMaximumSize maxSize: CGSize) {
let compactHeight = hudView.systemLayoutSizeFitting(maxSize).height + subtitleLabel.systemLayoutSizeFitting(maxSize).height

switch activeDisplayMode {
case .compact:
preferredContentSize = maxSize
preferredContentSize = CGSize(width: maxSize.width, height: compactHeight)
case .expanded:
preferredContentSize = CGSize(width: maxSize.width, height: 210)
preferredContentSize = CGSize(width: maxSize.width, height: compactHeight + 100)
}
}

Expand Down Expand Up @@ -168,29 +140,29 @@ class StatusViewController: UIViewController, NCWidgetProviding {
return NCUpdateResult.failed
}
if let lastGlucose = context.glucose?.last {
glucoseHUD.setGlucoseQuantity(lastGlucose.value,
hudView.glucoseHUD.setGlucoseQuantity(lastGlucose.value,
at: lastGlucose.startDate,
unit: lastGlucose.unit,
sensor: context.sensor
)
}

if let batteryPercentage = context.batteryPercentage {
batteryHUD.batteryLevel = Double(batteryPercentage)
hudView.batteryHUD.batteryLevel = Double(batteryPercentage)
}

if let reservoir = context.reservoir {
reservoirVolumeHUD.reservoirLevel = min(1, max(0, Double(reservoir.unitVolume / Double(reservoir.capacity))))
reservoirVolumeHUD.setReservoirVolume(volume: reservoir.unitVolume, at: reservoir.startDate)
hudView.reservoirVolumeHUD.reservoirLevel = min(1, max(0, Double(reservoir.unitVolume / Double(reservoir.capacity))))
hudView.reservoirVolumeHUD.setReservoirVolume(volume: reservoir.unitVolume, at: reservoir.startDate)
}

if let netBasal = context.netBasal {
basalRateHUD.setNetBasalRate(netBasal.rate, percent: netBasal.percentage, at: netBasal.start)
hudView.basalRateHUD.setNetBasalRate(netBasal.rate, percent: netBasal.percentage, at: netBasal.start)
}

if let loop = context.loop {
loopCompletionHUD.dosingEnabled = loop.dosingEnabled
loopCompletionHUD.lastLoopCompleted = loop.lastCompleted
hudView.loopCompletionHUD.dosingEnabled = loop.dosingEnabled
hudView.loopCompletionHUD.lastLoopCompleted = loop.lastCompleted
}

subtitleLabel.isHidden = true
Expand Down
4 changes: 4 additions & 0 deletions Loop.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
43076BF31DFDBC4B0012A723 /* it.lproj in Resources */ = {isa = PBXBuildFile; fileRef = 43076BF21DFDBC4B0012A723 /* it.lproj */; };
4309786C1E73D2F500BEBC82 /* it.lproj in Resources */ = {isa = PBXBuildFile; fileRef = 4309786B1E73D2F500BEBC82 /* it.lproj */; };
4309786E1E73DAD100BEBC82 /* CGM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4309786D1E73DAD100BEBC82 /* CGM.swift */; };
430D85891F44037000AF2D4F /* HUDViewTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 430D85881F44037000AF2D4F /* HUDViewTableViewCell.swift */; };
430DA58E1D4AEC230097D1CA /* NSBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 430DA58D1D4AEC230097D1CA /* NSBundle.swift */; };
430DA5901D4B0E4C0097D1CA /* MySentryPumpStatusMessageBody.swift in Sources */ = {isa = PBXBuildFile; fileRef = 430DA58F1D4B0E4C0097D1CA /* MySentryPumpStatusMessageBody.swift */; };
4311FB9B1F37FE1B00D4C0A7 /* TitleSubtitleTextFieldTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4311FB9A1F37FE1B00D4C0A7 /* TitleSubtitleTextFieldTableViewCell.swift */; };
Expand Down Expand Up @@ -377,6 +378,7 @@
4309786B1E73D2F500BEBC82 /* it.lproj */ = {isa = PBXFileReference; lastKnownFileType = folder; path = it.lproj; sourceTree = "<group>"; };
4309786D1E73DAD100BEBC82 /* CGM.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CGM.swift; sourceTree = "<group>"; };
430C1ABC1E5568A80067F1AE /* StatusChartsManager+LoopKit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "StatusChartsManager+LoopKit.swift"; sourceTree = "<group>"; };
430D85881F44037000AF2D4F /* HUDViewTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HUDViewTableViewCell.swift; sourceTree = "<group>"; };
430DA58D1D4AEC230097D1CA /* NSBundle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSBundle.swift; sourceTree = "<group>"; };
430DA58F1D4B0E4C0097D1CA /* MySentryPumpStatusMessageBody.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MySentryPumpStatusMessageBody.swift; sourceTree = "<group>"; };
4311FB9A1F37FE1B00D4C0A7 /* TitleSubtitleTextFieldTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TitleSubtitleTextFieldTableViewCell.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -935,6 +937,7 @@
4346D1E61C77F5FE00ABAFE3 /* ChartTableViewCell.swift */,
431A8C3F1EC6E8AB00823B9C /* CircleMaskView.swift */,
43D381611EBD9759007F8C8F /* HeaderValuesTableViewCell.swift */,
430D85881F44037000AF2D4F /* HUDViewTableViewCell.swift */,
438D42FA1D7D11A4003244B0 /* PredictionInputEffectTableViewCell.swift */,
43A5676A1C96155700334FAC /* SwitchTableViewCell.swift */,
43F64DD81D9C92C900D24DC6 /* TitleSubtitleTableViewCell.swift */,
Expand Down Expand Up @@ -1605,6 +1608,7 @@
435CB6291F37B01300C320C7 /* InsulinModelSettings.swift in Sources */,
431A8C401EC6E8AB00823B9C /* CircleMaskView.swift in Sources */,
439897371CD2F80600223065 /* AnalyticsManager.swift in Sources */,
430D85891F44037000AF2D4F /* HUDViewTableViewCell.swift in Sources */,
43A51E211EB6DBDD000736CC /* ChartsTableViewController.swift in Sources */,
4346D1F61C78501000ABAFE3 /* ChartPoint+Loop.swift in Sources */,
438849EE1D2A1EBB003B3F23 /* MLabService.swift in Sources */,
Expand Down
Loading