| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- import SwiftUI
- struct SidebarView: View {
- @Bindable var viewModel: FrontPageViewModel
- var body: some View {
- VStack(spacing: 0) {
- header
- navigationSections
- Spacer(minLength: 0)
- upgradeCard
- }
- .frame(width: AppTheme.sidebarWidth)
- .background(AppTheme.sidebarBackground)
- .overlay(alignment: .trailing) {
- Rectangle()
- .fill(AppTheme.border)
- .frame(width: 1)
- }
- }
- private var header: some View {
- HStack(spacing: AppTheme.sidebarRowSpacing) {
- ZStack {
- RoundedRectangle(cornerRadius: 10)
- .fill(
- LinearGradient(
- colors: [AppTheme.accentPurpleLight, AppTheme.accentPurple],
- startPoint: .topLeading,
- endPoint: .bottomTrailing
- )
- )
- .frame(width: AppTheme.iconContainerSize, height: AppTheme.iconContainerSize)
- Image(systemName: "brain.head.profile")
- .font(.system(size: 14, weight: .semibold))
- .foregroundStyle(.white)
- }
- .frame(width: AppTheme.iconContainerSize, height: AppTheme.iconContainerSize)
- VStack(alignment: .leading, spacing: 2) {
- Text("Reddora AI")
- .font(.system(size: 15, weight: .bold))
- .foregroundStyle(AppTheme.textPrimary)
- Text("AI Assistant for Reddit")
- .font(.system(size: 10))
- .foregroundStyle(AppTheme.textSecondary)
- }
- Spacer(minLength: 0)
- }
- .padding(.horizontal, AppTheme.sidebarContentInset + AppTheme.sidebarRowPaddingH)
- .padding(.top, 20)
- .padding(.bottom, 16)
- }
- private var navigationSections: some View {
- ScrollView {
- VStack(alignment: .leading, spacing: AppTheme.sidebarSectionSpacing) {
- sidebarSection(title: SidebarSection.quickAccess.rawValue) {
- SidebarQuickAccessItemView(isSelected: viewModel.isRedditActive) {
- viewModel.openReddit()
- }
- }
- sidebarSection(title: SidebarSection.create.rawValue) {
- ForEach(viewModel.createItems) { item in
- SidebarNavItemView(item: item, isSelected: viewModel.selectedNavItem == item) {
- viewModel.selectNavItem(item)
- }
- }
- }
- sidebarSection(title: SidebarSection.analyze.rawValue) {
- ForEach(viewModel.analyzeItems) { item in
- SidebarNavItemView(item: item, isSelected: viewModel.selectedNavItem == item) {
- viewModel.selectNavItem(item)
- }
- }
- }
- }
- .padding(.horizontal, AppTheme.sidebarContentInset)
- .padding(.top, 4)
- }
- }
- private func sidebarSection<Content: View>(
- title: String,
- @ViewBuilder content: () -> Content
- ) -> some View {
- VStack(alignment: .leading, spacing: AppTheme.sidebarItemSpacing) {
- SidebarSectionHeader(title: title)
- content()
- }
- }
- private var upgradeCard: some View {
- VStack(alignment: .leading, spacing: 10) {
- HStack(spacing: 6) {
- Image(systemName: "crown.fill")
- .font(.system(size: 12))
- .foregroundStyle(AppTheme.accentYellow)
- Text("Upgrade to Pro")
- .font(.system(size: 12, weight: .semibold))
- .foregroundStyle(AppTheme.textPrimary)
- }
- Text("Unlock unlimited AI generations and advanced analytics")
- .font(.system(size: 10))
- .foregroundStyle(AppTheme.textSecondary)
- .fixedSize(horizontal: false, vertical: true)
- .lineSpacing(2)
- Button("Upgrade Now") {}
- .font(.system(size: 11, weight: .semibold))
- .foregroundStyle(.white)
- .frame(maxWidth: .infinity)
- .padding(.vertical, 8)
- .background(AppTheme.accentPurple)
- .clipShape(RoundedRectangle(cornerRadius: 8))
- .buttonStyle(.plain)
- }
- .padding(14)
- .background(
- RoundedRectangle(cornerRadius: AppTheme.cornerRadiusSmall)
- .fill(AppTheme.cardBackground)
- .overlay(
- RoundedRectangle(cornerRadius: AppTheme.cornerRadiusSmall)
- .stroke(AppTheme.accentPurple.opacity(0.25), lineWidth: 1)
- )
- )
- .padding(.horizontal, AppTheme.sidebarContentInset)
- .padding(.top, 12)
- .padding(.bottom, 20)
- .overlay(alignment: .top) {
- Rectangle()
- .fill(AppTheme.border)
- .frame(height: 1)
- }
- }
- }
|