|
|
@@ -1,5 +1,11 @@
|
|
|
import SwiftUI
|
|
|
|
|
|
+struct InfoText: Identifiable {
|
|
|
+ var id: String { description }
|
|
|
+ let description: String
|
|
|
+ let oref0Variable: String
|
|
|
+}
|
|
|
+
|
|
|
extension PreferencesEditor {
|
|
|
struct RootView: BaseView {
|
|
|
@EnvironmentObject var viewModel: ViewModel<Provider>
|
|
|
@@ -10,6 +16,8 @@ extension PreferencesEditor {
|
|
|
return formatter
|
|
|
}
|
|
|
|
|
|
+ @State private var infoButtonPressed: InfoText?
|
|
|
+
|
|
|
var body: some View {
|
|
|
Form {
|
|
|
Section(header: Text("FreeAPS X")) {
|
|
|
@@ -36,17 +44,24 @@ extension PreferencesEditor {
|
|
|
}
|
|
|
|
|
|
ForEach(viewModel.boolFields.indexed(), id: \.1.id) { index, field in
|
|
|
- Toggle(field.displayName, isOn: self.$viewModel.boolFields[index].value)
|
|
|
+ HStack {
|
|
|
+ Button("", action: {
|
|
|
+ infoButtonPressed = InfoText(description: field.infoText, oref0Variable: field.displayName)
|
|
|
+ })
|
|
|
+ Toggle(field.displayName, isOn: self.$viewModel.boolFields[index].value)
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
ForEach(viewModel.decimalFields.indexed(), id: \.1.id) { index, field in
|
|
|
HStack {
|
|
|
+ Button("", action: {
|
|
|
+ infoButtonPressed = InfoText(description: field.infoText, oref0Variable: field.displayName)
|
|
|
+ })
|
|
|
Text(field.displayName)
|
|
|
DecimalTextField("0", value: self.$viewModel.decimalFields[index].value, formatter: formatter)
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
Section {
|
|
|
Text("Edit settings json").chevronCell()
|
|
|
.navigationLink(to: .configEditor(file: OpenAPS.FreeAPS.settings), from: self)
|
|
|
@@ -54,6 +69,13 @@ extension PreferencesEditor {
|
|
|
}
|
|
|
.navigationTitle("Preferences")
|
|
|
.navigationBarTitleDisplayMode(.automatic)
|
|
|
+ .alert(item: $infoButtonPressed) { infoButton in
|
|
|
+ Alert(
|
|
|
+ title: Text("\(infoButton.oref0Variable)"),
|
|
|
+ message: Text("\(infoButton.description)"),
|
|
|
+ dismissButton: .default(Text("OK"))
|
|
|
+ )
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|