|
Bogdan Timofte
authored
2 months ago
|
1
|
//
|
|
Bogdan Timofte
authored
2 months ago
|
2
|
// MeterInfoCardView.swift
|
|
Bogdan Timofte
authored
2 months ago
|
3
|
// USB Meter
|
|
|
4
|
//
|
|
|
5
|
|
|
|
6
|
import SwiftUI
|
|
|
7
|
|
|
Bogdan Timofte
authored
a month ago
|
8
|
struct MeterInfoCardView<Content: View, TrailingActions: View>: View {
|
|
Bogdan Timofte
authored
2 months ago
|
9
|
let title: String
|
|
Bogdan Timofte
authored
a month ago
|
10
|
let infoMessage: String?
|
|
Bogdan Timofte
authored
2 months ago
|
11
|
let tint: Color
|
|
Bogdan Timofte
authored
a month ago
|
12
|
@ViewBuilder var trailingActions: TrailingActions
|
|
Bogdan Timofte
authored
2 months ago
|
13
|
@ViewBuilder var content: Content
|
|
|
14
|
|
|
Bogdan Timofte
authored
a month ago
|
15
|
init(
|
|
|
16
|
title: String,
|
|
|
17
|
infoMessage: String? = nil,
|
|
|
18
|
tint: Color,
|
|
Bogdan Timofte
authored
a month ago
|
19
|
@ViewBuilder trailingActions: () -> TrailingActions = { EmptyView() },
|
|
Bogdan Timofte
authored
a month ago
|
20
|
@ViewBuilder content: () -> Content
|
|
|
21
|
) {
|
|
|
22
|
self.title = title
|
|
|
23
|
self.infoMessage = infoMessage
|
|
|
24
|
self.tint = tint
|
|
Bogdan Timofte
authored
a month ago
|
25
|
self.trailingActions = trailingActions()
|
|
Bogdan Timofte
authored
a month ago
|
26
|
self.content = content()
|
|
|
27
|
}
|
|
|
28
|
|
|
Bogdan Timofte
authored
2 months ago
|
29
|
var body: some View {
|
|
|
30
|
VStack(alignment: .leading, spacing: 12) {
|
|
Bogdan Timofte
authored
a month ago
|
31
|
HStack(spacing: 8) {
|
|
|
32
|
Text(title)
|
|
|
33
|
.font(.headline)
|
|
|
34
|
if let infoMessage {
|
|
|
35
|
ContextInfoButton(title: title, message: infoMessage)
|
|
|
36
|
}
|
|
Bogdan Timofte
authored
a month ago
|
37
|
Spacer(minLength: 0)
|
|
|
38
|
trailingActions
|
|
Bogdan Timofte
authored
a month ago
|
39
|
}
|
|
Bogdan Timofte
authored
2 months ago
|
40
|
content
|
|
|
41
|
}
|
|
|
42
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
|
43
|
.padding(18)
|
|
|
44
|
.meterCard(tint: tint, fillOpacity: 0.18, strokeOpacity: 0.24)
|
|
|
45
|
}
|
|
Bogdan Timofte
authored
a month ago
|
46
|
}
|