diff options
Diffstat (limited to 'iosApp/iosApp/Details/Information/UnitInformationView.swift')
-rw-r--r-- | iosApp/iosApp/Details/Information/UnitInformationView.swift | 146 |
1 files changed, 81 insertions, 65 deletions
diff --git a/iosApp/iosApp/Details/Information/UnitInformationView.swift b/iosApp/iosApp/Details/Information/UnitInformationView.swift index 3a52b84..f713ab4 100644 --- a/iosApp/iosApp/Details/Information/UnitInformationView.swift +++ b/iosApp/iosApp/Details/Information/UnitInformationView.swift @@ -23,80 +23,96 @@ struct UnitInformationView: View { var body: some View { List { - // MARK: - Contact - if let contact = unit.device.contact { - HStack { - Text("contact") - Spacer() - Text(contact).foregroundColor(.secondaryLabel) + Section { + // 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: - 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: - 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: - 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: - 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: - 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: - 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: - 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) + } } } - // MARK: - Protocol - if let protocol_ = unit.position?.protocol { - HStack { - Text("protocol") - Spacer() - Text(protocol_).foregroundColor(.secondaryLabel) + Section { + Button { + if let longitude = unit.position?.longitude, + let latitude = unit.position?.latitude, + let url = Utils.getMapsURL(longitude: Float(truncating: longitude), + latitude: Float(truncating: latitude)) { + if UIApplication.shared.canOpenURL(url) { + UIApplication.shared.open(url, options: [:]) + } + } + } label: { + Label("open-location-browser", systemImage: "globe") } } } |