InfoDisplaySettingsView.swift 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. List {
  19. ForEach(viewModel.infoSort, id: \.self) { sortedIndex in
  20. HStack {
  21. Text(viewModel.getName(for: sortedIndex))
  22. Spacer()
  23. Toggle("", isOn: Binding(
  24. get: { viewModel.infoVisible[sortedIndex] },
  25. set: { _ in
  26. viewModel.toggleVisibility(for: sortedIndex)
  27. }
  28. ))
  29. .labelsHidden()
  30. }
  31. }
  32. .onMove(perform: viewModel.move)
  33. }
  34. .environment(\.editMode, .constant(.active))
  35. }
  36. }
  37. .onDisappear {
  38. NotificationCenter.default.post(name: NSNotification.Name("refresh"), object: nil)
  39. }
  40. }
  41. .preferredColorScheme(Storage.shared.appearanceMode.value.colorScheme)
  42. .navigationBarTitle("Information Display Settings", displayMode: .inline)
  43. }
  44. }