Browse Source

Tinted InfoBanner

Jonas Björkert 1 year ago
parent
commit
1a9af37a96
1 changed files with 9 additions and 20 deletions
  1. 9 20
      LoopFollow/Alarm/AlarmEditing/Components/InfoBanner.swift

+ 9 - 20
LoopFollow/Alarm/AlarmEditing/Components/InfoBanner.swift

@@ -6,42 +6,31 @@
 //  Copyright © 2025 Jon Fawcett. All rights reserved.
 //
 
-
 import SwiftUI
 
-/// Apple-style information banner you can drop into any `Form` / `List` row.
-///
-/// Usage:
-/// ```swift
-/// Form {
-///     InfoBanner("Triggers when no CGM reading is received for the time you set below.")
-///     
-///     AlarmGeneralSection(alarm: $alarm)
-///     …
-/// }
-/// ```
 struct InfoBanner: View {
-    /// The main explanatory text (can be a `String` or a localized key).
     let text: String
-
-    /// Optional SFSymbol (defaults to “info.circle.fill” so you can omit it).
     var systemImage: String = "info.circle.fill"
-    
-    /// Icon colour (defaults to `.accentColor` so it adapts to light/dark).
     var iconColour: Color = .accentColor
-    
+    var tint: Color?      = Color.blue.opacity(0.07)
+
     var body: some View {
         HStack(alignment: .top, spacing: 12) {
             Image(systemName: systemImage)
                 .font(.title3)
                 .foregroundColor(iconColour)
-            
+
             Text(text)
                 .font(.callout)
                 .fixedSize(horizontal: false, vertical: true)
         }
         .padding()
+        .frame(maxWidth: .infinity, alignment: .leading)
+        .background(
+            RoundedRectangle(cornerRadius: 12, style: .continuous)
+                .fill(tint ?? .clear)
+                .background(.thinMaterial)
+        )
         .listRowInsets(EdgeInsets())
-        .padding(.bottom, 4)
     }
 }