InfoBanner.swift 1.4 KB

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