|
|
@@ -6,18 +6,34 @@ extension NightscoutConfig {
|
|
|
|
|
|
var body: some View {
|
|
|
Form {
|
|
|
- TextField("URL", text: $viewModel.url)
|
|
|
- .disableAutocorrection(true)
|
|
|
- .textContentType(.URL)
|
|
|
- .autocapitalization(.none)
|
|
|
- .keyboardType(.URL)
|
|
|
- SecureField("API secret", text: $viewModel.secret)
|
|
|
- .disableAutocorrection(true)
|
|
|
- .autocapitalization(.none)
|
|
|
- .textContentType(.password)
|
|
|
- .keyboardType(.asciiCapable)
|
|
|
- Button("Connect") { viewModel.connect() }.disabled(viewModel.url.isEmpty || viewModel.secret.isEmpty)
|
|
|
- Button("Delete") { viewModel.delete() }.foregroundColor(.red)
|
|
|
+ Section {
|
|
|
+ TextField("URL", text: $viewModel.url)
|
|
|
+ .disableAutocorrection(true)
|
|
|
+ .textContentType(.URL)
|
|
|
+ .autocapitalization(.none)
|
|
|
+ .keyboardType(.URL)
|
|
|
+ SecureField("API secret", text: $viewModel.secret)
|
|
|
+ .disableAutocorrection(true)
|
|
|
+ .autocapitalization(.none)
|
|
|
+ .textContentType(.password)
|
|
|
+ .keyboardType(.asciiCapable)
|
|
|
+ if !viewModel.message.isEmpty {
|
|
|
+ Text(viewModel.message)
|
|
|
+ }
|
|
|
+ if viewModel.connecting {
|
|
|
+ HStack {
|
|
|
+ Text("Connecting...")
|
|
|
+ Spacer()
|
|
|
+ ProgressView()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Section {
|
|
|
+ Button("Connect") { viewModel.connect() }
|
|
|
+ .disabled(viewModel.url.isEmpty || viewModel.secret.isEmpty || viewModel.connecting)
|
|
|
+ Button("Delete") { viewModel.delete() }.foregroundColor(.red).disabled(viewModel.connecting)
|
|
|
+ }
|
|
|
}
|
|
|
.toolbar { ToolbarItem(placement: .principal) { Text("Nightscout Config") } }
|
|
|
.navigationBarItems(leading: Button("Close", action: viewModel.hideModal))
|