Skip to content

Commit b41ceda

Browse files
author
Bharat Mediratta
committed
Add HKUnit extension to get preferredMinimumFractionDigits
That extension to HKUnit comes from LoopKit, which is no longer included with the Loop Status Extension. Not sure how this compiled without this fix in the past.
1 parent f09ae0b commit b41ceda

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

Loop Status Extension/HKUnit.swift

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
//
2+
// HKUnit.swift
3+
// Loop
4+
//
5+
// Created by Bharat Mediratta on 12/2/16.
6+
// Copyright © 2016 LoopKit Authors. All rights reserved.
7+
//
8+
9+
import HealthKit
10+
11+
public extension HKUnit {
12+
// A formatting helper for determining the preferred decimal style for a given unit
13+
// This is similar to the LoopKit HKUnit extension, but copied here so that we can
14+
// avoid a dependency on LoopKit from the Loop Status Extension.
15+
var preferredMinimumFractionDigits: Int {
16+
if self.unitString == "mg/dL" {
17+
return 0
18+
} else {
19+
return 1
20+
}
21+
}
22+
}

Loop.xcodeproj/project.pbxproj

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,8 @@
151151
43FBEDD81D73843700B21F22 /* LevelMaskView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 43FBEDD71D73843700B21F22 /* LevelMaskView.swift */; };
152152
4D3B40041D4A9E1A00BC6334 /* G4ShareSpy.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D3B40021D4A9DFE00BC6334 /* G4ShareSpy.framework */; };
153153
4D5B7A4B1D457CCA00796CA9 /* GlucoseG4.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D5B7A4A1D457CCA00796CA9 /* GlucoseG4.swift */; };
154+
4F526D5D1DF0FD6500A04910 /* InsulinKit.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 43C6407B1DA051850093E25D /* InsulinKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
155+
4F526D5F1DF2459000A04910 /* HKUnit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F526D5E1DF2459000A04910 /* HKUnit.swift */; };
154156
4F70C1DE1DE8DCA7006380B7 /* NotificationCenter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4F70C1DD1DE8DCA7006380B7 /* NotificationCenter.framework */; };
155157
4F70C1E11DE8DCA7006380B7 /* StatusViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F70C1E01DE8DCA7006380B7 /* StatusViewController.swift */; };
156158
4F70C1E41DE8DCA7006380B7 /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4F70C1E21DE8DCA7006380B7 /* MainInterface.storyboard */; };
@@ -175,7 +177,6 @@
175177
4F70C2131DE90339006380B7 /* StatusExtensionContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F70C2111DE900EA006380B7 /* StatusExtensionContext.swift */; };
176178
4FC8C8011DEB93E400A1452E /* NSUserDefaults+StatusExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FC8C8001DEB93E400A1452E /* NSUserDefaults+StatusExtension.swift */; };
177179
4FC8C8021DEB943800A1452E /* NSUserDefaults+StatusExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4FC8C8001DEB93E400A1452E /* NSUserDefaults+StatusExtension.swift */; };
178-
4F526D5D1DF0FD6500A04910 /* InsulinKit.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 43C6407B1DA051850093E25D /* InsulinKit.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
179180
C10428971D17BAD400DD539A /* NightscoutUploadKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C10428961D17BAD400DD539A /* NightscoutUploadKit.framework */; };
180181
C15713821DAC6983005BC4D2 /* MealBolusNightscoutTreatment.swift in Sources */ = {isa = PBXBuildFile; fileRef = C15713811DAC6983005BC4D2 /* MealBolusNightscoutTreatment.swift */; };
181182
C17884631D51A7A400405663 /* BatteryIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C17884621D51A7A400405663 /* BatteryIndicator.swift */; };
@@ -433,6 +434,7 @@
433434
43FBEDD71D73843700B21F22 /* LevelMaskView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LevelMaskView.swift; sourceTree = "<group>"; };
434435
4D3B40021D4A9DFE00BC6334 /* G4ShareSpy.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = G4ShareSpy.framework; path = Carthage/Build/iOS/G4ShareSpy.framework; sourceTree = "<group>"; };
435436
4D5B7A4A1D457CCA00796CA9 /* GlucoseG4.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = GlucoseG4.swift; path = Loop/Models/GlucoseG4.swift; sourceTree = SOURCE_ROOT; };
437+
4F526D5E1DF2459000A04910 /* HKUnit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HKUnit.swift; sourceTree = "<group>"; };
436438
4F70C1DC1DE8DCA7006380B7 /* Loop Status Extension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "Loop Status Extension.appex"; sourceTree = BUILT_PRODUCTS_DIR; };
437439
4F70C1DD1DE8DCA7006380B7 /* NotificationCenter.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = NotificationCenter.framework; path = System/Library/Frameworks/NotificationCenter.framework; sourceTree = SDKROOT; };
438440
4F70C1E01DE8DCA7006380B7 /* StatusViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = StatusViewController.swift; sourceTree = "<group>"; };
@@ -810,6 +812,7 @@
810812
4F70C1E21DE8DCA7006380B7 /* MainInterface.storyboard */,
811813
4F70C1E51DE8DCA7006380B7 /* Info.plist */,
812814
4F70C2111DE900EA006380B7 /* StatusExtensionContext.swift */,
815+
4F526D5E1DF2459000A04910 /* HKUnit.swift */,
813816
);
814817
path = "Loop Status Extension";
815818
sourceTree = SOURCE_ROOT;
@@ -1299,6 +1302,7 @@
12991302
files = (
13001303
4FC8C8021DEB943800A1452E /* NSUserDefaults+StatusExtension.swift in Sources */,
13011304
4F70C20B1DE8E9F4006380B7 /* GlucoseTrend.swift in Sources */,
1305+
4F526D5F1DF2459000A04910 /* HKUnit.swift in Sources */,
13021306
4F70C1FB1DE8E45E006380B7 /* NSTimeInterval.swift in Sources */,
13031307
4F70C1FA1DE8E42D006380B7 /* ReservoirVolumeHUDView.swift in Sources */,
13041308
4F70C1F91DE8E409006380B7 /* LoopStateView.swift in Sources */,

0 commit comments

Comments
 (0)