MainView.swift 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. import SwiftUI
  2. struct MainView: View {
  3. @StateObject private var viewModel = MainViewModel()
  4. var body: some View {
  5. Group {
  6. if viewModel.isShowingPaywall {
  7. PaywallView(onClose: viewModel.hidePaywall)
  8. .transition(.opacity)
  9. } else {
  10. HStack(spacing: 0) {
  11. SidebarView(
  12. selectedDestination: $viewModel.selectedDestination,
  13. onUpgradeTapped: viewModel.showPaywall
  14. )
  15. .frame(maxHeight: .infinity)
  16. Rectangle()
  17. .fill(AppTheme.border)
  18. .frame(width: 1)
  19. .frame(maxHeight: .infinity)
  20. .ignoresSafeArea(edges: .top)
  21. ZStack {
  22. BackgroundDecorations()
  23. contentView
  24. .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
  25. }
  26. .frame(maxWidth: .infinity, maxHeight: .infinity)
  27. }
  28. .background {
  29. AppTheme.background
  30. .ignoresSafeArea(edges: .top)
  31. }
  32. }
  33. }
  34. .animation(.easeInOut(duration: 0.2), value: viewModel.isShowingPaywall)
  35. }
  36. @ViewBuilder
  37. private var contentView: some View {
  38. switch viewModel.selectedDestination {
  39. case .grammarChecker:
  40. GrammarCheckerView()
  41. default:
  42. PlaceholderView(destination: viewModel.selectedDestination)
  43. }
  44. }
  45. }