|
Bogdan Timofte
authored
a week ago
|
1
|
//
|
|
|
2
|
// SidebarHelpNoticeCardView.swift
|
|
|
3
|
// USB Meter
|
|
|
4
|
//
|
|
|
5
|
|
|
|
6
|
import SwiftUI
|
|
|
7
|
|
|
|
8
|
struct SidebarHelpNoticeCardView: View {
|
|
|
9
|
let reason: SidebarHelpReason
|
|
|
10
|
let cloudSyncHelpTitle: String
|
|
|
11
|
let cloudSyncHelpMessage: String
|
|
|
12
|
|
|
|
13
|
var body: some View {
|
|
|
14
|
VStack(alignment: .leading, spacing: 8) {
|
|
|
15
|
Text(helpNoticeTitle)
|
|
|
16
|
.font(.subheadline.weight(.semibold))
|
|
|
17
|
Text(helpNoticeDetail)
|
|
|
18
|
.font(.caption)
|
|
|
19
|
.foregroundColor(.secondary)
|
|
|
20
|
}
|
|
|
21
|
.frame(maxWidth: .infinity, alignment: .leading)
|
|
|
22
|
.padding(14)
|
|
|
23
|
.meterCard(tint: reason.tint, fillOpacity: 0.14, strokeOpacity: 0.20, cornerRadius: 18)
|
|
|
24
|
}
|
|
|
25
|
|
|
|
26
|
private var helpNoticeTitle: String {
|
|
|
27
|
switch reason {
|
|
|
28
|
case .bluetoothPermission:
|
|
|
29
|
return "Bluetooth access needs attention"
|
|
|
30
|
case .cloudSyncUnavailable:
|
|
|
31
|
return cloudSyncHelpTitle
|
|
|
32
|
case .noDevicesDetected:
|
|
|
33
|
return "No supported meters found yet"
|
|
|
34
|
}
|
|
|
35
|
}
|
|
|
36
|
|
|
|
37
|
private var helpNoticeDetail: String {
|
|
|
38
|
switch reason {
|
|
|
39
|
case .bluetoothPermission:
|
|
|
40
|
return "Open Bluetooth help to review the permission state and jump into Settings if access is blocked."
|
|
|
41
|
case .cloudSyncUnavailable:
|
|
|
42
|
return cloudSyncHelpMessage
|
|
|
43
|
case .noDevicesDetected:
|
|
|
44
|
return "Open Device help for quick checks like meter power, Bluetooth availability on the meter, or an existing connection to another phone."
|
|
|
45
|
}
|
|
|
46
|
}
|
|
|
47
|
}
|