Newer Older
75 lines | 2.52kb
Bogdan Timofte authored a week ago
1
//
2
//  MeterCardView.swift
3
//  USB Meter
4
//
5

            
6
import SwiftUI
7

            
8
struct MeterCardView: View {
9
    let meterSummary: AppData.MeterSummary
10

            
11
    var body: some View {
12
        HStack(spacing: 14) {
13
            Image(systemName: "sensor.tag.radiowaves.forward.fill")
14
                .font(.system(size: 18, weight: .semibold))
15
                .foregroundColor(meterSummary.tint)
16
                .frame(width: 42, height: 42)
17
                .background(
18
                    Circle()
19
                        .fill(meterSummary.tint.opacity(0.18))
20
                )
21
                .overlay(alignment: .bottomTrailing) {
22
                    Circle()
23
                        .fill(Color.red)
24
                        .frame(width: 12, height: 12)
25
                        .overlay(
26
                            Circle()
27
                                .stroke(Color(uiColor: .systemBackground), lineWidth: 2)
28
                        )
29
                }
30

            
31
            VStack(alignment: .leading, spacing: 4) {
32
                Text(meterSummary.displayName)
33
                    .font(.headline)
34
                Text(meterSummary.modelSummary)
35
                    .font(.caption)
36
                    .foregroundColor(.secondary)
37
                if let advertisedName = meterSummary.advertisedName, advertisedName != meterSummary.modelSummary {
38
                    Text("Advertised as \(advertisedName)")
39
                        .font(.caption2)
40
                        .foregroundColor(.secondary)
41
                }
42
            }
43

            
44
            Spacer()
45

            
46
            VStack(alignment: .trailing, spacing: 4) {
47
                HStack(spacing: 6) {
48
                    Circle()
49
                        .fill(Color.red)
50
                        .frame(width: 8, height: 8)
51
                    Text("Missing")
52
                        .font(.caption.weight(.semibold))
53
                        .foregroundColor(.secondary)
54
                }
55
                .padding(.horizontal, 10)
56
                .padding(.vertical, 6)
57
                .background(
58
                    Capsule(style: .continuous)
59
                        .fill(Color.red.opacity(0.12))
60
                )
61
                .overlay(
62
                    Capsule(style: .continuous)
63
                        .stroke(Color.red.opacity(0.22), lineWidth: 1)
64
                )
65
            }
66
        }
67
        .padding(14)
68
        .meterCard(
69
            tint: meterSummary.tint,
70
            fillOpacity: 0.16,
71
            strokeOpacity: 0.22,
72
            cornerRadius: 18
73
        )
74
    }
75
}