64 lines
1.9 KiB
Swift
64 lines
1.9 KiB
Swift
import SwiftUI
|
|
|
|
struct ContentView: View {
|
|
var ble: BLEManager
|
|
|
|
var body: some View {
|
|
TabView {
|
|
Tab("EIS", systemImage: "waveform.path") {
|
|
PlaceholderTab(title: "Impedance Spectroscopy", ble: ble)
|
|
}
|
|
Tab("LSV", systemImage: "arrow.right") {
|
|
PlaceholderTab(title: "Linear Sweep Voltammetry", ble: ble)
|
|
}
|
|
Tab("Amp", systemImage: "bolt") {
|
|
PlaceholderTab(title: "Amperometry", ble: ble)
|
|
}
|
|
Tab("Cl\u{2082}", systemImage: "drop") {
|
|
PlaceholderTab(title: "Chlorine", ble: ble)
|
|
}
|
|
Tab("pH", systemImage: "scalemass") {
|
|
PlaceholderTab(title: "pH", ble: ble)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private struct PlaceholderTab: View {
|
|
let title: String
|
|
var ble: BLEManager
|
|
|
|
var body: some View {
|
|
NavigationStack {
|
|
VStack(spacing: 20) {
|
|
Image(systemName: "antenna.radiowaves.left.and.right")
|
|
.font(.largeTitle)
|
|
.foregroundStyle(statusColor)
|
|
Text(ble.state.rawValue)
|
|
.font(.headline)
|
|
}
|
|
.navigationTitle(title)
|
|
.toolbar {
|
|
ToolbarItem(placement: .topBarTrailing) {
|
|
Button(ble.state == .connected ? "Disconnect" : "Connect") {
|
|
if ble.state == .connected {
|
|
ble.disconnect()
|
|
} else {
|
|
ble.startScanning()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private var statusColor: Color {
|
|
switch ble.state {
|
|
case .connected: .green
|
|
case .scanning: .orange
|
|
case .connecting: .yellow
|
|
case .disconnected: .secondary
|
|
}
|
|
}
|
|
}
|