import SwiftUI struct RootView: View { @StateObject private var localization = LocalizationStore() @EnvironmentObject private var analytics: HermesAnalyticsClient var body: some View { NavigationStack { ScrollView { VStack(alignment: .leading, spacing: 24) { header OnboardingView() FeedView() RoundView() } .padding(.horizontal, HermesTheme.screenPadding) .padding(.vertical, 24) } .background(HermesTheme.background.ignoresSafeArea()) .navigationTitle(localization.string(for: "app.name")) .navigationBarTitleDisplayMode(.inline) } .environmentObject(localization) .onAppear { analytics.track("app_opened", attributes: ["screen_name": "home"]) analytics.track("screen_viewed", attributes: ["screen_name": "home"]) } } private var header: some View { HStack(alignment: .top) { VStack(alignment: .leading, spacing: 8) { Text(localization.string(for: "app.name")) .font(.largeTitle.bold()) .foregroundStyle(HermesTheme.textPrimary) Text(localization.string(for: "app.subtitle")) .font(.callout) .foregroundStyle(HermesTheme.textSecondary) } Spacer(minLength: 12) localeToggle } } private var localeToggle: some View { HStack(spacing: 8) { localeButton(title: "EN", localeCode: "en") localeButton(title: "SV", localeCode: "sv") } } private func localeButton(title: String, localeCode: String) -> some View { let isSelected = localization.localeCode == localeCode return Button { localization.setLocale(localeCode) analytics.track("locale_changed", attributes: ["locale_code": localeCode]) } label: { Text(title) .font(.caption.weight(.bold)) .padding(.horizontal, 12) .padding(.vertical, 8) .foregroundStyle(isSelected ? HermesTheme.background : HermesTheme.textPrimary) .background(isSelected ? HermesTheme.accent : HermesTheme.surfaceElevated) .clipShape(Capsule()) } } }