import SwiftUI struct ContactActionRow: View { let icon: String let title: String let subtitle: String let iconColor: Color let action: (() -> Void)? @Environment(\.horizontalSizeClass) private var horizontalSizeClass init(icon: String, title: String, subtitle: String, iconColor: Color, action: (() -> Void)? = nil) { self.icon = icon self.title = title self.subtitle = subtitle self.iconColor = iconColor self.action = action } var body: some View { Group { if let action = action { Button(action: action) { content } .buttonStyle(.plain) } else { content } } } private var content: some View { HStack(spacing: 16) { Image(systemName: icon) .font(.title2) .foregroundColor(iconColor) .frame(width: 24) VStack(alignment: .leading, spacing: 4) { Text(title) .font(.system(size: horizontalSizeClass == .regular ? 16 : 14, weight: .semibold)) .foregroundColor(.primary) Text(subtitle) .font(.system(size: horizontalSizeClass == .regular ? 15 : 13, weight: .regular)) .foregroundColor(.secondary) .multilineTextAlignment(.leading) } Spacer() if action != nil { Image(systemName: "arrow.up.right.square") .font(.caption) .foregroundColor(.secondary) } else { Image(systemName: "chevron.right") .font(.caption) .foregroundColor(.secondary) } } .padding(.vertical, 12) .contentShape(Rectangle()) } } // MARK: - Contact Actions Helper struct ContactActions { static func callAction(phoneNumber: String) -> (() -> Void)? { guard UIDevice.current.userInterfaceIdiom == .phone else { return nil } return { let digitsOnly = phoneNumber.filter { $0.isNumber } let phoneURL = URL(string: "tel://\(digitsOnly)") if let url = phoneURL, UIApplication.shared.canOpenURL(url) { UIApplication.shared.open(url) } } } static func emailAction(email: String) -> () -> Void { return { if let url = URL(string: "mailto:\(email)") { UIApplication.shared.open(url) } } } static func directionsAction(address: String) -> () -> Void { return { let encodedAddress = address.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed) ?? address if let url = URL(string: "https://maps.apple.com/?address=\(encodedAddress)") { UIApplication.shared.open(url) } } } }