66 lines
1.9 KiB
Swift
66 lines
1.9 KiB
Swift
import Foundation
|
|
import SwiftUI
|
|
|
|
/// A simplified card structure synced from the iOS app via App Group UserDefaults
|
|
struct WatchCard: Codable, Identifiable, Hashable {
|
|
let id: UUID
|
|
var displayName: String
|
|
var role: String
|
|
var company: String
|
|
var email: String
|
|
var phone: String
|
|
var website: String
|
|
var location: String
|
|
var isDefault: Bool
|
|
/// Pre-generated QR code PNG data from iOS (CoreImage not available on watchOS)
|
|
var qrCodeImageData: Data?
|
|
|
|
/// Returns a SwiftUI Image from the synced QR code data
|
|
var qrCodeImage: Image? {
|
|
guard let data = qrCodeImageData,
|
|
let uiImage = UIImage(data: data) else { return nil }
|
|
return Image(uiImage: uiImage)
|
|
}
|
|
}
|
|
|
|
extension WatchCard {
|
|
static let samples: [WatchCard] = [
|
|
WatchCard(
|
|
id: UUID(),
|
|
displayName: "Daniel Sullivan",
|
|
role: "Property Developer",
|
|
company: "WR Construction",
|
|
email: "daniel@wrconstruction.co",
|
|
phone: "+1 (214) 987-7810",
|
|
website: "wrconstruction.co",
|
|
location: "Dallas, TX",
|
|
isDefault: true,
|
|
qrCodeImageData: nil
|
|
),
|
|
WatchCard(
|
|
id: UUID(),
|
|
displayName: "Maya Chen",
|
|
role: "Creative Lead",
|
|
company: "Signal Studio",
|
|
email: "maya@signal.studio",
|
|
phone: "+1 (312) 404-2211",
|
|
website: "signal.studio",
|
|
location: "Chicago, IL",
|
|
isDefault: false,
|
|
qrCodeImageData: nil
|
|
),
|
|
WatchCard(
|
|
id: UUID(),
|
|
displayName: "DJ Michaels",
|
|
role: "DJ",
|
|
company: "Live Sessions",
|
|
email: "dj@livesessions.fm",
|
|
phone: "+1 (646) 222-3300",
|
|
website: "livesessions.fm",
|
|
location: "New York, NY",
|
|
isDefault: false,
|
|
qrCodeImageData: nil
|
|
)
|
|
]
|
|
}
|