2022-05-25 22:30:48 -07:00
|
|
|
import SwiftUI
|
|
|
|
|
//
|
|
|
|
|
// LastHeardText.swift
|
|
|
|
|
// Meshtastic Apple
|
|
|
|
|
//
|
|
|
|
|
// Created by Garth Vander Houwen on 5/25/22.
|
|
|
|
|
//
|
|
|
|
|
struct LastHeardText: View {
|
|
|
|
|
var lastHeard: Date?
|
|
|
|
|
let sixMonthsAgo = Calendar.current.date(byAdding: .month, value: -6, to: Date())
|
|
|
|
|
var body: some View {
|
2023-03-06 10:33:18 -08:00
|
|
|
if lastHeard != nil && lastHeard! >= sixMonthsAgo! {
|
2023-04-01 02:35:31 -07:00
|
|
|
Text("heard")+Text(" \(lastHeard!, style: .relative) ")+Text("ago")
|
2022-05-25 22:30:48 -07:00
|
|
|
} else {
|
2022-12-12 20:35:38 -08:00
|
|
|
Text("unknown.age")
|
2022-05-25 22:30:48 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-12-12 20:35:38 -08:00
|
|
|
struct LastHeardText_Previews: PreviewProvider {
|
|
|
|
|
static var previews: some View {
|
|
|
|
|
LastHeardText(lastHeard: Date())
|
|
|
|
|
.previewLayout(.fixed(width: 300, height: 100))
|
|
|
|
|
.environment(\.locale, .init(identifier: "en"))
|
|
|
|
|
LastHeardText(lastHeard: Date())
|
|
|
|
|
.previewLayout(.fixed(width: 300, height: 100))
|
|
|
|
|
.environment(\.locale, .init(identifier: "de"))
|
|
|
|
|
}
|
|
|
|
|
}
|