Skip to content
Open
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
18 changes: 17 additions & 1 deletion G6SensorKitUI/G6CGMManager+UI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,18 @@ extension G6CGMManager: CGMManagerUI {
)
}

// Ahead of calibration and signal loss: a dying battery is the likely
// cause of both, and replacing the transmitter is the actual fix. The
// highlight is the host's home-screen tag, so this is the one place
// the user sees it without opening settings.
if state.isBatteryVeryLow {
return G6StatusHighlight(
localizedMessage: LocalizedString("Transmitter Low", comment: "Status highlight when the transmitter battery is very low"),
imageName: "battery.0percent",
state: .warning
)
}

if let reading = state.latestReading, reading.calibrationState.needsCalibration {
return G6StatusHighlight(
localizedMessage: LocalizedString("Calibration Needed", comment: "Status highlight when a calibration is requested"),
Expand Down Expand Up @@ -162,7 +174,11 @@ extension G6CGMManager: CGMManagerUI {
let progressState: DeviceLifecycleProgressState
if remaining <= 0 {
progressState = .critical
} else if remaining <= .hours(24) {
} else if remaining <= .hours(24) || state.isBatteryVeryLow {
// A dying transmitter battery counts too. Trio shows the status
// highlight ("Transmitter Low") on its home screen only while
// the progress is not normal, so without this it would stay
// hidden for most of a session.
progressState = .warning
} else {
progressState = .normalCGM
Expand Down
12 changes: 12 additions & 0 deletions G6SensorKitUI/Localizable.xcstrings
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"sourceLanguage": "en",
"strings": {
"Readings may be missing or arrive late, and the transmitter may respond slowly or not at all — including to stopping a session or calibrating. Replace the transmitter as soon as you can, and check your glucose with a fingerstick meter if readings stop.": {
"comment": "Settings banner body when the transmitter battery is very low",
"extractionState": "manual"
},
"Sensor Failed": {
"extractionState": "manual",
"comment": "Status highlight for failed sensor"
Expand Down Expand Up @@ -49,6 +53,14 @@
"extractionState": "manual",
"comment": "Navigation title for pairing screen"
},
"Transmitter Low": {
"comment": "Status highlight when the transmitter battery is very low",
"extractionState": "manual"
},
"Transmitter battery very low": {
"comment": "Settings banner title when the transmitter battery is very low",
"extractionState": "manual"
},
"Warm-Up": {
"extractionState": "manual",
"comment": "Navigation title for warm-up screen"
Expand Down
29 changes: 29 additions & 0 deletions G6SensorKitUI/Views/G6SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,40 @@ struct G6SettingsView: View {
.foregroundStyle(.orange)
}
}

// Last, so the session's own status reads first and the battery
// explains it underneath.
if viewModel.state.isBatteryVeryLow {
batteryVeryLowRow
}
} header: {
Text(LocalizedString("Sensor", comment: "Settings section: sensor"))
}
}

/// The Sensor section's last row. Stays up for as long as the battery
/// reads very low; there is nothing to dismiss, because the only fix is
/// a new transmitter. A tester ran on a near-dead battery for a day of
/// dropped connections and an End Sensor that never got through, with
/// nothing on this screen to explain why.
private var batteryVeryLowRow: some View {
HStack(alignment: .top, spacing: 12) {
Image(systemName: "battery.0percent")
.font(.title2)
.foregroundStyle(.red)
VStack(alignment: .leading, spacing: 4) {
Text(LocalizedString("Transmitter battery very low", comment: "Settings banner title when the transmitter battery is very low"))
.font(.subheadline.weight(.semibold))
Text(LocalizedString("Readings may be missing or arrive late, and the transmitter may respond slowly or not at all — including to stopping a session or calibrating. Replace the transmitter as soon as you can, and check your glucose with a fingerstick meter if readings stop.", comment: "Settings banner body when the transmitter battery is very low"))
.font(.footnote)
.foregroundStyle(.secondary)
.fixedSize(horizontal: false, vertical: true)
}
}
.padding(.vertical, 4)
.listRowBackground(Color.red.opacity(0.12))
}

private var lastReadingSection: some View {
Section(LocalizedString("Last Reading", comment: "Settings section: last reading")) {
if let reading = viewModel.state.latestReading, !viewModel.state.isInWarmup {
Expand Down