Skip to content

Commit 3581083

Browse files
committed
Show loading if measurement is 0
1 parent 0b7274e commit 3581083

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

profile/src/main/java/no/nordicsemi/android/toolbox/profile/view/channelSounding/ChannelSoundingScreen.kt

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import no.nordicsemi.android.toolbox.profile.data.SessionClosedReason
5050
import no.nordicsemi.android.toolbox.profile.data.UpdateRate
5151
import no.nordicsemi.android.toolbox.profile.viewmodel.ChannelSoundingEvent
5252
import no.nordicsemi.android.toolbox.profile.viewmodel.ChannelSoundingViewModel
53+
import no.nordicsemi.android.ui.view.AnimatedThreeDots
5354
import no.nordicsemi.android.ui.view.ScreenSection
5455
import no.nordicsemi.android.ui.view.SectionTitle
5556
import no.nordicsemi.android.ui.view.TextWithAnimatedDots
@@ -323,12 +324,18 @@ private fun DistanceDashboard(measurement: Double) {
323324
horizontalAlignment = Alignment.CenterHorizontally,
324325
verticalArrangement = Arrangement.Center,
325326
) {
326-
Text(
327-
text = stringResource(R.string.ranging_distance_m, measurement.toFloat()),
328-
fontWeight = FontWeight.Bold,
329-
color = MaterialTheme.colorScheme.primary,
330-
style = MaterialTheme.typography.displayLarge
331-
)
327+
// get measurement in string with 2 decimal places
328+
val data = "%.2f".format(measurement.toFloat())
329+
if (data == "0.00") {
330+
AnimatedThreeDots(dotSize = 16.dp)
331+
} else {
332+
Text(
333+
text = stringResource(R.string.ranging_distance_m, measurement.toFloat()),
334+
fontWeight = FontWeight.Bold,
335+
color = MaterialTheme.colorScheme.primary,
336+
style = MaterialTheme.typography.displayLarge
337+
)
338+
}
332339
Spacer(modifier = Modifier.height(8.dp))
333340
Text(
334341
text = stringResource(R.string.current_measurement),
@@ -342,7 +349,7 @@ private fun DistanceDashboard(measurement: Double) {
342349
@Composable
343350
private fun DDistanceDashboard_Preview() {
344351
NordicTheme {
345-
DistanceDashboard(2.5)
352+
DistanceDashboard(0.0)
346353
}
347354
}
348355

0 commit comments

Comments
 (0)