RTSDA-iOS/Views/Components/ContactActionRow.swift
RTSDA 00679f927c docs: Update README for v2.0 release and fix git remote URL
- Comprehensive README update documenting v2.0 architectural changes
- Updated git remote to ssh://rockvilleav@git.rockvilletollandsda.church:10443/RTSDA/RTSDA-iOS.git
- Documented unified ChurchService and 60% code reduction
- Added new features: Home Feed, responsive reading, enhanced UI
- Corrected license information (GPL v3 with church content copyright)
- Updated build instructions and technical stack details
2025-08-16 18:41:51 -04:00

99 lines
3 KiB
Swift

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)
}
}
}
}