InfoDisplaySettingsView.swift 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. // LoopFollow
  2. // InfoDisplaySettingsView.swift
  3. import SwiftUI
  4. struct InfoDisplaySettingsView: View {
  5. @ObservedObject var viewModel: InfoDisplaySettingsViewModel
  6. var body: some View {
  7. NavigationView {
  8. Form {
  9. Section(header: Text("General")) {
  10. Toggle(isOn: Binding(
  11. get: { Storage.shared.hideInfoTable.value },
  12. set: { Storage.shared.hideInfoTable.value = $0 }
  13. )) {
  14. Text("Hide Information Table")
  15. }
  16. }
  17. Section(header: Text("Information Display Settings")) {
  18. ForEach(viewModel.infoSort, id: \.self) { sortedIndex in
  19. HStack {
  20. Text(viewModel.getName(for: sortedIndex))
  21. Spacer()
  22. Toggle("", isOn: Binding(
  23. get: { viewModel.infoVisible[sortedIndex] },
  24. set: { _ in
  25. viewModel.toggleVisibility(for: sortedIndex)
  26. }
  27. ))
  28. .labelsHidden()
  29. }
  30. }
  31. .onMove(perform: viewModel.move)
  32. }
  33. }
  34. .environment(\.editMode, .constant(.active))
  35. .onDisappear {
  36. NotificationCenter.default.post(name: NSNotification.Name("refresh"), object: nil)
  37. }
  38. }
  39. .preferredColorScheme(Storage.shared.appearanceMode.value.colorScheme)
  40. .navigationBarTitle("Information Display Settings", displayMode: .inline)
  41. }
  42. }