Pārlūkot izejas kodu

Add Settings navigation with a dedicated sidebar section and placeholder view.

Co-authored-by: Cursor <cursoragent@cursor.com>
AhtashamShahzad1 1 mēnesi atpakaļ
vecāks
revīzija
fdc3d1895b

+ 1 - 0
Reddit App/Models/NavigationModels.swift

@@ -10,6 +10,7 @@ struct SidebarNavItem: Identifiable, Hashable {
 enum SidebarSection: String, CaseIterable, Identifiable {
     case quickAccess = "QUICK ACCESS"
     case create = "CREATE"
+    case settings = "SETTINGS"
 
     var id: String { rawValue }
 }

+ 3 - 0
Reddit App/Models/SidebarIconKind.swift

@@ -4,12 +4,14 @@ enum SidebarIconKind: Hashable {
     case postGenerator
     case titleOptimizer
     case commentWriter
+    case settings
 
     var systemImage: String {
         switch self {
         case .postGenerator: "square.and.pencil"
         case .titleOptimizer: "textformat.size"
         case .commentWriter: "bubble.left.and.bubble.right.fill"
+        case .settings: "gearshape.fill"
         }
     }
 
@@ -18,6 +20,7 @@ enum SidebarIconKind: Hashable {
         case .postGenerator: [Color(hex: 0xC4B5FD), Color(hex: 0x7C3AED)]
         case .titleOptimizer: [Color(hex: 0x93C5FD), Color(hex: 0x2563EB)]
         case .commentWriter: [Color(hex: 0x86EFAC), Color(hex: 0x16A34A)]
+        case .settings: [Color(hex: 0x9CA3AF), Color(hex: 0x4B5563)]
         }
     }
 

+ 15 - 0
Reddit App/ViewModels/FrontPageViewModel.swift

@@ -8,18 +8,33 @@ final class FrontPageViewModel {
     private(set) var redditLoadURL = redditHomeURL
     var selectedNavItem: SidebarNavItem?
     var isRedditActive = true
+    var isSettingsActive = false
     private(set) var redditReloadTrigger = 0
 
+    static let settingsItem = SidebarNavItem(
+        title: "Settings",
+        subtitle: "Preferences & API keys",
+        iconKind: .settings
+    )
+
     func openReddit(at url: URL? = nil) {
         selectedNavItem = nil
         isRedditActive = true
+        isSettingsActive = false
         redditLoadURL = url ?? Self.redditHomeURL
         redditReloadTrigger += 1
     }
 
+    func openSettings() {
+        selectedNavItem = nil
+        isRedditActive = false
+        isSettingsActive = true
+    }
+
     func selectNavItem(_ item: SidebarNavItem) {
         selectedNavItem = item
         isRedditActive = false
+        isSettingsActive = false
     }
 
     let createItems: [SidebarNavItem] = [

+ 3 - 1
Reddit App/Views/FrontPageView.swift

@@ -29,7 +29,9 @@ struct FrontPageView: View {
             .allowsHitTesting(viewModel.isRedditActive)
             .accessibilityHidden(!viewModel.isRedditActive)
 
-            if !viewModel.isRedditActive, let item = viewModel.selectedNavItem {
+            if viewModel.isSettingsActive {
+                SettingsView()
+            } else if !viewModel.isRedditActive, let item = viewModel.selectedNavItem {
                 toolContent(for: item)
             }
         }

+ 35 - 0
Reddit App/Views/SettingsView.swift

@@ -0,0 +1,35 @@
+import SwiftUI
+
+struct SettingsView: View {
+    var body: some View {
+        VStack(spacing: 0) {
+            header
+            Spacer()
+        }
+        .background(AppTheme.background)
+    }
+
+    private var header: some View {
+        HStack(spacing: 14) {
+            ModernSidebarIconView(kind: .settings, size: 40)
+
+            VStack(alignment: .leading, spacing: 2) {
+                Text("Settings")
+                    .font(.system(size: 18, weight: .semibold))
+                    .foregroundStyle(AppTheme.textPrimary)
+                Text("Manage app preferences")
+                    .font(.system(size: 11))
+                    .foregroundStyle(AppTheme.textSecondary)
+            }
+
+            Spacer()
+        }
+        .padding(.horizontal, 24)
+        .padding(.vertical, 16)
+        .overlay(alignment: .bottom) {
+            Rectangle()
+                .fill(AppTheme.border)
+                .frame(height: 1)
+        }
+    }
+}

+ 9 - 0
Reddit App/Views/SidebarView.swift

@@ -69,6 +69,15 @@ struct SidebarView: View {
                         }
                     }
                 }
+
+                sidebarSection(title: SidebarSection.settings.rawValue) {
+                    SidebarNavItemView(
+                        item: FrontPageViewModel.settingsItem,
+                        isSelected: viewModel.isSettingsActive
+                    ) {
+                        viewModel.openSettings()
+                    }
+                }
             }
             .padding(.horizontal, AppTheme.sidebarContentInset)
             .padding(.top, 4)