@blueid/access-capacitor 0.92.0 → 0.95.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/BlueCore_pb.d.ts +20 -0
- package/dist/esm/BlueCore_pb.js +25 -0
- package/dist/esm/BlueCore_pb.js.map +1 -1
- package/dist/esm/BlueSDK_pb.d.ts +72 -12
- package/dist/esm/BlueSDK_pb.js +24 -9
- package/dist/esm/BlueSDK_pb.js.map +1 -1
- package/dist/plugin.cjs.js +49 -9
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +49 -9
- package/dist/plugin.js.map +1 -1
- package/ios/CBlueIDAccess.xcframework/ios-arm64/Headers/core/BlueCore.pb.h +5 -0
- package/ios/CBlueIDAccess.xcframework/ios-arm64/libCBlueIDAccess.a +0 -0
- package/ios/CBlueIDAccess.xcframework/ios-arm64_x86_64-simulator/Headers/core/BlueCore.pb.h +5 -0
- package/ios/CBlueIDAccess.xcframework/ios-arm64_x86_64-simulator/libCBlueIDAccess.a +0 -0
- package/ios/CBlueIDAccess.xcframework/macos-arm64_x86_64/Headers/core/BlueCore.pb.h +5 -0
- package/ios/CBlueIDAccess.xcframework/macos-arm64_x86_64/libCBlueIDAccess.a +0 -0
- package/ios/Plugin/BlueIDAccessSDK/BlueAccess.swift +209 -58
- package/ios/Plugin/BlueIDAccessSDK/BlueCore.pb.swift +20 -0
- package/ios/Plugin/BlueIDAccessSDK/BlueModal/{BlueModalSession.swift → BlueAccessDeviceModalSession.swift} +5 -5
- package/ios/Plugin/BlueIDAccessSDK/BlueModal/{BlueModalView.swift → BlueAccessDeviceModalView.swift} +11 -22
- package/ios/Plugin/BlueIDAccessSDK/BlueModal/BlueModal+Extensions.swift +14 -0
- package/ios/Plugin/BlueIDAccessSDK/BlueModal/BlueModal.swift +50 -2
- package/ios/Plugin/BlueIDAccessSDK/BlueModal/BlueSynchronizeAccessDeviceModalSession.swift +56 -0
- package/ios/Plugin/BlueIDAccessSDK/BlueModal/BlueSynchronizeAccessDeviceModalView.swift +237 -0
- package/ios/Plugin/BlueIDAccessSDK/BlueSDK.pb.swift +310 -40
- package/ios/Plugin/BlueIDAccessSDK/BlueTaskRunner.swift +155 -0
- package/package.json +1 -1
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
#if os(iOS) || os(watchOS)
|
|
2
|
+
import SwiftUI
|
|
3
|
+
import Combine
|
|
4
|
+
|
|
5
|
+
private func getColor(_ status: BlueTaskStatus) -> Color {
|
|
6
|
+
switch (status) {
|
|
7
|
+
case .ready, .started, .skipped:
|
|
8
|
+
return .gray
|
|
9
|
+
case .failed:
|
|
10
|
+
return .red
|
|
11
|
+
case .succeeded:
|
|
12
|
+
return .green
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
private func getLineColor(_ status: BlueTaskStatus) -> Color {
|
|
17
|
+
switch (status) {
|
|
18
|
+
case .ready, .started:
|
|
19
|
+
return .gray
|
|
20
|
+
case .failed:
|
|
21
|
+
return .red
|
|
22
|
+
case .succeeded, .skipped:
|
|
23
|
+
return .green
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
private func getSymbol(_ status: BlueTaskStatus) -> String {
|
|
28
|
+
switch(status) {
|
|
29
|
+
case .ready:
|
|
30
|
+
return "circle"
|
|
31
|
+
case .started:
|
|
32
|
+
return "circle.circle"
|
|
33
|
+
case .failed:
|
|
34
|
+
return "xmark.circle"
|
|
35
|
+
case .succeeded, .skipped:
|
|
36
|
+
return "checkmark.circle"
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
class BlueTaskModel: ObservableObject, Identifiable {
|
|
41
|
+
@Published var label: String
|
|
42
|
+
@Published var status: BlueTaskStatus
|
|
43
|
+
@Published var statusColor: Color
|
|
44
|
+
@Published var lineColor: Color
|
|
45
|
+
@Published var symbol: String
|
|
46
|
+
@Published var errorDescription: String
|
|
47
|
+
@Published var isLast: Bool
|
|
48
|
+
|
|
49
|
+
private var subscriber: AnyCancellable?
|
|
50
|
+
|
|
51
|
+
init(_ task: BlueTask, _ isLast: Bool) {
|
|
52
|
+
self.label = task.label
|
|
53
|
+
self.status = task.status.value
|
|
54
|
+
self.statusColor = getColor(task.status.value)
|
|
55
|
+
self.lineColor = getLineColor(task.status.value)
|
|
56
|
+
self.symbol = getSymbol(task.status.value)
|
|
57
|
+
self.errorDescription = task.errorDescription ?? ""
|
|
58
|
+
self.isLast = isLast
|
|
59
|
+
|
|
60
|
+
self.subscriber = task.status.sink{ [weak self] status in
|
|
61
|
+
guard let self = self else { return }
|
|
62
|
+
|
|
63
|
+
self.status = status
|
|
64
|
+
self.statusColor = getColor(status)
|
|
65
|
+
self.lineColor = getLineColor(status)
|
|
66
|
+
self.symbol = getSymbol(status)
|
|
67
|
+
self.errorDescription = task.errorDescription ?? ""
|
|
68
|
+
|
|
69
|
+
self.objectWillChange.send()
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
struct TaskView: View {
|
|
75
|
+
@StateObject var task: BlueTaskModel
|
|
76
|
+
|
|
77
|
+
public var body: some View {
|
|
78
|
+
VStack(alignment: .leading, spacing: 0) {
|
|
79
|
+
HStack(alignment: .center){
|
|
80
|
+
if (task.status == .started) {
|
|
81
|
+
ProgressView()
|
|
82
|
+
.progressViewStyle(CircularProgressViewStyle(tint: .gray))
|
|
83
|
+
.padding(.leading, 2)
|
|
84
|
+
.padding(.trailing, 2)
|
|
85
|
+
} else {
|
|
86
|
+
Image(systemName: task.symbol)
|
|
87
|
+
.foregroundColor(task.statusColor)
|
|
88
|
+
.font(.system(size: 20))
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
Text(task.label)
|
|
92
|
+
.font(.system(size: 14))
|
|
93
|
+
.frame(maxWidth: .infinity, alignment: .leading)
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
HStack(alignment: .center) {
|
|
97
|
+
if !task.isLast {
|
|
98
|
+
Rectangle()
|
|
99
|
+
.fill(task.lineColor)
|
|
100
|
+
.frame(width: 2)
|
|
101
|
+
.padding(.horizontal, 10.5)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if !task.errorDescription.isEmpty {
|
|
105
|
+
Text(task.errorDescription)
|
|
106
|
+
.foregroundColor(.red)
|
|
107
|
+
.font(.system(size: 11))
|
|
108
|
+
.padding(.vertical, 2)
|
|
109
|
+
.multilineTextAlignment(.leading)
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
class BlueSynchronizeAccessDeviceModalViewModel: ObservableObject {
|
|
117
|
+
@Published var title = ""
|
|
118
|
+
@Published var dismiss: String = ""
|
|
119
|
+
@Published var dismissEnabled: Bool = true
|
|
120
|
+
@Published var tasks: [BlueTask]
|
|
121
|
+
|
|
122
|
+
init(title: String = "", dismiss: String = "", tasks: [BlueTask] = []) {
|
|
123
|
+
self.title = title
|
|
124
|
+
self.dismiss = dismiss
|
|
125
|
+
self.tasks = tasks
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
struct BlueSynchronizeAccessDeviceModalView: View {
|
|
130
|
+
@ObservedObject private var vm: BlueSynchronizeAccessDeviceModalViewModel
|
|
131
|
+
|
|
132
|
+
internal var height: CGFloat = 500
|
|
133
|
+
internal var backgroundColor: UIColor = .white
|
|
134
|
+
internal var foregroundColor: UIColor = .black
|
|
135
|
+
|
|
136
|
+
private let onDismiss: () -> Void
|
|
137
|
+
private let cornerRadius: CGFloat = 35
|
|
138
|
+
|
|
139
|
+
public init(
|
|
140
|
+
_ vm: BlueSynchronizeAccessDeviceModalViewModel,
|
|
141
|
+
_ onDismiss: @escaping () -> Void)
|
|
142
|
+
{
|
|
143
|
+
self.vm = vm
|
|
144
|
+
self.onDismiss = onDismiss
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
public var body: some View {
|
|
148
|
+
GeometryReader { geometry in
|
|
149
|
+
ZStack {
|
|
150
|
+
VStack {
|
|
151
|
+
Spacer()
|
|
152
|
+
|
|
153
|
+
ZStack {
|
|
154
|
+
RoundedRectangle(cornerRadius: cornerRadius)
|
|
155
|
+
.foregroundColor(Color(backgroundColor))
|
|
156
|
+
.shadow(color: .gray, radius: 1)
|
|
157
|
+
|
|
158
|
+
VStack(alignment: .center) {
|
|
159
|
+
Text(vm.title)
|
|
160
|
+
.font(.system(size: 20))
|
|
161
|
+
.foregroundColor(.gray)
|
|
162
|
+
|
|
163
|
+
Spacer()
|
|
164
|
+
|
|
165
|
+
ScrollView {
|
|
166
|
+
VStack(alignment: .leading, spacing: 0) {
|
|
167
|
+
ForEach(vm.tasks.indices, id: \.self){ index in
|
|
168
|
+
TaskView(task: BlueTaskModel(vm.tasks[index], index == vm.tasks.indices.last))
|
|
169
|
+
}
|
|
170
|
+
}.padding(.vertical, 10)
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if !vm.dismiss.isEmpty {
|
|
174
|
+
Spacer()
|
|
175
|
+
|
|
176
|
+
Button {
|
|
177
|
+
onDismiss()
|
|
178
|
+
} label: {
|
|
179
|
+
Text(vm.dismiss)
|
|
180
|
+
.font(.system(size: 18))
|
|
181
|
+
.frame(maxWidth: .infinity)
|
|
182
|
+
.padding(EdgeInsets(top: 15, leading: 10, bottom: 15, trailing: 10))
|
|
183
|
+
.background(Color.gray.opacity(0.5))
|
|
184
|
+
.cornerRadius(10)
|
|
185
|
+
}
|
|
186
|
+
.disabled(!vm.dismissEnabled)
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
.padding(30)
|
|
190
|
+
}
|
|
191
|
+
.frame(height: height + cornerRadius)
|
|
192
|
+
.offset(y: cornerRadius - 15)
|
|
193
|
+
.padding(.horizontal, 15)
|
|
194
|
+
}
|
|
195
|
+
.foregroundColor(Color(foregroundColor))
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
struct BlueSynchronizeAccessDeviceModalView_Preview: PreviewProvider {
|
|
202
|
+
static var previews: some View {
|
|
203
|
+
BlueSynchronizeAccessDeviceModalView(
|
|
204
|
+
BlueSynchronizeAccessDeviceModalViewModel(
|
|
205
|
+
title: "Synchronization in Progress",
|
|
206
|
+
dismiss: "Cancel",
|
|
207
|
+
tasks: [
|
|
208
|
+
BlueTask(
|
|
209
|
+
id: "A",
|
|
210
|
+
label: "Retrieve device configuration",
|
|
211
|
+
status: .failed,
|
|
212
|
+
error: BlueError(.sdkCredentialNotFound, cause: BlueError(.invalidCrc), detail: "Something is wrong")
|
|
213
|
+
) { _ in .result(nil) },
|
|
214
|
+
|
|
215
|
+
BlueTask(
|
|
216
|
+
id: "B",
|
|
217
|
+
label: "Update device configuration",
|
|
218
|
+
status: .succeeded
|
|
219
|
+
) { _ in .result(nil) },
|
|
220
|
+
|
|
221
|
+
BlueTask(
|
|
222
|
+
id: "C",
|
|
223
|
+
label: "Wait for device to restart",
|
|
224
|
+
status: .started
|
|
225
|
+
) { _ in .result(nil) },
|
|
226
|
+
|
|
227
|
+
BlueTask(
|
|
228
|
+
id: "D",
|
|
229
|
+
label: "Push system status",
|
|
230
|
+
status: .ready
|
|
231
|
+
) { _ in .result(nil) }
|
|
232
|
+
]
|
|
233
|
+
)
|
|
234
|
+
) {}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
#endif
|