aboutsummaryrefslogtreecommitdiff
path: root/iosApp/iosApp/Details/Information/UnitInformationView.swift
diff options
context:
space:
mode:
Diffstat (limited to 'iosApp/iosApp/Details/Information/UnitInformationView.swift')
-rw-r--r--iosApp/iosApp/Details/Information/UnitInformationView.swift104
1 files changed, 104 insertions, 0 deletions
diff --git a/iosApp/iosApp/Details/Information/UnitInformationView.swift b/iosApp/iosApp/Details/Information/UnitInformationView.swift
new file mode 100644
index 0000000..3a52b84
--- /dev/null
+++ b/iosApp/iosApp/Details/Information/UnitInformationView.swift
@@ -0,0 +1,104 @@
+/**
+ * TrackerMap
+ * Copyright (C) 2021-2022 Iván Ávalos <avalos@disroot.org>, Henoch Ojeda <imhenoch@protonmail.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+import SwiftUI
+import shared
+
+struct UnitInformationView: View {
+ var unit: UnitInformation
+
+ var body: some View {
+ List {
+ // MARK: - Contact
+ if let contact = unit.device.contact {
+ HStack {
+ Text("contact")
+ Spacer()
+ Text(contact).foregroundColor(.secondaryLabel)
+ }
+ }
+ // MARK: - Unique ID
+ if let uniqueId = unit.device.uniqueId {
+ HStack {
+ Text("unique-id")
+ Spacer()
+ Text(uniqueId).foregroundColor(.secondaryLabel)
+ }
+ }
+ // MARK: - Date time
+ if let datetime = unit.position?.fixTime {
+ HStack {
+ Text("datetime")
+ Spacer()
+ Text(Formatter.companion.formatDate(str: datetime))
+ .foregroundColor(.secondaryLabel)
+ }
+ }
+ // MARK: - Latitude
+ if let latitude = unit.position?.latitude {
+ HStack {
+ Text("latitude")
+ Spacer()
+ Text("\(latitude)").foregroundColor(.secondaryLabel)
+ }
+ }
+ // MARK: - Longitude
+ if let longitude = unit.position?.longitude {
+ HStack {
+ Text("longitude")
+ Spacer()
+ Text("\(longitude)").foregroundColor(.secondaryLabel)
+ }
+ }
+ // MARK: - Speed
+ if let speed = unit.position?.speed {
+ HStack {
+ Text("speed")
+ Spacer()
+ Text(Formatter.companion.formatSpeed(
+ speed: Double(truncating: speed), unit: .kmh))
+ .foregroundColor(.secondaryLabel)
+ }
+ }
+ // MARK: - Address
+ if let address = unit.position?.address {
+ HStack {
+ Text("address")
+ Spacer()
+ Text(address).foregroundColor(.secondaryLabel)
+ }
+ }
+ // MARK: - Hours
+ if let hours = unit.getHourmeter() {
+ HStack {
+ Text("hourmeter")
+ Spacer()
+ Text(Formatter.companion.formatHours(millis: Int64(truncating: hours)))
+ .foregroundColor(.secondaryLabel)
+ }
+ }
+ // MARK: - Protocol
+ if let protocol_ = unit.position?.protocol {
+ HStack {
+ Text("protocol")
+ Spacer()
+ Text(protocol_).foregroundColor(.secondaryLabel)
+ }
+ }
+ }
+ }
+}