BusinessCard/BusinessCardWatch/Models/WatchCard.swift

69 lines
1.9 KiB
Swift

import Foundation
/// 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
var vCardPayload: String {
let lines = [
"BEGIN:VCARD",
"VERSION:3.0",
"FN:\(displayName)",
"ORG:\(company)",
"TITLE:\(role)",
"TEL;TYPE=work:\(phone)",
"EMAIL;TYPE=work:\(email)",
"URL:\(website)",
"ADR;TYPE=work:;;\(location)",
"END:VCARD"
]
return lines.joined(separator: "\n")
}
}
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
),
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
),
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
)
]
}