| 12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- import SwiftUI
- struct RootView: View {
- @EnvironmentObject private var subscriptions: SubscriptionManager
- let session: AppSessionState
- @Bindable var splashViewModel: SplashViewModel
- var body: some View {
- ZStack {
- FrontPageView(session: session)
- if splashViewModel.isVisible {
- SplashScreenView(viewModel: splashViewModel)
- .transition(.opacity)
- .zIndex(1)
- }
- }
- .animation(.easeInOut(duration: 0.45), value: splashViewModel.isVisible)
- .task {
- async let splash: Void = splashViewModel.runIfNeeded()
- async let entitlements: Void = subscriptions.ensureEntitlementsResolved()
- _ = await (splash, entitlements)
- syncToolSubscriptionState()
- }
- }
- private func syncToolSubscriptionState() {
- let hasPremium = subscriptions.hasPremiumAccess
- let hasEverPurchased = subscriptions.hasEverPurchasedPremium
- session.postGenerator.setSubscriptionState(
- hasPremiumAccess: hasPremium,
- hasEverPurchasedPremium: hasEverPurchased
- )
- session.titleOptimizer.setSubscriptionState(
- hasPremiumAccess: hasPremium,
- hasEverPurchasedPremium: hasEverPurchased
- )
- session.commentWriter.setSubscriptionState(
- hasPremiumAccess: hasPremium,
- hasEverPurchasedPremium: hasEverPurchased
- )
- }
- }
|