aboutsummaryrefslogtreecommitdiff
path: root/shared/src/commonMain
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
commit3e15173c529b2b307e813288f4728f5110fb5a78 (patch)
treee0bb58b98b6667a01190ed25b4b24d29a1c71568 /shared/src/commonMain
parent793ccb0b907ac4b1364efd3e9a8df558c0346249 (diff)
downloadetbsa-trackermap-mobile-3e15173c529b2b307e813288f4728f5110fb5a78.tar.gz
etbsa-trackermap-mobile-3e15173c529b2b307e813288f4728f5110fb5a78.tar.bz2
etbsa-trackermap-mobile-3e15173c529b2b307e813288f4728f5110fb5a78.zip
Implemented formatSpeed, redesigned UnitInformationFragment, added button to open device location in map, minor UI tweaks and added translations.
Diffstat (limited to 'shared/src/commonMain')
-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