|
@@ -6,42 +6,31 @@
|
|
|
// Copyright © 2025 Jon Fawcett. All rights reserved.
|
|
// Copyright © 2025 Jon Fawcett. All rights reserved.
|
|
|
//
|
|
//
|
|
|
|
|
|
|
|
-
|
|
|
|
|
import SwiftUI
|
|
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 {
|
|
struct InfoBanner: View {
|
|
|
- /// The main explanatory text (can be a `String` or a localized key).
|
|
|
|
|
let text: String
|
|
let text: String
|
|
|
-
|
|
|
|
|
- /// Optional SFSymbol (defaults to “info.circle.fill” so you can omit it).
|
|
|
|
|
var systemImage: String = "info.circle.fill"
|
|
var systemImage: String = "info.circle.fill"
|
|
|
-
|
|
|
|
|
- /// Icon colour (defaults to `.accentColor` so it adapts to light/dark).
|
|
|
|
|
var iconColour: Color = .accentColor
|
|
var iconColour: Color = .accentColor
|
|
|
-
|
|
|
|
|
|
|
+ var tint: Color? = Color.blue.opacity(0.07)
|
|
|
|
|
+
|
|
|
var body: some View {
|
|
var body: some View {
|
|
|
HStack(alignment: .top, spacing: 12) {
|
|
HStack(alignment: .top, spacing: 12) {
|
|
|
Image(systemName: systemImage)
|
|
Image(systemName: systemImage)
|
|
|
.font(.title3)
|
|
.font(.title3)
|
|
|
.foregroundColor(iconColour)
|
|
.foregroundColor(iconColour)
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
Text(text)
|
|
Text(text)
|
|
|
.font(.callout)
|
|
.font(.callout)
|
|
|
.fixedSize(horizontal: false, vertical: true)
|
|
.fixedSize(horizontal: false, vertical: true)
|
|
|
}
|
|
}
|
|
|
.padding()
|
|
.padding()
|
|
|
|
|
+ .frame(maxWidth: .infinity, alignment: .leading)
|
|
|
|
|
+ .background(
|
|
|
|
|
+ RoundedRectangle(cornerRadius: 12, style: .continuous)
|
|
|
|
|
+ .fill(tint ?? .clear)
|
|
|
|
|
+ .background(.thinMaterial)
|
|
|
|
|
+ )
|
|
|
.listRowInsets(EdgeInsets())
|
|
.listRowInsets(EdgeInsets())
|
|
|
- .padding(.bottom, 4)
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|