| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- import SwiftUI
- struct MainView: View {
- @StateObject private var viewModel = MainViewModel()
- var body: some View {
- Group {
- if viewModel.isShowingPaywall {
- PaywallView(onClose: viewModel.hidePaywall)
- .transition(.opacity)
- } else {
- HStack(spacing: 0) {
- SidebarView(
- selectedDestination: $viewModel.selectedDestination,
- onUpgradeTapped: viewModel.showPaywall
- )
- .frame(maxHeight: .infinity)
- Rectangle()
- .fill(AppTheme.border)
- .frame(width: 1)
- .frame(maxHeight: .infinity)
- .ignoresSafeArea(edges: .top)
- ZStack {
- BackgroundDecorations()
- contentView
- .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)
- }
- .frame(maxWidth: .infinity, maxHeight: .infinity)
- }
- .background {
- AppTheme.background
- .ignoresSafeArea(edges: .top)
- }
- }
- }
- .animation(.easeInOut(duration: 0.2), value: viewModel.isShowingPaywall)
- }
- @ViewBuilder
- private var contentView: some View {
- switch viewModel.selectedDestination {
- case .grammarChecker:
- GrammarCheckerView()
- default:
- PlaceholderView(destination: viewModel.selectedDestination)
- }
- }
- }
|