65 lines
2.1 KiB
Swift
65 lines
2.1 KiB
Swift
import SwiftUI
|
|
|
|
struct RootView: View {
|
|
@StateObject private var localization = LocalizationStore()
|
|
|
|
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)
|
|
}
|
|
|
|
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)
|
|
} 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())
|
|
}
|
|
}
|
|
}
|