|
|
@@ -1,5 +1,10 @@
|
|
|
import SwiftUI
|
|
|
|
|
|
+struct DescriptionString: Identifiable {
|
|
|
+ var id: String { name }
|
|
|
+ let name: String
|
|
|
+}
|
|
|
+
|
|
|
extension PreferencesEditor {
|
|
|
struct RootView: BaseView {
|
|
|
@EnvironmentObject var viewModel: ViewModel<Provider>
|
|
|
@@ -10,6 +15,8 @@ extension PreferencesEditor {
|
|
|
return formatter
|
|
|
}
|
|
|
|
|
|
+ @State private var infoButtonPressed: DescriptionString?
|
|
|
+
|
|
|
var body: some View {
|
|
|
Form {
|
|
|
Section(header: Text("FreeAPS X")) {
|
|
|
@@ -36,15 +43,37 @@ 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 = DescriptionString(name: field.infoText)
|
|
|
+ })
|
|
|
+ Toggle(field.displayName, isOn: self.$viewModel.boolFields[index].value)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ .alert(item: $infoButtonPressed) { iButton in
|
|
|
+ Alert(
|
|
|
+ title: Text("Description"),
|
|
|
+ message: Text(iButton.name),
|
|
|
+ dismissButton: .default(Text("Got it!"))
|
|
|
+ )
|
|
|
}
|
|
|
|
|
|
ForEach(viewModel.decimalFields.indexed(), id: \.1.id) { index, field in
|
|
|
HStack {
|
|
|
+ Button("ⓘ", action: {
|
|
|
+ infoButtonPressed = DescriptionString(name: field.infoText)
|
|
|
+ })
|
|
|
Text(field.displayName)
|
|
|
DecimalTextField("0", value: self.$viewModel.decimalFields[index].value, formatter: formatter)
|
|
|
}
|
|
|
}
|
|
|
+ .alert(item: $infoButtonPressed) { iButton in
|
|
|
+ Alert(
|
|
|
+ title: Text("Description"),
|
|
|
+ message: Text(iButton.name),
|
|
|
+ dismissButton: .default(Text("Got it!"))
|
|
|
+ )
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
Section {
|