Skip to content

Commit

Permalink
"Change distance format"
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandrocalles committed Jun 2, 2024
1 parent 62e88f8 commit 26ee0d4
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,14 @@ fun EventListItem(
val association = event.organizer?.name?.let { "$it" } ?: ""
// Format the distance to be displayed
val dist =
distance?.let { String.format(Locale.getDefault(), "%.0f", it) }?.let { "${it}km • " } ?: ""
distance
?.let {
val fmt = { format: String, value: Double ->
String.format(Locale.getDefault(), format, value)
}
if (it < 1000) fmt("%.0fm", it) else fmt("%.1fkm", it / 1000.0)
}
?.let { "$it" } ?: ""

// Layout constants
val spaceBetweenTagChips = 6.dp
Expand Down

0 comments on commit 26ee0d4

Please sign in to comment.