Skip to content

Commit 7e07af6

Browse files
authored
Font scaling fixes (#566)
* Font scaling fixes * Font scaling fixes
1 parent 172243e commit 7e07af6

16 files changed

+418
-265
lines changed

Loop Status Extension/Base.lproj/MainInterface.storyboard

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,17 +24,17 @@
2424
<stackView opaque="NO" contentMode="scaleToFill" axis="vertical" translatesAutoresizingMaskIntoConstraints="NO" id="QEK-eF-fK6">
2525
<rect key="frame" x="8" y="0.0" width="359" height="220"/>
2626
<subviews>
27-
<stackView opaque="NO" contentMode="scaleToFill" distribution="fillEqually" translatesAutoresizingMaskIntoConstraints="NO" id="d8d-rW-z8J" customClass="HUDView" customModule="LoopUI">
27+
<view contentMode="scaleToFill" verticalHuggingPriority="252" translatesAutoresizingMaskIntoConstraints="NO" id="VIh-8L-VsB" customClass="HUDView" customModule="LoopUI">
2828
<rect key="frame" x="0.0" y="0.0" width="359" height="70"/>
2929
<constraints>
30-
<constraint firstAttribute="height" constant="70" id="CMw-Lk-A0P"/>
30+
<constraint firstAttribute="height" constant="70" placeholder="YES" id="DpL-aY-Gr3"/>
3131
</constraints>
32-
</stackView>
32+
</view>
3333
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="3n2-yC-jGi">
34-
<rect key="frame" x="0.0" y="70" width="359" height="40"/>
34+
<rect key="frame" x="0.0" y="70" width="359" height="50"/>
3535
<subviews>
3636
<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">
37-
<rect key="frame" x="8" y="0.0" width="343" height="40"/>
37+
<rect key="frame" x="8" y="0.0" width="343" height="50"/>
3838
<constraints>
3939
<constraint firstAttribute="height" relation="greaterThanOrEqual" constant="40" id="aVA-Mg-CvQ"/>
4040
</constraints>
@@ -50,8 +50,8 @@
5050
<constraint firstAttribute="trailing" secondItem="9iF-xY-Bh4" secondAttribute="trailing" constant="8" id="x9b-EB-fji"/>
5151
</constraints>
5252
</view>
53-
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="GVu-hk-PBg" customClass="ChartContainerView" customModule="LoopUI">
54-
<rect key="frame" x="0.0" y="110" width="359" height="110"/>
53+
<view contentMode="scaleToFill" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="GVu-hk-PBg" customClass="ChartContainerView" customModule="LoopUI">
54+
<rect key="frame" x="0.0" y="120" width="359" height="100"/>
5555
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
5656
<constraints>
5757
<constraint firstAttribute="height" relation="greaterThanOrEqual" priority="750" constant="100" id="rLK-f9-lLl"/>
@@ -75,7 +75,7 @@
7575
<size key="freeformSize" width="375" height="220"/>
7676
<connections>
7777
<outlet property="glucoseChartContentView" destination="GVu-hk-PBg" id="gfZ-nx-P6V"/>
78-
<outlet property="hudView" destination="d8d-rW-z8J" id="7Cp-BW-Kpc"/>
78+
<outlet property="hudView" destination="VIh-8L-VsB" id="NsP-iq-J4a"/>
7979
<outlet property="subtitleLabel" destination="9iF-xY-Bh4" id="PM8-hd-IB3"/>
8080
</connections>
8181
</viewController>

Loop Status Extension/StatusViewController.swift

Lines changed: 11 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -61,36 +61,6 @@ class StatusViewController: UIViewController, NCWidgetProviding {
6161
var defaults: UserDefaults?
6262
final var observationContext = 1
6363

64-
var loopCompletionHUD: LoopCompletionHUDView! {
65-
get {
66-
return hudView.loopCompletionHUD
67-
}
68-
}
69-
70-
var glucoseHUD: GlucoseHUDView! {
71-
get {
72-
return hudView.glucoseHUD
73-
}
74-
}
75-
76-
var basalRateHUD: BasalRateHUDView! {
77-
get {
78-
return hudView.basalRateHUD
79-
}
80-
}
81-
82-
var reservoirVolumeHUD: ReservoirVolumeHUDView! {
83-
get {
84-
return hudView.reservoirVolumeHUD
85-
}
86-
}
87-
88-
var batteryHUD: BatteryLevelHUDView! {
89-
get {
90-
return hudView.batteryHUD
91-
}
92-
}
93-
9464
override func viewDidLoad() {
9565
super.viewDidLoad()
9666
subtitleLabel.isHidden = true
@@ -125,11 +95,13 @@ class StatusViewController: UIViewController, NCWidgetProviding {
12595
}
12696

12797
func widgetActiveDisplayModeDidChange(_ activeDisplayMode: NCWidgetDisplayMode, withMaximumSize maxSize: CGSize) {
98+
let compactHeight = hudView.systemLayoutSizeFitting(maxSize).height + subtitleLabel.systemLayoutSizeFitting(maxSize).height
99+
128100
switch activeDisplayMode {
129101
case .compact:
130-
preferredContentSize = maxSize
102+
preferredContentSize = CGSize(width: maxSize.width, height: compactHeight)
131103
case .expanded:
132-
preferredContentSize = CGSize(width: maxSize.width, height: 210)
104+
preferredContentSize = CGSize(width: maxSize.width, height: compactHeight + 100)
133105
}
134106
}
135107

@@ -168,29 +140,29 @@ class StatusViewController: UIViewController, NCWidgetProviding {
168140
return NCUpdateResult.failed
169141
}
170142
if let lastGlucose = context.glucose?.last {
171-
glucoseHUD.setGlucoseQuantity(lastGlucose.value,
143+
hudView.glucoseHUD.setGlucoseQuantity(lastGlucose.value,
172144
at: lastGlucose.startDate,
173145
unit: lastGlucose.unit,
174146
sensor: context.sensor
175147
)
176148
}
177149

178150
if let batteryPercentage = context.batteryPercentage {
179-
batteryHUD.batteryLevel = Double(batteryPercentage)
151+
hudView.batteryHUD.batteryLevel = Double(batteryPercentage)
180152
}
181153

182154
if let reservoir = context.reservoir {
183-
reservoirVolumeHUD.reservoirLevel = min(1, max(0, Double(reservoir.unitVolume / Double(reservoir.capacity))))
184-
reservoirVolumeHUD.setReservoirVolume(volume: reservoir.unitVolume, at: reservoir.startDate)
155+
hudView.reservoirVolumeHUD.reservoirLevel = min(1, max(0, Double(reservoir.unitVolume / Double(reservoir.capacity))))
156+
hudView.reservoirVolumeHUD.setReservoirVolume(volume: reservoir.unitVolume, at: reservoir.startDate)
185157
}
186158

187159
if let netBasal = context.netBasal {
188-
basalRateHUD.setNetBasalRate(netBasal.rate, percent: netBasal.percentage, at: netBasal.start)
160+
hudView.basalRateHUD.setNetBasalRate(netBasal.rate, percent: netBasal.percentage, at: netBasal.start)
189161
}
190162

191163
if let loop = context.loop {
192-
loopCompletionHUD.dosingEnabled = loop.dosingEnabled
193-
loopCompletionHUD.lastLoopCompleted = loop.lastCompleted
164+
hudView.loopCompletionHUD.dosingEnabled = loop.dosingEnabled
165+
hudView.loopCompletionHUD.lastLoopCompleted = loop.lastCompleted
194166
}
195167

196168
subtitleLabel.isHidden = true

Loop.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
43076BF31DFDBC4B0012A723 /* it.lproj in Resources */ = {isa = PBXBuildFile; fileRef = 43076BF21DFDBC4B0012A723 /* it.lproj */; };
1616
4309786C1E73D2F500BEBC82 /* it.lproj in Resources */ = {isa = PBXBuildFile; fileRef = 4309786B1E73D2F500BEBC82 /* it.lproj */; };
1717
4309786E1E73DAD100BEBC82 /* CGM.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4309786D1E73DAD100BEBC82 /* CGM.swift */; };
18+
430D85891F44037000AF2D4F /* HUDViewTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 430D85881F44037000AF2D4F /* HUDViewTableViewCell.swift */; };
1819
430DA58E1D4AEC230097D1CA /* NSBundle.swift in Sources */ = {isa = PBXBuildFile; fileRef = 430DA58D1D4AEC230097D1CA /* NSBundle.swift */; };
1920
430DA5901D4B0E4C0097D1CA /* MySentryPumpStatusMessageBody.swift in Sources */ = {isa = PBXBuildFile; fileRef = 430DA58F1D4B0E4C0097D1CA /* MySentryPumpStatusMessageBody.swift */; };
2021
4311FB9B1F37FE1B00D4C0A7 /* TitleSubtitleTextFieldTableViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4311FB9A1F37FE1B00D4C0A7 /* TitleSubtitleTextFieldTableViewCell.swift */; };
@@ -377,6 +378,7 @@
377378
4309786B1E73D2F500BEBC82 /* it.lproj */ = {isa = PBXFileReference; lastKnownFileType = folder; path = it.lproj; sourceTree = "<group>"; };
378379
4309786D1E73DAD100BEBC82 /* CGM.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CGM.swift; sourceTree = "<group>"; };
379380
430C1ABC1E5568A80067F1AE /* StatusChartsManager+LoopKit.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "StatusChartsManager+LoopKit.swift"; sourceTree = "<group>"; };
381+
430D85881F44037000AF2D4F /* HUDViewTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HUDViewTableViewCell.swift; sourceTree = "<group>"; };
380382
430DA58D1D4AEC230097D1CA /* NSBundle.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NSBundle.swift; sourceTree = "<group>"; };
381383
430DA58F1D4B0E4C0097D1CA /* MySentryPumpStatusMessageBody.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MySentryPumpStatusMessageBody.swift; sourceTree = "<group>"; };
382384
4311FB9A1F37FE1B00D4C0A7 /* TitleSubtitleTextFieldTableViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TitleSubtitleTextFieldTableViewCell.swift; sourceTree = "<group>"; };
@@ -935,6 +937,7 @@
935937
4346D1E61C77F5FE00ABAFE3 /* ChartTableViewCell.swift */,
936938
431A8C3F1EC6E8AB00823B9C /* CircleMaskView.swift */,
937939
43D381611EBD9759007F8C8F /* HeaderValuesTableViewCell.swift */,
940+
430D85881F44037000AF2D4F /* HUDViewTableViewCell.swift */,
938941
438D42FA1D7D11A4003244B0 /* PredictionInputEffectTableViewCell.swift */,
939942
43A5676A1C96155700334FAC /* SwitchTableViewCell.swift */,
940943
43F64DD81D9C92C900D24DC6 /* TitleSubtitleTableViewCell.swift */,
@@ -1605,6 +1608,7 @@
16051608
435CB6291F37B01300C320C7 /* InsulinModelSettings.swift in Sources */,
16061609
431A8C401EC6E8AB00823B9C /* CircleMaskView.swift in Sources */,
16071610
439897371CD2F80600223065 /* AnalyticsManager.swift in Sources */,
1611+
430D85891F44037000AF2D4F /* HUDViewTableViewCell.swift in Sources */,
16081612
43A51E211EB6DBDD000736CC /* ChartsTableViewController.swift in Sources */,
16091613
4346D1F61C78501000ABAFE3 /* ChartPoint+Loop.swift in Sources */,
16101614
438849EE1D2A1EBB003B3F23 /* MLabService.swift in Sources */,

0 commit comments

Comments
 (0)