OnboardingStepHeader.swift 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // LoopFollow
  2. // OnboardingStepHeader.swift
  3. import SwiftUI
  4. /// Consistent icon + title + subtitle header used at the top of each step body.
  5. ///
  6. /// The header deliberately carries no horizontal margin: it shares whatever
  7. /// leading edge its container uses, so it lines up exactly with the content
  8. /// below it — the section cards in a `Form`, or the `.padding(.horizontal)`
  9. /// cards in a plain `VStack`. Callers add their own horizontal padding to match.
  10. struct OnboardingStepHeader: View {
  11. let systemImage: String
  12. let title: String
  13. let subtitle: String
  14. var body: some View {
  15. // Left-aligned: justified/centered body copy is harder to read, so the
  16. // header reads as a natural top-down intro.
  17. VStack(alignment: .leading, spacing: 12) {
  18. Image(systemName: systemImage)
  19. .font(.system(size: 44, weight: .semibold))
  20. .foregroundStyle(Color.accentColor)
  21. .padding(.bottom, 2)
  22. Text(title)
  23. .font(.title2.weight(.bold))
  24. .multilineTextAlignment(.leading)
  25. Text(subtitle)
  26. .font(.subheadline)
  27. .foregroundColor(.secondary)
  28. .multilineTextAlignment(.leading)
  29. }
  30. .frame(maxWidth: .infinity, alignment: .leading)
  31. .padding(.top, 8)
  32. }
  33. }