InfoDisplaySettingsView.swift 1.6 KB

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