SettingsComponents.swift 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. import SwiftUI
  2. struct SettingsShareAppButton: View {
  3. let message: String
  4. let url: URL
  5. var body: some View {
  6. ShareLink(item: url, message: Text(message)) {
  7. HStack(spacing: 14) {
  8. Image(systemName: "square.and.arrow.up")
  9. .font(.system(size: 16, weight: .semibold))
  10. .foregroundStyle(.white)
  11. .frame(width: 40, height: 40)
  12. .background(
  13. RoundedRectangle(cornerRadius: 10)
  14. .fill(AppTheme.accentPurple)
  15. )
  16. VStack(alignment: .leading, spacing: 2) {
  17. Text("Share App")
  18. .font(.system(size: 14, weight: .semibold))
  19. .foregroundStyle(AppTheme.textPrimary)
  20. Text("Tell friends about \(AppLinks.appName)")
  21. .font(.system(size: 11))
  22. .foregroundStyle(AppTheme.textSecondary)
  23. }
  24. Spacer()
  25. Image(systemName: "chevron.right")
  26. .font(.system(size: 11, weight: .semibold))
  27. .foregroundStyle(AppTheme.textTertiary)
  28. }
  29. .padding(14)
  30. .background(
  31. RoundedRectangle(cornerRadius: AppTheme.cornerRadiusSmall)
  32. .fill(AppTheme.cardBackground)
  33. .overlay(
  34. RoundedRectangle(cornerRadius: AppTheme.cornerRadiusSmall)
  35. .stroke(AppTheme.accentPurple.opacity(0.35), lineWidth: 1)
  36. )
  37. )
  38. }
  39. .buttonStyle(AppPlainButtonStyle())
  40. .hoverCard(cornerRadius: AppTheme.cornerRadiusSmall)
  41. .frame(maxWidth: .infinity, alignment: .leading)
  42. }
  43. }
  44. struct SettingsToggleRow: View {
  45. let icon: String
  46. let title: String
  47. var subtitle: String?
  48. @Binding var isOn: Bool
  49. var body: some View {
  50. HStack(spacing: 12) {
  51. Image(systemName: icon)
  52. .font(.system(size: 14, weight: .medium))
  53. .foregroundStyle(AppTheme.accentPurple)
  54. .frame(width: 32, height: 32)
  55. .background(
  56. RoundedRectangle(cornerRadius: 8)
  57. .fill(AppTheme.accentPurple.opacity(0.12))
  58. )
  59. VStack(alignment: .leading, spacing: 2) {
  60. Text(title)
  61. .font(.system(size: 13, weight: .medium))
  62. .foregroundStyle(AppTheme.textPrimary)
  63. if let subtitle {
  64. Text(subtitle)
  65. .font(.system(size: 10))
  66. .foregroundStyle(AppTheme.textSecondary)
  67. }
  68. }
  69. Spacer()
  70. Toggle("", isOn: $isOn)
  71. .labelsHidden()
  72. .toggleStyle(.switch)
  73. }
  74. .padding(.horizontal, 12)
  75. .padding(.vertical, 10)
  76. .background(AppTheme.panelBackground)
  77. .clipShape(RoundedRectangle(cornerRadius: 8))
  78. .overlay(
  79. RoundedRectangle(cornerRadius: 8)
  80. .stroke(AppTheme.cardBorder, lineWidth: 1)
  81. )
  82. .frame(maxWidth: .infinity, alignment: .leading)
  83. }
  84. }
  85. struct SettingsLinkRow: View {
  86. let icon: String
  87. let title: String
  88. var subtitle: String?
  89. let action: () -> Void
  90. var body: some View {
  91. Button(action: action) {
  92. HStack(spacing: 12) {
  93. Image(systemName: icon)
  94. .font(.system(size: 14, weight: .medium))
  95. .foregroundStyle(AppTheme.accentPurple)
  96. .frame(width: 32, height: 32)
  97. .background(
  98. RoundedRectangle(cornerRadius: 8)
  99. .fill(AppTheme.accentPurple.opacity(0.12))
  100. )
  101. VStack(alignment: .leading, spacing: 2) {
  102. Text(title)
  103. .font(.system(size: 13, weight: .medium))
  104. .foregroundStyle(AppTheme.textPrimary)
  105. if let subtitle {
  106. Text(subtitle)
  107. .font(.system(size: 10))
  108. .foregroundStyle(AppTheme.textSecondary)
  109. }
  110. }
  111. Spacer()
  112. Image(systemName: "arrow.up.right")
  113. .font(.system(size: 11, weight: .medium))
  114. .foregroundStyle(AppTheme.textTertiary)
  115. }
  116. .padding(.horizontal, 12)
  117. .padding(.vertical, 10)
  118. .background(AppTheme.panelBackground)
  119. .clipShape(RoundedRectangle(cornerRadius: 8))
  120. .overlay(
  121. RoundedRectangle(cornerRadius: 8)
  122. .stroke(AppTheme.cardBorder, lineWidth: 1)
  123. )
  124. }
  125. .buttonStyle(AppPlainButtonStyle())
  126. .hoverCard(cornerRadius: 8)
  127. .frame(maxWidth: .infinity, alignment: .leading)
  128. }
  129. }