// // ChannelLock.swift // Meshtastic // // Copyright(c) Garth Vander Houwen 6/22/25. // import SwiftUI struct ChannelLock: View { @Bindable var channel: ChannelEntity var body: some View { /// Unencrypted - using no key at all or a known 1 byte key if channel.psk?.hexDescription.count ?? 0 < 3 { let preciseLoction = 17...32 // Using precise location and have MQTT uplink enabled if channel.uplinkEnabled && preciseLoction ~= (Int(channel.positionPrecision)) { Image(systemName: "lock.open.trianglebadge.exclamationmark.fill") .foregroundColor(.red) // Using precise location } else if preciseLoction ~= (Int(channel.positionPrecision)) { Image(systemName: "lock.open.fill") .foregroundColor(.red) // Just unencrypted without any location or MQTT } else { Image(systemName: "lock.open.fill") .foregroundColor(.yellow) } } else { Image(systemName: "lock.fill") .foregroundColor(.green) } } } // TODO: Fix preview for SwiftData /* #Preview { let encryptedChannel = ChannelEntity() encryptedChannel.psk = Data([0x01, 0x02, 0x03, 0x04]) let unencryptedChannel = ChannelEntity() unencryptedChannel.psk = Data() HStack(spacing: 16) { ChannelLock(channel: encryptedChannel) ChannelLock(channel: unencryptedChannel) } } */