InfoBanner.swift 1.3 KB

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