SettingsView.swift 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. import SwiftUI
  2. struct SettingsView: View {
  3. @Bindable var viewModel: SettingsViewModel
  4. private enum Layout {
  5. static let horizontalPadding: CGFloat = 24
  6. }
  7. var body: some View {
  8. VStack(spacing: 0) {
  9. header
  10. ScrollView {
  11. VStack(alignment: .leading, spacing: 12) {
  12. shareSection
  13. linksSection
  14. }
  15. .frame(maxWidth: .infinity, alignment: .leading)
  16. .padding(.horizontal, Layout.horizontalPadding)
  17. .padding(.top, 12)
  18. .padding(.bottom, 24)
  19. }
  20. }
  21. .background(AppTheme.background)
  22. }
  23. private var header: some View {
  24. HStack(spacing: 14) {
  25. ModernSidebarIconView(kind: .settings, size: 40)
  26. VStack(alignment: .leading, spacing: 2) {
  27. Text("Settings")
  28. .font(.system(size: 18, weight: .semibold))
  29. .foregroundStyle(AppTheme.textPrimary)
  30. Text("Manage app preferences")
  31. .font(.system(size: 11))
  32. .foregroundStyle(AppTheme.textSecondary)
  33. }
  34. Spacer()
  35. }
  36. .padding(.horizontal, 24)
  37. .padding(.vertical, 16)
  38. .overlay(alignment: .bottom) {
  39. Rectangle()
  40. .fill(AppTheme.border)
  41. .frame(height: 1)
  42. }
  43. }
  44. private var shareSection: some View {
  45. PostFormCard(
  46. title: "Share",
  47. subtitle: "Spread the word about \(AppLinks.appName)"
  48. ) {
  49. SettingsShareAppButton(
  50. message: viewModel.shareMessage,
  51. url: viewModel.shareURL
  52. )
  53. }
  54. }
  55. private var linksSection: some View {
  56. PostFormCard(
  57. title: "About",
  58. subtitle: "Website, legal, and help resources"
  59. ) {
  60. VStack(spacing: 8) {
  61. SettingsLinkRow(
  62. icon: "globe",
  63. title: "Website",
  64. subtitle: AppLinks.website.host
  65. ) {
  66. viewModel.openWebsite()
  67. }
  68. SettingsLinkRow(
  69. icon: "hand.raised.fill",
  70. title: "Privacy Policy",
  71. subtitle: "How we handle your data"
  72. ) {
  73. viewModel.openPrivacyPolicy()
  74. }
  75. SettingsLinkRow(
  76. icon: "doc.text.fill",
  77. title: "Terms & Conditions",
  78. subtitle: "Terms of service"
  79. ) {
  80. viewModel.openTermsAndConditions()
  81. }
  82. SettingsLinkRow(
  83. icon: "lifepreserver.fill",
  84. title: "Support",
  85. subtitle: "Get help or send feedback"
  86. ) {
  87. viewModel.openSupport()
  88. }
  89. }
  90. }
  91. }
  92. }
  93. #Preview {
  94. SettingsView(viewModel: SettingsViewModel())
  95. .frame(width: 800, height: 600)
  96. }