Skip to content

Commit 693e7e8

Browse files
authored
[LOOP-3384] correct when and how the accessibility string updates with status highlights (#547)
1 parent 0b7c628 commit 693e7e8

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

LoopUI/ViewModel/CGMStatusHUDViewModel.swift

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,12 @@ public class CGMStatusHUDViewModel {
6060
if isManualGlucoseCurrent {
6161
// If there is a current manual glucose, it displays the current status highlight icon
6262
setManualGlucoseTrendIconOverride()
63-
} else if let localizedMessage = storedStatusHighlight?.localizedMessage,
64-
let statusState = storedStatusHighlight?.state
63+
}
64+
65+
if let localizedMessage = storedStatusHighlight?.localizedMessage.replacingOccurrences(of: "\n", with: " "),
66+
let statusStateMessage = storedStatusHighlight?.state.localizedDescription
6567
{
66-
accessibilityString = localizedMessage + ", " + statusState.localizedDescription
68+
accessibilityString = localizedMessage + ", " + statusStateMessage
6769
}
6870
}
6971
}
@@ -156,16 +158,19 @@ public class CGMStatusHUDViewModel {
156158
if isManualGlucoseCurrent {
157159
// a manual glucose value presents any status highlight icon instead of a trend icon
158160
setManualGlucoseTrendIconOverride()
159-
if let statusState = storedStatusHighlight?.state {
160-
accessibilityStrings.append(statusState.localizedDescription)
161-
}
162161
} else if let trend = glucoseDisplay?.trendType, glucoseValueCurrent {
163162
self.trend = trend
164163
glucoseTrendTintColor = glucoseDisplay?.glucoseRangeCategory?.trendColor ?? .glucoseTintColor
165164
accessibilityStrings.append(trend.localizedDescription)
166165
} else {
167166
glucoseTrendTintColor = .glucoseTintColor
168167
}
168+
169+
if let statusStateMessage = storedStatusHighlight?.state.localizedDescription,
170+
let localizedMessage = storedStatusHighlight?.localizedMessage.replacingOccurrences(of: "\n", with: " ")
171+
{
172+
accessibilityStrings.append(localizedMessage + ", " + statusStateMessage)
173+
}
169174

170175
unitsString = unit.localizedShortUnitString
171176
accessibilityString = accessibilityStrings.joined(separator: ", ")

LoopUI/Views/CGMStatusHUDView.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ public final class CGMStatusHUDView: DeviceStatusHUDView, NibLoadable {
6868
defer {
6969
// when the status highlight is updated, the trend icon may also need to be updated
7070
updateTrendIcon()
71+
// when the status highlight is updated, the accessibility string is updated
72+
accessibilityValue = viewModel.accessibilityString
7173
}
7274

7375
guard statusStackView.arrangedSubviews.contains(glucoseValueHUD),
@@ -89,6 +91,8 @@ public final class CGMStatusHUDView: DeviceStatusHUDView, NibLoadable {
8991
defer {
9092
// when the status highlight is updated, the trend icon may also need to be updated
9193
updateTrendIcon()
94+
// when the status highlight is updated, the accessibility string is updated
95+
accessibilityValue = viewModel.accessibilityString
9296
}
9397

9498
guard statusStackView.arrangedSubviews.contains(statusHighlightView) else {

0 commit comments

Comments
 (0)