diff --git a/Loop Status Extension/Base.lproj/MainInterface.storyboard b/Loop Status Extension/Base.lproj/MainInterface.storyboard index 9904d79108..65c73c24cd 100644 --- a/Loop Status Extension/Base.lproj/MainInterface.storyboard +++ b/Loop Status Extension/Base.lproj/MainInterface.storyboard @@ -1,11 +1,11 @@ - - + + - + @@ -18,37 +18,51 @@ - + - + - + - + - + + + + - - + + @@ -58,7 +72,7 @@ - + diff --git a/Loop Status Extension/StatusViewController.swift b/Loop Status Extension/StatusViewController.swift index d91dbd84cc..a6116360de 100644 --- a/Loop Status Extension/StatusViewController.swift +++ b/Loop Status Extension/StatusViewController.swift @@ -29,7 +29,25 @@ class StatusViewController: UIViewController, NCWidgetProviding { @IBOutlet weak var glucoseChartContentView: ChartContentView! private lazy var charts: StatusChartsManager = { - let charts = StatusChartsManager(colors: ChartColorPalette(axisLine: .axisLineColor, axisLabel: .axisLabelColor, grid: .gridColor, glucoseTint: .glucoseTintColor, doseTint: .doseTintColor)) + let charts = StatusChartsManager( + colors: ChartColorPalette( + axisLine: .axisLineColor, + axisLabel: .axisLabelColor, + grid: .gridColor, + glucoseTint: .glucoseTintColor, + doseTint: .doseTintColor + ), + settings: { + var settings = ChartSettings() + settings.top = 4 + settings.bottom = 8 + settings.trailing = 8 + settings.axisTitleLabelsToLabelsSpacing = 0 + settings.labelsToAxisSpacingX = 6 + settings.labelsWidthY = 30 + return settings + }() + ) charts.glucoseDisplayRange = ( min: HKQuantity(unit: HKUnit.milligramsPerDeciliterUnit(), doubleValue: 100), @@ -75,7 +93,7 @@ class StatusViewController: UIViewController, NCWidgetProviding { override func viewDidLoad() { super.viewDidLoad() - subtitleLabel.alpha = 0 + subtitleLabel.isHidden = true subtitleLabel.textColor = .subtitleLabelColor let tapGestureRecognizer = UITapGestureRecognizer(target: self, action: #selector(openLoopApp(_:))) @@ -97,7 +115,7 @@ class StatusViewController: UIViewController, NCWidgetProviding { } self.extensionContext?.widgetLargestAvailableDisplayMode = NCWidgetDisplayMode.expanded - glucoseChartContentView.alpha = self.extensionContext?.widgetActiveDisplayMode == NCWidgetDisplayMode.compact ? 0 : 1 + glucoseChartContentView.isHidden = self.extensionContext?.widgetActiveDisplayMode != .expanded } deinit { @@ -107,10 +125,11 @@ class StatusViewController: UIViewController, NCWidgetProviding { } func widgetActiveDisplayModeDidChange(_ activeDisplayMode: NCWidgetDisplayMode, withMaximumSize maxSize: CGSize) { - if (activeDisplayMode == NCWidgetDisplayMode.compact) { - self.preferredContentSize = maxSize - } else { - self.preferredContentSize = CGSize(width: maxSize.width, height: 210) + switch activeDisplayMode { + case .compact: + preferredContentSize = maxSize + case .expanded: + preferredContentSize = CGSize(width: maxSize.width, height: 210) } } @@ -119,11 +138,7 @@ class StatusViewController: UIViewController, NCWidgetProviding { coordinator.animate(alongsideTransition: { (UIViewControllerTransitionCoordinatorContext) -> Void in - if self.extensionContext?.widgetActiveDisplayMode == .compact { - self.glucoseChartContentView.alpha = 0 - } else { - self.glucoseChartContentView.alpha = 1 - } + self.glucoseChartContentView.isHidden = self.extensionContext?.widgetActiveDisplayMode != .expanded }) } @@ -178,7 +193,7 @@ class StatusViewController: UIViewController, NCWidgetProviding { loopCompletionHUD.lastLoopCompleted = loop.lastCompleted } - subtitleLabel.alpha = 0 + subtitleLabel.isHidden = true let dateFormatter: DateFormatter = { let dateFormatter = DateFormatter() @@ -225,7 +240,7 @@ class StatusViewController: UIViewController, NCWidgetProviding { eventualGlucoseNumberString, eventualGlucose.unit.glucoseUnitDisplayString ) - subtitleLabel.alpha = 1 + subtitleLabel.isHidden = false } } } diff --git a/Loop Status Extension/UIColor+Widget.swift b/Loop Status Extension/UIColor+Widget.swift index bf57127f74..5ae2e95efc 100644 --- a/Loop Status Extension/UIColor+Widget.swift +++ b/Loop Status Extension/UIColor+Widget.swift @@ -12,7 +12,7 @@ import LoopUI extension UIColor { @nonobjc static let axisLabelColor = subtitleLabelColor - @nonobjc static let axisLineColor = subtitleLabelColor + @nonobjc static let axisLineColor = UIColor.clear @nonobjc static let doseTintColor = UIColor(red: 255 / 255, green: 109 / 255, blue: 0, alpha: 1) diff --git a/Loop.xcodeproj/project.pbxproj b/Loop.xcodeproj/project.pbxproj index 9a20d34622..6848ad2cb9 100644 --- a/Loop.xcodeproj/project.pbxproj +++ b/Loop.xcodeproj/project.pbxproj @@ -64,6 +64,9 @@ 438849EA1D297CB6003B3F23 /* NightscoutService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 438849E91D297CB6003B3F23 /* NightscoutService.swift */; }; 438849EC1D29EC34003B3F23 /* AmplitudeService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 438849EB1D29EC34003B3F23 /* AmplitudeService.swift */; }; 438849EE1D2A1EBB003B3F23 /* MLabService.swift in Sources */ = {isa = PBXBuildFile; fileRef = 438849ED1D2A1EBB003B3F23 /* MLabService.swift */; }; + 438991681E91B570000EEF90 /* ChartPoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 438991661E91B563000EEF90 /* ChartPoint.swift */; }; + 438991691E91B571000EEF90 /* ChartPoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 438991661E91B563000EEF90 /* ChartPoint.swift */; }; + 4389916B1E91B689000EEF90 /* ChartSettings+Loop.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4389916A1E91B689000EEF90 /* ChartSettings+Loop.swift */; }; 438A95A81D8B9B24009D12E1 /* xDripG5.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 438A95A71D8B9B24009D12E1 /* xDripG5.framework */; }; 438D42F91D7C88BC003244B0 /* PredictionInputEffect.swift in Sources */ = {isa = PBXBuildFile; fileRef = 438D42F81D7C88BC003244B0 /* PredictionInputEffect.swift */; }; 438D42FB1D7D11A4003244B0 /* PredictionInputEffectTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 438D42FA1D7D11A4003244B0 /* PredictionInputEffectTableViewCell.swift */; }; @@ -146,8 +149,6 @@ 43FCBBC21E51710B00343C1B /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 43776F9A1B8022E90074EA36 /* LaunchScreen.storyboard */; }; 4D3B40041D4A9E1A00BC6334 /* G4ShareSpy.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D3B40021D4A9DFE00BC6334 /* G4ShareSpy.framework */; }; 4D5B7A4B1D457CCA00796CA9 /* GlucoseG4.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4D5B7A4A1D457CCA00796CA9 /* GlucoseG4.swift */; }; - 4F08DE771E7B31C0006741EA /* ChartPoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F08DE751E7B3113006741EA /* ChartPoint.swift */; }; - 4F08DE791E7B57C9006741EA /* ChartPoint.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F08DE751E7B3113006741EA /* ChartPoint.swift */; }; 4F08DE8F1E7BB871006741EA /* CollectionType+Loop.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4F08DE8E1E7BB871006741EA /* CollectionType+Loop.swift */; }; 4F08DE9B1E7BC4ED006741EA /* SwiftCharts.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4346D1EF1C781BEA00ABAFE3 /* SwiftCharts.framework */; }; 4F08DE9D1E81D0E9006741EA /* StatusChartsManager+LoopKit.swift in Sources */ = {isa = PBXBuildFile; fileRef = 430C1ABC1E5568A80067F1AE /* StatusChartsManager+LoopKit.swift */; }; @@ -387,7 +388,7 @@ 43523EDA1CC35083001850F1 /* RileyLinkKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = RileyLinkKit.framework; path = Carthage/Build/iOS/RileyLinkKit.framework; sourceTree = ""; }; 435400301C9F744E00D5819C /* BolusSuggestionUserInfo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = BolusSuggestionUserInfo.swift; sourceTree = ""; }; 435400331C9F878D00D5819C /* SetBolusUserInfo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SetBolusUserInfo.swift; sourceTree = ""; }; - 43649A621C7A347F00523D7F /* CollectionType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CollectionType.swift; path = Extensions/CollectionType.swift; sourceTree = ""; }; + 43649A621C7A347F00523D7F /* CollectionType.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CollectionType.swift; sourceTree = ""; }; 436A0DA41D236A2A00104B24 /* LoopError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoopError.swift; sourceTree = ""; }; 436FACED1D0BA636004E2427 /* InsulinDataSource.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InsulinDataSource.swift; sourceTree = ""; }; 43776F8C1B8022E90074EA36 /* Loop.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Loop.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -412,6 +413,8 @@ 438849E91D297CB6003B3F23 /* NightscoutService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NightscoutService.swift; sourceTree = ""; }; 438849EB1D29EC34003B3F23 /* AmplitudeService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AmplitudeService.swift; sourceTree = ""; }; 438849ED1D2A1EBB003B3F23 /* MLabService.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MLabService.swift; sourceTree = ""; }; + 438991661E91B563000EEF90 /* ChartPoint.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChartPoint.swift; sourceTree = ""; }; + 4389916A1E91B689000EEF90 /* ChartSettings+Loop.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ChartSettings+Loop.swift"; sourceTree = ""; }; 438A95A71D8B9B24009D12E1 /* xDripG5.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = xDripG5.framework; path = Carthage/Build/iOS/xDripG5.framework; sourceTree = ""; }; 438D42F81D7C88BC003244B0 /* PredictionInputEffect.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PredictionInputEffect.swift; sourceTree = ""; }; 438D42FA1D7D11A4003244B0 /* PredictionInputEffectTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PredictionInputEffectTableViewCell.swift; sourceTree = ""; }; @@ -499,10 +502,9 @@ 43FBEDD71D73843700B21F22 /* LevelMaskView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LevelMaskView.swift; sourceTree = ""; }; 4D3B40021D4A9DFE00BC6334 /* G4ShareSpy.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = G4ShareSpy.framework; path = Carthage/Build/iOS/G4ShareSpy.framework; sourceTree = ""; }; 4D5B7A4A1D457CCA00796CA9 /* GlucoseG4.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = GlucoseG4.swift; path = Loop/Models/GlucoseG4.swift; sourceTree = SOURCE_ROOT; }; - 4F08DE751E7B3113006741EA /* ChartPoint.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChartPoint.swift; sourceTree = ""; }; 4F08DE7C1E7BB6E5006741EA /* ChartAxisValueDoubleLog.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChartAxisValueDoubleLog.swift; sourceTree = ""; }; 4F08DE7D1E7BB6E5006741EA /* ChartAxisValueDoubleUnit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChartAxisValueDoubleUnit.swift; sourceTree = ""; }; - 4F08DE801E7BB6F1006741EA /* CGPoint.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = CGPoint.swift; path = Extensions/CGPoint.swift; sourceTree = ""; }; + 4F08DE801E7BB6F1006741EA /* CGPoint.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CGPoint.swift; sourceTree = ""; }; 4F08DE831E7BB70B006741EA /* ChartPointsScatterDownTrianglesLayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChartPointsScatterDownTrianglesLayer.swift; sourceTree = ""; }; 4F08DE841E7BB70B006741EA /* ChartPointsTouchHighlightLayerViewCache.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChartPointsTouchHighlightLayerViewCache.swift; sourceTree = ""; }; 4F08DE8E1E7BB871006741EA /* CollectionType+Loop.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "CollectionType+Loop.swift"; sourceTree = ""; }; @@ -526,7 +528,7 @@ 4F75288B1DFE1DC600C322D6 /* LoopUI.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = LoopUI.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 4F75288D1DFE1DC600C322D6 /* LoopUI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = LoopUI.h; sourceTree = ""; }; 4F75288E1DFE1DC600C322D6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 4FB76FC51E8C57B100B39636 /* StatusChartsManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = StatusChartsManager.swift; path = Managers/StatusChartsManager.swift; sourceTree = ""; }; + 4FB76FC51E8C57B100B39636 /* StatusChartsManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusChartsManager.swift; sourceTree = ""; }; 4FB76FCD1E8C835D00B39636 /* ChartColorPalette.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChartColorPalette.swift; sourceTree = ""; }; 4FC8C8001DEB93E400A1452E /* NSUserDefaults+StatusExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "NSUserDefaults+StatusExtension.swift"; sourceTree = ""; }; 4FF4D0FF1E18374700846527 /* WatchContext.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = WatchContext.swift; sourceTree = ""; }; @@ -673,11 +675,11 @@ 4FF4D0FA1E1834BD00846527 /* Common */, 43776F8E1B8022E90074EA36 /* Loop */, 4F70C1DF1DE8DCA7006380B7 /* Loop Status Extension */, + 4F75288C1DFE1DC600C322D6 /* LoopUI */, 43A943731B926B7B0051FA24 /* WatchApp */, 43A943821B926B7B0051FA24 /* WatchApp Extension */, 43F78D2C1C8FC58F002152D1 /* LoopTests */, 43E2D8D21D20BF42004DA55F /* DoseMathTests */, - 4F75288C1DFE1DC600C322D6 /* LoopUI */, 968DCD53F724DE56FFE51920 /* Frameworks */, 43776F8D1B8022E90074EA36 /* Products */, 437D9BA11D7B5203007245E8 /* Loop.xcconfig */, @@ -812,7 +814,10 @@ isa = PBXGroup; children = ( C17884621D51A7A400405663 /* BatteryIndicator.swift */, + C17824991E1999FA00D9D25C /* CaseCountable.swift */, + 4F6663931E905FD2009E74FC /* ChartColorPalette+Loop.swift */, 4346D1F51C78501000ABAFE3 /* ChartPoint+Loop.swift */, + 4389916A1E91B689000EEF90 /* ChartSettings+Loop.swift */, 4F08DE8E1E7BB871006741EA /* CollectionType+Loop.swift */, 43CE7CDD1CA8B63E003CC1B0 /* Data.swift */, 4302F4E41D4EA75100F0FCAF /* DoseStore.swift */, @@ -825,8 +830,6 @@ 43BFF0BB1E45C80600FF19A9 /* UIColor+Loop.swift */, 437CEEE31CDE5C0A003C8C80 /* UIImage.swift */, 434FF1ED1CF27EEF000DB779 /* UITableViewCell.swift */, - C17824991E1999FA00D9D25C /* CaseCountable.swift */, - 4F6663931E905FD2009E74FC /* ChartColorPalette+Loop.swift */, ); path = Extensions; sourceTree = ""; @@ -839,6 +842,7 @@ 4315D2861CA5CC3B00589052 /* CarbEntryEditTableViewController.swift */, 43DBF0581C93F73800B3C386 /* CarbEntryTableViewController.swift */, 433EA4C31D9F71C800CD78FB /* CommandResponseViewController.swift */, + C178249F1E19CF9800D9D25C /* GlucoseThresholdTableViewController.swift */, 4302F4E21D4EA54200F0FCAF /* InsulinDeliveryTableViewController.swift */, 437D9BA21D7BC977007245E8 /* PredictionTableViewController.swift */, 433EA4C11D9F39C900CD78FB /* PumpIDTableViewController.swift */, @@ -846,7 +850,6 @@ 43F5C2DA1B92A5E1003EB13D /* SettingsTableViewController.swift */, 43E3449E1B9D68E900C85C07 /* StatusTableViewController.swift */, 4302F4E01D4E9C8900F0FCAF /* TextFieldTableViewController.swift */, - C178249F1E19CF9800D9D25C /* GlucoseThresholdTableViewController.swift */, ); path = "View Controllers"; sourceTree = ""; @@ -876,6 +879,7 @@ 43F4EF1C1BA2A57600526CE1 /* DiagnosticLogger.swift */, 4315D2891CA5F45E00589052 /* DiagnosticLogger+LoopKit.swift */, 43F78D251C8FC000002152D1 /* DoseMath.swift */, + 4F08DEA01E81D90F006741EA /* GlucoseRangeScheduleCalculator.swift */, 43E2D8C51D204678004DA55F /* KeychainManager.swift */, 43E2D8C71D208D5B004DA55F /* KeychainManager+Loop.swift */, 43A567681C94880B00334FAC /* LoopDataManager.swift */, @@ -885,7 +889,6 @@ 430C1ABC1E5568A80067F1AE /* StatusChartsManager+LoopKit.swift */, 4F70C20F1DE8FAC5006380B7 /* StatusExtensionDataManager.swift */, 4328E0341CFC0AE100E199AA /* WatchDataManager.swift */, - 4F08DEA01E81D90F006741EA /* GlucoseRangeScheduleCalculator.swift */, ); path = Managers; sourceTree = ""; @@ -899,30 +902,16 @@ path = LoopTests; sourceTree = ""; }; - 4F08DE6B1E799EBE006741EA /* Managers */ = { - isa = PBXGroup; - children = ( - ); - name = Managers; - sourceTree = ""; - }; - 4F08DE821E7BB6FE006741EA /* Views */ = { - isa = PBXGroup; - children = ( - ); - name = Views; - sourceTree = ""; - }; 4F70C1DF1DE8DCA7006380B7 /* Loop Status Extension */ = { isa = PBXGroup; children = ( 4F70C1FD1DE8E662006380B7 /* Loop Status Extension.entitlements */, 4F70C1E51DE8DCA7006380B7 /* Info.plist */, + 4F08DEA21E81E12D006741EA /* DatedRangedContextCalculator.swift */, 43BFF0CC1E466C8400FF19A9 /* StateColorPalette.swift */, 4F70C1E01DE8DCA7006380B7 /* StatusViewController.swift */, 43BFF0BE1E45C8EA00FF19A9 /* UIColor+Widget.swift */, 4F70C1E21DE8DCA7006380B7 /* MainInterface.storyboard */, - 4F08DEA21E81E12D006741EA /* DatedRangedContextCalculator.swift */, ); path = "Loop Status Extension"; sourceTree = ""; @@ -945,20 +934,20 @@ 4F7528931DFE1E1600C322D6 /* Views */ = { isa = PBXGroup; children = ( - 4F08DE831E7BB70B006741EA /* ChartPointsScatterDownTrianglesLayer.swift */, - 4F08DE841E7BB70B006741EA /* ChartPointsTouchHighlightLayerViewCache.swift */, 437CEEBF1CD6FCD8003C8C80 /* BasalRateHUDView.swift */, 43B371851CE583890013C5A6 /* BasalStateView.swift */, 437CEEBB1CD6DE6A003C8C80 /* BaseHUDView.swift */, 437CEEC91CD84DB7003C8C80 /* BatteryLevelHUDView.swift */, 4313EDDF1D8A6BF90060FA79 /* ChartContentView.swift */, + 4F08DE831E7BB70B006741EA /* ChartPointsScatterDownTrianglesLayer.swift */, + 4F08DE841E7BB70B006741EA /* ChartPointsTouchHighlightLayerViewCache.swift */, 4337615E1D52F487004A3647 /* GlucoseHUDView.swift */, 4F2C15921E09BF2C00E160D4 /* HUDView.swift */, + 43E0F0A41E46D1670064F7CE /* LevelHUDView.swift */, 43FBEDD71D73843700B21F22 /* LevelMaskView.swift */, 437CEEBD1CD6E0CB003C8C80 /* LoopCompletionHUDView.swift */, 438DADC71CDE8F8B007697A5 /* LoopStateView.swift */, 437CEEC71CD84CBB003C8C80 /* ReservoirVolumeHUDView.swift */, - 43E0F0A41E46D1670064F7CE /* LevelHUDView.swift */, ); path = Views; sourceTree = ""; @@ -968,9 +957,9 @@ children = ( 4F08DE7C1E7BB6E5006741EA /* ChartAxisValueDoubleLog.swift */, 4F08DE7D1E7BB6E5006741EA /* ChartAxisValueDoubleUnit.swift */, + 4FB76FCD1E8C835D00B39636 /* ChartColorPalette.swift */, 43EA28611D517E42001BC233 /* SensorDisplayable.swift */, 43BFF0C81E465B0A00FF19A9 /* StateColorPalette.swift */, - 4FB76FCD1E8C835D00B39636 /* ChartColorPalette.swift */, ); path = Models; sourceTree = ""; @@ -980,7 +969,7 @@ children = ( 4FB76FC51E8C57B100B39636 /* StatusChartsManager.swift */, ); - name = Managers; + path = Managers; sourceTree = ""; }; 4FB76FC41E8C576800B39636 /* Extensions */ = { @@ -989,16 +978,14 @@ 4F08DE801E7BB6F1006741EA /* CGPoint.swift */, 43649A621C7A347F00523D7F /* CollectionType.swift */, ); - name = Extensions; + path = Extensions; sourceTree = ""; }; 4FF4D0FA1E1834BD00846527 /* Common */ = { isa = PBXGroup; children = ( 4FF4D0FC1E1834CC00846527 /* Extensions */, - 4F08DE6B1E799EBE006741EA /* Managers */, 4FF4D0FB1E1834C400846527 /* Models */, - 4F08DE821E7BB6FE006741EA /* Views */, ); path = Common; sourceTree = ""; @@ -1019,7 +1006,7 @@ 4FF4D0FC1E1834CC00846527 /* Extensions */ = { isa = PBXGroup; children = ( - 4F08DE751E7B3113006741EA /* ChartPoint.swift */, + 438991661E91B563000EEF90 /* ChartPoint.swift */, 4F526D5E1DF2459000A04910 /* HKUnit.swift */, 434FF1E91CF26C29000DB779 /* IdentifiableClass.swift */, 434F54561D287FDB002A9274 /* NibLoadable.swift */, @@ -1436,6 +1423,7 @@ 439BED2E1E760BC600B0AED5 /* EnliteCGMManager.swift in Sources */, 43CE7CDE1CA8B63E003CC1B0 /* Data.swift in Sources */, 43BFF0CB1E466C0900FF19A9 /* StateColorPalette.swift in Sources */, + 438991691E91B571000EEF90 /* ChartPoint.swift in Sources */, 43F5C2DB1B92A5E1003EB13D /* SettingsTableViewController.swift in Sources */, C11C87DD1E21E53500BB71D3 /* GlucoseThreshold.swift in Sources */, 434FF1EA1CF26C29000DB779 /* IdentifiableClass.swift in Sources */, @@ -1458,7 +1446,6 @@ 43E93FB71E469A5100EAB8DB /* HKUnit.swift in Sources */, C17884631D51A7A400405663 /* BatteryIndicator.swift in Sources */, 43BFF0BC1E45C80600FF19A9 /* UIColor+Loop.swift in Sources */, - 4F08DE771E7B31C0006741EA /* ChartPoint.swift in Sources */, 43C0944A1CACCC73001F6403 /* NotificationManager.swift in Sources */, 4F08DE9D1E81D0E9006741EA /* StatusChartsManager+LoopKit.swift in Sources */, 434FF1EE1CF27EEF000DB779 /* UITableViewCell.swift in Sources */, @@ -1466,6 +1453,7 @@ C18C8C511D5A351900E043FB /* NightscoutDataManager.swift in Sources */, 438849EA1D297CB6003B3F23 /* NightscoutService.swift in Sources */, 437CCADC1D284B830075D2C3 /* ButtonTableViewCell.swift in Sources */, + 4389916B1E91B689000EEF90 /* ChartSettings+Loop.swift in Sources */, 4315D2871CA5CC3B00589052 /* CarbEntryEditTableViewController.swift in Sources */, 4309786E1E73DAD100BEBC82 /* CGM.swift in Sources */, 43F5173D1D713DB0000FA422 /* RadioSelectionTableViewController.swift in Sources */, @@ -1581,9 +1569,9 @@ 4F526D621DF9D95200A04910 /* NSBundle.swift in Sources */, 4FC8C8021DEB943800A1452E /* NSUserDefaults+StatusExtension.swift in Sources */, 43BFF0C71E465A4F00FF19A9 /* UIColor+HIG.swift in Sources */, - 4F08DE791E7B57C9006741EA /* ChartPoint.swift in Sources */, 43BFF0BF1E45C8EA00FF19A9 /* UIColor+Widget.swift in Sources */, 4F70C2121DE900EA006380B7 /* StatusExtensionContext.swift in Sources */, + 438991681E91B570000EEF90 /* ChartPoint.swift in Sources */, 4F70C1E11DE8DCA7006380B7 /* StatusViewController.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1732,6 +1720,10 @@ DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/iOS", + ); GCC_C_LANGUAGE_STANDARD = gnu99; GCC_DYNAMIC_NO_PIC = NO; GCC_NO_COMMON_BLOCKS = YES; @@ -1786,6 +1778,10 @@ DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; + FRAMEWORK_SEARCH_PATHS = ( + "$(inherited)", + "$(PROJECT_DIR)/Carthage/Build/iOS", + ); GCC_C_LANGUAGE_STANDARD = gnu99; GCC_NO_COMMON_BLOCKS = YES; GCC_WARN_64_TO_32_BIT_CONVERSION = YES; @@ -1814,10 +1810,6 @@ CODE_SIGN_ENTITLEMENTS = Loop/Loop.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; DEVELOPMENT_TEAM = ""; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Carthage/Build/iOS", - ); INFOPLIST_FILE = Loop/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; "OTHER_SWIFT_FLAGS[sdk=iphonesimulator*]" = "-D IOS_SIMULATOR"; @@ -1835,10 +1827,6 @@ CODE_SIGN_ENTITLEMENTS = Loop/Loop.entitlements; CODE_SIGN_IDENTITY = "iPhone Developer"; DEVELOPMENT_TEAM = ""; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Carthage/Build/iOS", - ); INFOPLIST_FILE = Loop/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "$(MAIN_APP_BUNDLE_IDENTIFIER)"; @@ -1929,10 +1917,6 @@ CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DEVELOPMENT_TEAM = ""; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Carthage/Build/iOS", - ); INFOPLIST_FILE = DoseMathTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.loudnate.DoseMathTests; @@ -1946,10 +1930,6 @@ CLANG_ANALYZER_NONNULL = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DEVELOPMENT_TEAM = ""; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Carthage/Build/iOS", - ); INFOPLIST_FILE = DoseMathTests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.loudnate.DoseMathTests; @@ -1997,10 +1977,6 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DEVELOPMENT_TEAM = ""; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Carthage/Build/iOS", - ); INFOPLIST_FILE = "Loop Status Extension/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "$(MAIN_APP_BUNDLE_IDENTIFIER).statuswidget"; @@ -2021,10 +1997,6 @@ CODE_SIGN_IDENTITY = "iPhone Developer"; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DEVELOPMENT_TEAM = ""; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Carthage/Build/iOS", - ); INFOPLIST_FILE = "Loop Status Extension/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @executable_path/../../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "$(MAIN_APP_BUNDLE_IDENTIFIER).statuswidget"; @@ -2049,10 +2021,6 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 32; DYLIB_INSTALL_NAME_BASE = "@rpath"; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Carthage/Build/iOS", - ); INFOPLIST_FILE = LoopUI/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -2081,10 +2049,6 @@ DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 32; DYLIB_INSTALL_NAME_BASE = "@rpath"; - FRAMEWORK_SEARCH_PATHS = ( - "$(inherited)", - "$(PROJECT_DIR)/Carthage/Build/iOS", - ); INFOPLIST_FILE = LoopUI/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; diff --git a/Loop/Extensions/ChartColorPalette+Loop.swift b/Loop/Extensions/ChartColorPalette+Loop.swift index f645f52619..382fb7b69f 100644 --- a/Loop/Extensions/ChartColorPalette+Loop.swift +++ b/Loop/Extensions/ChartColorPalette+Loop.swift @@ -6,14 +6,11 @@ // Copyright © 2017 LoopKit Authors. All rights reserved. // -import Foundation - import LoopUI + extension ChartColorPalette { static var `default`: ChartColorPalette { - get { - return ChartColorPalette(axisLine: .axisLineColor, axisLabel: .axisLabelColor, grid: .gridColor, glucoseTint: .glucoseTintColor, doseTint: .doseTintColor) - } + return ChartColorPalette(axisLine: .axisLineColor, axisLabel: .axisLabelColor, grid: .gridColor, glucoseTint: .glucoseTintColor, doseTint: .doseTintColor) } } diff --git a/Loop/Extensions/ChartSettings+Loop.swift b/Loop/Extensions/ChartSettings+Loop.swift new file mode 100644 index 0000000000..2020f095dc --- /dev/null +++ b/Loop/Extensions/ChartSettings+Loop.swift @@ -0,0 +1,22 @@ +// +// ChartSettings+Loop.swift +// Loop +// +// Copyright © 2017 LoopKit Authors. All rights reserved. +// + +import SwiftCharts + + +extension ChartSettings { + static var `default`: ChartSettings { + let settings = ChartSettings() + settings.top = 12 + settings.bottom = 0 + settings.trailing = 8 + settings.axisTitleLabelsToLabelsSpacing = 0 + settings.labelsToAxisSpacingX = 6 + settings.labelsWidthY = 30 + return settings + } +} diff --git a/Loop/View Controllers/PredictionTableViewController.swift b/Loop/View Controllers/PredictionTableViewController.swift index 2908cec7a0..18037eb004 100644 --- a/Loop/View Controllers/PredictionTableViewController.swift +++ b/Loop/View Controllers/PredictionTableViewController.swift @@ -89,7 +89,7 @@ class PredictionTableViewController: UITableViewController, IdentifiableClass, U var dataManager: DeviceDataManager! private lazy var charts: StatusChartsManager = { - let charts = StatusChartsManager(colors: .default) + let charts = StatusChartsManager(colors: .default, settings: .default) charts.glucoseDisplayRange = ( min: HKQuantity(unit: HKUnit.milligramsPerDeciliterUnit(), doubleValue: 60), diff --git a/Loop/View Controllers/StatusTableViewController.swift b/Loop/View Controllers/StatusTableViewController.swift index 24449b6af8..4159209804 100644 --- a/Loop/View Controllers/StatusTableViewController.swift +++ b/Loop/View Controllers/StatusTableViewController.swift @@ -397,7 +397,7 @@ final class StatusTableViewController: UITableViewController, UIGestureRecognize } private lazy var charts: StatusChartsManager = { - let charts = StatusChartsManager(colors: .default) + let charts = StatusChartsManager(colors: .default, settings: .default) charts.glucoseDisplayRange = ( min: HKQuantity(unit: HKUnit.milligramsPerDeciliterUnit(), doubleValue: 100), diff --git a/LoopUI/HUDView.xib b/LoopUI/HUDView.xib index f30f330b35..9e3944363c 100644 --- a/LoopUI/HUDView.xib +++ b/LoopUI/HUDView.xib @@ -1,11 +1,11 @@ - + - + @@ -138,6 +138,7 @@ + diff --git a/LoopUI/Managers/StatusChartsManager.swift b/LoopUI/Managers/StatusChartsManager.swift index 90d737b7b4..5a89d9298f 100644 --- a/LoopUI/Managers/StatusChartsManager.swift +++ b/LoopUI/Managers/StatusChartsManager.swift @@ -19,11 +19,9 @@ public protocol TargetPointsCalculator { } public final class StatusChartsManager { - - private var colors: ChartColorPalette - - public init(colors: ChartColorPalette) { + public init(colors: ChartColorPalette, settings: ChartSettings) { self.colors = colors + self.chartSettings = settings axisLabelSettings = ChartLabelSettings(font: UIFont.preferredFont(forTextStyle: UIFontTextStyle.caption1), fontColor: colors.axisLabel) @@ -32,17 +30,9 @@ public final class StatusChartsManager { // MARK: - Configuration - private lazy var chartSettings: ChartSettings = { - var chartSettings = ChartSettings() - chartSettings.top = 12 - chartSettings.bottom = 0 - chartSettings.trailing = 8 - chartSettings.axisTitleLabelsToLabelsSpacing = 0 - chartSettings.labelsToAxisSpacingX = 6 - chartSettings.labelsWidthY = 30 - - return chartSettings - }() + private let colors: ChartColorPalette + + private let chartSettings: ChartSettings /// The amount of horizontal space reserved for fixed margins public var fixedHorizontalMargin: CGFloat { diff --git a/LoopUI/Views/ChartContentView.swift b/LoopUI/Views/ChartContentView.swift index 82bd4ccbc1..dcc3d7d3ec 100644 --- a/LoopUI/Views/ChartContentView.swift +++ b/LoopUI/Views/ChartContentView.swift @@ -14,7 +14,11 @@ public class ChartContentView: UIView { super.layoutSubviews() if chartView == nil || chartView!.frame != bounds { - chartView = chartGenerator?(bounds) + // 50 is the smallest height in which we should attempt to redraw a chart. + // Smaller sizes might be requested mid-animation, so ignore them. + if bounds.height > 50 { + chartView = chartGenerator?(bounds) + } } else if chartView!.superview == nil { addSubview(chartView!) }