Meshtastic-Apple/Meshtastic/Views/Settings/AdminMessageList.swift
2022-07-26 21:52:36 -07:00

68 lines
1.6 KiB
Swift

//
// AdminMessageList.swift
// Meshtastic
//
// Created by Garth Vander Houwen on 7/2/22.
//
/*
Abstract:
A view showing the details for a node.
*/
import SwiftUI
import MapKit
import CoreLocation
struct AdminMessageList: View {
@Environment(\.managedObjectContext) var context
@EnvironmentObject var bleManager: BLEManager
var user: UserEntity?
var body: some View {
List {
if user != nil {
ForEach ( user!.adminMessageList ) { am in
HStack {
Text("\(am.adminDescription ?? "Unknown") - \(Date(timeIntervalSince1970: TimeInterval(am.messageTimestamp)), style: .date) \(Date(timeIntervalSince1970: TimeInterval(am.messageTimestamp)).formattedDate(format: "h:mm:ss a"))")
.font(.caption)
if am.receivedACK {
Image(systemName: "checkmark.square")
.foregroundColor(.gray)
.font(.caption)
Text("Acknowledged: \(Date(timeIntervalSince1970: TimeInterval(am.ackTimestamp)).formattedDate(format: "h:mm:ss a"))")
.foregroundColor(.gray)
.font(.caption)
} else {
Image(systemName: "square")
.foregroundColor(.gray)
.font(.caption)
Text("Not Acknowledged")
.foregroundColor(.gray)
.font(.caption)
}
}
}
}
}
.navigationTitle("Admin Message Log")
.navigationBarItems(trailing:
ZStack {
ConnectedDevice(bluetoothOn: bleManager.isSwitchedOn, deviceConnected: bleManager.connectedPeripheral != nil, name: (bleManager.connectedPeripheral != nil) ? bleManager.connectedPeripheral.shortName : "????")
})
.onAppear {
self.bleManager.context = context
}
}
}