@@ -185,9 +185,9 @@ class ExperimentDataParser {
185185 units: appearance. units,
186186 pointsAfterDecimal: appearance. pointsAfterDecimal)
187187 let ( sensorIcon, sensorIconAccessibilityLabel) =
188- imageAttributesForAppearance ( sensorSnapshot. sensorSpec. rememberedAppearance ,
189- size: SnapshotCardView . sensorIconSize,
190- value: sensorSnapshot. value)
188+ imageAttributesForSensor ( sensorSnapshot. sensorSpec,
189+ size: SnapshotCardView . sensorIconSize,
190+ value: sensorSnapshot. value)
191191 return DisplaySnapshotValue ( value: snapshotValue,
192192 valueType: appearance. name,
193193 sensorIcon: sensorIcon,
@@ -211,9 +211,9 @@ class ExperimentDataParser {
211211 units: sensorSpec. rememberedAppearance. units,
212212 pointsAfterDecimal: sensorSpec. rememberedAppearance. pointsAfterDecimal)
213213 let ( sensorIcon, sensorIconAccessibilityLabel) =
214- imageAttributesForAppearance ( sensorSpec. rememberedAppearance ,
215- size: TriggerCardView . sensorIconSize,
216- value: triggerInformation. valueToTrigger)
214+ imageAttributesForSensor ( sensorSpec,
215+ size: TriggerCardView . sensorIconSize,
216+ value: triggerInformation. valueToTrigger)
217217 return DisplayTriggerNoteViewData ( ID: note. ID,
218218 trialID: trial? . ID,
219219 descriptionText: descriptionText,
@@ -259,24 +259,33 @@ class ExperimentDataParser {
259259 }
260260 }
261261
262- /// Returns a large size icon for the given sensor appearance . Optionally a value can be passed
262+ /// Returns a large size icon for the given sensor. Optionally a value can be passed
263263 /// for icons that change based on a sensor value. If no icon can be found the default icon is
264264 /// returned. In some cases, an accessibility label is also returned.
265265 ///
266266 /// - Parameters:
267- /// - appearance: The appearance to parse an icon image from.
267+ /// - appearance: The sensor spec to parse an icon image from.
268268 /// - size: The icon size for icons that need it. Optional.
269269 /// - value: A sensor value for icons that need it. Optional.
270270 /// - Returns: A tuple containing an optional image and an optional accessibility label.
271- private func imageAttributesForAppearance( _ appearance: BasicSensorAppearance ,
272- size: CGSize ? ,
273- value: Double ? ) -> ( UIImage ? , String ? ) {
271+ private func imageAttributesForSensor( _ sensor: SensorSpec ,
272+ size: CGSize ? ,
273+ value: Double ? ) -> ( UIImage ? , String ? ) {
274+ let appearance = sensor. rememberedAppearance
275+
274276 guard let iconPath = appearance. largeIconPath else {
275277 return ( UIImage ( named: ExperimentDataParser . genericLargeIconName) , nil )
276278 }
277279
280+ guard iconPath. type == . builtin else {
281+ guard let sensor = sensorController. sensor ( for: sensor. gadgetInfo. address) else {
282+ return ( UIImage ( named: ExperimentDataParser . genericLargeIconName) , nil )
283+ }
284+ return ( UIImage ( named: sensor. iconName + ExperimentDataParser. largeIconSuffix) , nil )
285+ }
286+
278287 guard let pathString = iconPath. pathString,
279- let sensor = sensorController. sensor ( for: pathString) else {
288+ let sensor = sensorController. sensor ( for: pathString) else {
280289 return ( UIImage ( named: ExperimentDataParser . genericLargeIconName) , nil )
281290 }
282291
@@ -285,7 +294,7 @@ class ExperimentDataParser {
285294 }
286295
287296 switch iconPath. type {
288- case . builtin, . proto :
297+ case . builtin:
289298 return ( UIImage ( named: sensor. iconName + ExperimentDataParser. largeIconSuffix) , nil )
290299 default : return ( UIImage ( named: ExperimentDataParser . genericLargeIconName) , nil )
291300 }
0 commit comments