import SwiftUI struct BottomPromoBanner: View { let settings: AppSettings @State private var showRemoveAdsPromo: Bool = false @State private var showPremium = false private static let counterKey = "com.mealmood.bottomBannerRotation" private static let rotationInterval = 4 var body: some View { Group { if showRemoveAdsPromo { removeAdsPromo } else { AdBannerView() } } .onAppear(perform: decideRotation) .sheet(isPresented: $showPremium) { NavigationStack { PremiumView(settings: settings, source: "ad_replacement") } } } private var removeAdsPromo: some View { VStack(spacing: 0) { Rectangle() .fill(Color.mealMoodTextSecondary.opacity(0.22)) .frame(height: 1) Button { showPremium = true } label: { HStack(spacing: 10) { Image(systemName: "star.fill") .foregroundColor(.mealMoodCoral) VStack(alignment: .leading, spacing: 1) { Text("remove_ads_promo_title") .font(.mealMoodSmall.weight(.semibold)) .foregroundColor(.mealMoodTextPrimary) Text("remove_ads_promo_subtitle") .font(.mealMoodCaption) .foregroundColor(.mealMoodTextSecondary) } Spacer() Text("remove_ads_promo_cta") .font(.mealMoodCaption.weight(.semibold)) .foregroundColor(.white) .padding(.horizontal, 12) .padding(.vertical, 6) .background(Color.mealMoodCoral) .clipShape(Capsule()) } .padding(.horizontal, 14) } .buttonStyle(.plain) .frame(maxWidth: .infinity, minHeight: 56) .background(Color.mealMoodSurface) } .frame(maxWidth: .infinity) .background(Color.mealMoodSurface) } private func decideRotation() { let current = UserDefaults.standard.integer(forKey: Self.counterKey) let next = current + 1 UserDefaults.standard.set(next, forKey: Self.counterKey) showRemoveAdsPromo = (next % Self.rotationInterval == 0) } }