InfoBanner.swift 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. //
  2. // InfoBanner.swift
  3. // LoopFollow
  4. //
  5. // Created by Jonas Björkert on 2025-05-10.
  6. // Copyright © 2025 Jon Fawcett. All rights reserved.
  7. //
  8. import SwiftUI
  9. /// Apple-style information banner you can drop into any `Form` / `List` row.
  10. ///
  11. /// Usage:
  12. /// ```swift
  13. /// Form {
  14. /// InfoBanner("Triggers when no CGM reading is received for the time you set below.")
  15. ///
  16. /// AlarmGeneralSection(alarm: $alarm)
  17. /// …
  18. /// }
  19. /// ```
  20. struct InfoBanner: View {
  21. /// The main explanatory text (can be a `String` or a localized key).
  22. let text: String
  23. /// Optional SFSymbol (defaults to “info.circle.fill” so you can omit it).
  24. var systemImage: String = "info.circle.fill"
  25. /// Icon colour (defaults to `.accentColor` so it adapts to light/dark).
  26. var iconColour: Color = .accentColor
  27. var body: some View {
  28. HStack(alignment: .top, spacing: 12) {
  29. Image(systemName: systemImage)
  30. .font(.title3)
  31. .foregroundColor(iconColour)
  32. Text(text)
  33. .font(.callout)
  34. .fixedSize(horizontal: false, vertical: true)
  35. }
  36. .padding()
  37. .listRowInsets(EdgeInsets())
  38. .padding(.bottom, 4)
  39. }
  40. }