App-side changes: - Added "Get Started" / "Continue" next buttons to all onboarding pages (Welcome, Day, Time, Style) with onboarding_next_button accessibility ID - Added onNext callback plumbing from OnboardingMain to each page - OnboardingMain now uses TabView(selection:) for programmatic page navigation - Added .accessibilityElement(children: .contain) to all onboarding pages to fix iOS 26 paged TabView not exposing child elements - Added settings_segmented_picker accessibility ID to Settings Picker - Reduced padding on onboarding pages to keep buttons in visible area Test-side changes: - OnboardingScreen: replaced unreliable swipeToNext() with tapNext() that taps the accessibility-identified next button - OnboardingScreen: multi-strategy skip button detection for subscription page - SettingsScreen: scoped segment tap to picker element to avoid tab bar collision - CustomizeScreen: simplified horizontal scroll to plain app.swipeLeft() - OnboardingVotingTests: uses tapNext() to advance to Day page Passing: OnboardingTests.CompleteFlow, OnboardingVotingTests Remaining: OnboardingTests.DoesNotRepeat (session state issue), Settings scroll (deep elements), Customize horizontal pickers Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
190 lines
6.7 KiB
Swift
190 lines
6.7 KiB
Swift
//
|
|
// OnboardingSubscription.swift
|
|
// Reflect
|
|
//
|
|
// Created by Claude Code on 12/10/24.
|
|
//
|
|
|
|
import SwiftUI
|
|
|
|
struct OnboardingSubscription: View {
|
|
@ObservedObject var onboardingData: OnboardingData
|
|
@EnvironmentObject var iapManager: IAPManager
|
|
@State private var showSubscriptionStore = false
|
|
|
|
let completionClosure: ((OnboardingData) -> Void)
|
|
|
|
var body: some View {
|
|
VStack(spacing: 0) {
|
|
Spacer()
|
|
|
|
// Crown icon
|
|
ZStack {
|
|
Circle()
|
|
.fill(.white.opacity(0.15))
|
|
.frame(width: 120, height: 120)
|
|
|
|
Image(systemName: "crown.fill")
|
|
.font(.largeTitle)
|
|
.foregroundColor(.yellow)
|
|
}
|
|
.padding(.bottom, 24)
|
|
|
|
// Title
|
|
Text("Unlock the Full\nExperience")
|
|
.font(.title.weight(.bold))
|
|
.foregroundColor(.white)
|
|
.multilineTextAlignment(.center)
|
|
.padding(.bottom, 8)
|
|
|
|
Spacer()
|
|
|
|
// Benefits list
|
|
VStack(spacing: 0) {
|
|
BenefitRow(
|
|
icon: "calendar.badge.clock",
|
|
title: "Month & Year Views",
|
|
description: "See your mood patterns across months and years"
|
|
)
|
|
|
|
Divider()
|
|
.background(.white.opacity(0.2))
|
|
|
|
BenefitRow(
|
|
icon: "lightbulb.fill",
|
|
title: "AI-Powered Insights",
|
|
description: "Discover trends and patterns in your moods"
|
|
)
|
|
|
|
Divider()
|
|
.background(.white.opacity(0.2))
|
|
|
|
BenefitRow(
|
|
icon: "heart.text.square.fill",
|
|
title: "Health Data Correlation",
|
|
description: "Connect your mood with sleep, steps, and more"
|
|
)
|
|
|
|
Divider()
|
|
.background(.white.opacity(0.2))
|
|
|
|
BenefitRow(
|
|
icon: "square.grid.2x2.fill",
|
|
title: "Interactive Widgets",
|
|
description: "Log your mood directly from your home screen"
|
|
)
|
|
}
|
|
.padding(.vertical, 8)
|
|
.background(
|
|
RoundedRectangle(cornerRadius: 20)
|
|
.fill(.white.opacity(0.15))
|
|
)
|
|
.padding(.horizontal, 24)
|
|
|
|
Spacer()
|
|
|
|
// Buttons
|
|
VStack(spacing: 12) {
|
|
// Subscribe button
|
|
Button(action: {
|
|
AnalyticsManager.shared.track(.onboardingSubscribeTapped)
|
|
showSubscriptionStore = true
|
|
}) {
|
|
HStack {
|
|
Image(systemName: "sparkles")
|
|
.font(.headline.weight(.semibold))
|
|
|
|
Text("Get Personal Insights")
|
|
.font(.headline.weight(.bold))
|
|
}
|
|
.foregroundColor(Color(hex: "11998e"))
|
|
.frame(maxWidth: .infinity)
|
|
.padding(.vertical, 18)
|
|
.background(
|
|
RoundedRectangle(cornerRadius: 16)
|
|
.fill(.white)
|
|
.shadow(color: .black.opacity(0.15), radius: 10, y: 5)
|
|
)
|
|
}
|
|
.accessibilityIdentifier(AccessibilityID.Onboarding.subscribeButton)
|
|
.accessibilityLabel(String(localized: "Get Personal Insights"))
|
|
.accessibilityHint(String(localized: "Opens subscription options"))
|
|
|
|
// Skip button
|
|
Button(action: {
|
|
AnalyticsManager.shared.track(.onboardingCompleted(dayId: nil))
|
|
AnalyticsManager.shared.track(.onboardingSkipped)
|
|
completionClosure(onboardingData)
|
|
}) {
|
|
Text("Maybe Later")
|
|
.font(.body.weight(.medium))
|
|
.foregroundColor(.white.opacity(0.8))
|
|
.accessibilityIdentifier(AccessibilityID.Onboarding.skipButton)
|
|
}
|
|
.accessibilityIdentifier(AccessibilityID.Onboarding.skipButton)
|
|
.accessibilityLabel(String(localized: "Maybe Later"))
|
|
.accessibilityHint(String(localized: "Skip subscription and complete setup"))
|
|
.padding(.top, 4)
|
|
}
|
|
.padding(.horizontal, 24)
|
|
.padding(.bottom, 30)
|
|
}
|
|
.background(
|
|
LinearGradient(
|
|
colors: [Color(hex: "11998e"), Color(hex: "38ef7d")],
|
|
startPoint: .topLeading,
|
|
endPoint: .bottomTrailing
|
|
)
|
|
.ignoresSafeArea()
|
|
)
|
|
.accessibilityElement(children: .contain)
|
|
.accessibilityIdentifier(AccessibilityID.Onboarding.subscriptionScreen)
|
|
.sheet(isPresented: $showSubscriptionStore, onDismiss: {
|
|
// After subscription store closes, complete onboarding
|
|
AnalyticsManager.shared.track(.onboardingCompleted(dayId: nil))
|
|
completionClosure(onboardingData)
|
|
}) {
|
|
ReflectSubscriptionStoreView(source: "onboarding")
|
|
}
|
|
}
|
|
}
|
|
|
|
struct BenefitRow: View {
|
|
let icon: String
|
|
let title: String
|
|
let description: String
|
|
|
|
var body: some View {
|
|
HStack(spacing: 16) {
|
|
Image(systemName: icon)
|
|
.font(.title3)
|
|
.foregroundColor(.white)
|
|
.frame(width: 40)
|
|
.accessibilityHidden(true)
|
|
|
|
VStack(alignment: .leading, spacing: 2) {
|
|
Text(title)
|
|
.font(.body.weight(.semibold))
|
|
.foregroundColor(.white)
|
|
|
|
Text(description)
|
|
.font(.caption)
|
|
.foregroundColor(.white.opacity(0.8))
|
|
}
|
|
|
|
Spacer()
|
|
}
|
|
.padding(.horizontal, 20)
|
|
.padding(.vertical, 14)
|
|
.accessibilityElement(children: .combine)
|
|
.accessibilityLabel("\(title): \(description)")
|
|
}
|
|
}
|
|
|
|
struct OnboardingSubscription_Previews: PreviewProvider {
|
|
static var previews: some View {
|
|
OnboardingSubscription(onboardingData: OnboardingData(), completionClosure: { _ in })
|
|
.environmentObject(IAPManager())
|
|
}
|
|
}
|