aboutsummaryrefslogtreecommitdiff
path: root/shared
diff options
context:
space:
mode:
authorIván Ávalos <avalos@disroot.org>2022-01-04 22:37:36 -0600
committerIván Ávalos <avalos@disroot.org>2022-01-04 22:37:36 -0600
commita43ed464b9dc0f7700e87e70bb60c588628d89a0 (patch)
treec2a98d78d1d82c46390af0717d2249acbd0520bd /shared
parentdc7e37b108bd4f63fb67b6d969518d5fbab41a6e (diff)
downloadetbsa-trackermap-mobile-a43ed464b9dc0f7700e87e70bb60c588628d89a0.tar.gz
etbsa-trackermap-mobile-a43ed464b9dc0f7700e87e70bb60c588628d89a0.tar.bz2
etbsa-trackermap-mobile-a43ed464b9dc0f7700e87e70bb60c588628d89a0.zip
Implemented formatSpeed, redesigned UnitInformationFragment, added button to open device location in map, minor UI tweaks and added translations.
Diffstat (limited to 'shared')
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/Formatter.kt15
-rw-r--r--shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/SpeedUnit.kt5
2 files changed, 20 insertions, 0 deletions
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/Formatter.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/Formatter.kt
index 133c028..af4e14d 100644
--- a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/Formatter.kt
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/Formatter.kt
@@ -1,6 +1,7 @@
package mx.trackermap.TrackerMap.utils
import kotlinx.datetime.*
+import kotlin.math.round
class Formatter {
companion object {
@@ -8,5 +9,19 @@ class Formatter {
return date.substring(0 until date.indexOf('+'))
.toLocalDateTime().toString().replace('T', ' ')
}
+
+ fun formatSpeed(speed: Double, unit: SpeedUnit): String {
+ return when (unit) {
+ SpeedUnit.KMH -> {
+ "${(speed * 1.852).toInt()} km/h"
+ }
+ SpeedUnit.MPH -> {
+ "${(speed * 1.15078).toInt()} mph"
+ }
+ SpeedUnit.KN -> {
+ "${speed.toInt()} kn"
+ }
+ }
+ }
}
} \ No newline at end of file
diff --git a/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/SpeedUnit.kt b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/SpeedUnit.kt
new file mode 100644
index 0000000..bc9cdb4
--- /dev/null
+++ b/shared/src/commonMain/kotlin/mx/trackermap/TrackerMap/utils/SpeedUnit.kt
@@ -0,0 +1,5 @@
+package mx.trackermap.TrackerMap.utils
+
+enum class SpeedUnit {
+ KMH, MPH, KN
+} \ No newline at end of file