SidebarView.swift 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. import SwiftUI
  2. struct SidebarView: View {
  3. @Bindable var viewModel: FrontPageViewModel
  4. var body: some View {
  5. VStack(spacing: 0) {
  6. header
  7. navigationSections
  8. Spacer(minLength: 0)
  9. upgradeCard
  10. }
  11. .frame(width: AppTheme.sidebarWidth)
  12. .background(AppTheme.sidebarBackground)
  13. .overlay(alignment: .trailing) {
  14. Rectangle()
  15. .fill(AppTheme.border)
  16. .frame(width: 1)
  17. }
  18. }
  19. private var header: some View {
  20. HStack(spacing: AppTheme.sidebarRowSpacing) {
  21. ZStack {
  22. RoundedRectangle(cornerRadius: 10)
  23. .fill(
  24. LinearGradient(
  25. colors: [AppTheme.accentPurpleLight, AppTheme.accentPurple],
  26. startPoint: .topLeading,
  27. endPoint: .bottomTrailing
  28. )
  29. )
  30. .frame(width: AppTheme.iconContainerSize, height: AppTheme.iconContainerSize)
  31. Image(systemName: "brain.head.profile")
  32. .font(.system(size: 14, weight: .semibold))
  33. .foregroundStyle(.white)
  34. }
  35. .frame(width: AppTheme.iconContainerSize, height: AppTheme.iconContainerSize)
  36. VStack(alignment: .leading, spacing: 2) {
  37. Text("Reddora AI")
  38. .font(.system(size: 15, weight: .bold))
  39. .foregroundStyle(AppTheme.textPrimary)
  40. Text("AI Assistant for Reddit")
  41. .font(.system(size: 10))
  42. .foregroundStyle(AppTheme.textSecondary)
  43. }
  44. Spacer(minLength: 0)
  45. }
  46. .padding(.horizontal, AppTheme.sidebarContentInset + AppTheme.sidebarRowPaddingH)
  47. .padding(.top, 20)
  48. .padding(.bottom, 16)
  49. }
  50. private var navigationSections: some View {
  51. ScrollView {
  52. VStack(alignment: .leading, spacing: AppTheme.sidebarSectionSpacing) {
  53. sidebarSection(title: SidebarSection.quickAccess.rawValue) {
  54. SidebarQuickAccessItemView(isSelected: viewModel.isRedditActive) {
  55. viewModel.openReddit()
  56. }
  57. }
  58. sidebarSection(title: SidebarSection.create.rawValue) {
  59. ForEach(viewModel.createItems) { item in
  60. SidebarNavItemView(item: item, isSelected: viewModel.selectedNavItem == item) {
  61. viewModel.selectNavItem(item)
  62. }
  63. }
  64. }
  65. sidebarSection(title: SidebarSection.analyze.rawValue) {
  66. ForEach(viewModel.analyzeItems) { item in
  67. SidebarNavItemView(item: item, isSelected: viewModel.selectedNavItem == item) {
  68. viewModel.selectNavItem(item)
  69. }
  70. }
  71. }
  72. }
  73. .padding(.horizontal, AppTheme.sidebarContentInset)
  74. .padding(.top, 4)
  75. }
  76. }
  77. private func sidebarSection<Content: View>(
  78. title: String,
  79. @ViewBuilder content: () -> Content
  80. ) -> some View {
  81. VStack(alignment: .leading, spacing: AppTheme.sidebarItemSpacing) {
  82. SidebarSectionHeader(title: title)
  83. content()
  84. }
  85. }
  86. private var upgradeCard: some View {
  87. VStack(alignment: .leading, spacing: 10) {
  88. HStack(spacing: 6) {
  89. Image(systemName: "crown.fill")
  90. .font(.system(size: 12))
  91. .foregroundStyle(AppTheme.accentYellow)
  92. Text("Upgrade to Pro")
  93. .font(.system(size: 12, weight: .semibold))
  94. .foregroundStyle(AppTheme.textPrimary)
  95. }
  96. Text("Unlock unlimited AI generations and advanced analytics")
  97. .font(.system(size: 10))
  98. .foregroundStyle(AppTheme.textSecondary)
  99. .fixedSize(horizontal: false, vertical: true)
  100. .lineSpacing(2)
  101. Button("Upgrade Now") {}
  102. .font(.system(size: 11, weight: .semibold))
  103. .foregroundStyle(.white)
  104. .frame(maxWidth: .infinity)
  105. .padding(.vertical, 8)
  106. .background(AppTheme.accentPurple)
  107. .clipShape(RoundedRectangle(cornerRadius: 8))
  108. .buttonStyle(.plain)
  109. }
  110. .padding(14)
  111. .background(
  112. RoundedRectangle(cornerRadius: AppTheme.cornerRadiusSmall)
  113. .fill(AppTheme.cardBackground)
  114. .overlay(
  115. RoundedRectangle(cornerRadius: AppTheme.cornerRadiusSmall)
  116. .stroke(AppTheme.accentPurple.opacity(0.25), lineWidth: 1)
  117. )
  118. )
  119. .padding(.horizontal, AppTheme.sidebarContentInset)
  120. .padding(.top, 12)
  121. .padding(.bottom, 20)
  122. .overlay(alignment: .top) {
  123. Rectangle()
  124. .fill(AppTheme.border)
  125. .frame(height: 1)
  126. }
  127. }
  128. }