-
-
Notifications
You must be signed in to change notification settings - Fork 99
/
BeaconEmitterView.swift
60 lines (52 loc) · 1.7 KB
/
BeaconEmitterView.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//
// ContentView.swift
// BeaconEmitter
//
// Created by Laurent Gaches.
//
import SwiftUI
struct BeaconEmitterView: View {
@StateObject var viewModel = BeaconEmitterViewModel()
var body: some View {
Form {
HStack {
TextField("UUID", text: $viewModel.uuid)
.disabled(viewModel.isStarted)
Button {
viewModel.refreshUUID()
} label: {
Image(systemName: "arrow.clockwise")
}.disabled(viewModel.isStarted)
Button {
viewModel.copyPaste()
} label: {
Image(systemName: "doc.on.doc")
}.disabled(viewModel.isStarted)
}
TextField("Major", value: $viewModel.major, formatter: viewModel.majorMinorFormatter)
.disabled(viewModel.isStarted)
TextField("Minor", value: $viewModel.minor, formatter: viewModel.majorMinorFormatter)
.disabled(viewModel.isStarted)
TextField("Power", value: $viewModel.power, formatter: viewModel.powerFormatter)
.disabled(viewModel.isStarted)
Text(viewModel.status)
Button {
viewModel.startStop()
} label: {
Spacer()
if viewModel.isStarted {
Text("Turn iBeacon on")
} else {
Text("Turn iBeacon off")
}
Spacer()
}
}
.padding()
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
BeaconEmitterView()
}
}