InfoBanner.swift 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. // LoopFollow
  2. // InfoBanner.swift
  3. import SwiftUI
  4. struct InfoBanner: View {
  5. /// Main explanatory text
  6. let text: String
  7. /// Optional alarm type whose icon you’d like to show.
  8. /// If `nil`, we fall back to the standard “info” symbol.
  9. var alarmType: AlarmType? = nil
  10. /// Colour for the leading symbol
  11. var iconColour: Color = .accentColor
  12. /// Background + border tints
  13. var tint: Color = Color.blue.opacity(0.20)
  14. var border: Color = Color.blue.opacity(0.40)
  15. // ────────── View ──────────
  16. var body: some View {
  17. HStack(alignment: .top, spacing: 12) {
  18. Image(systemName: alarmType?.icon ?? "info.circle.fill")
  19. .font(.title3)
  20. .foregroundColor(iconColour)
  21. Text(text)
  22. .font(.callout)
  23. .fixedSize(horizontal: false, vertical: true)
  24. }
  25. .padding()
  26. .frame(maxWidth: .infinity, alignment: .leading)
  27. .background(
  28. RoundedRectangle(cornerRadius: 12, style: .continuous)
  29. .fill(tint)
  30. )
  31. .overlay(
  32. RoundedRectangle(cornerRadius: 12, style: .continuous)
  33. .stroke(border, lineWidth: 1)
  34. )
  35. .listRowInsets(EdgeInsets())
  36. }
  37. }