AddAlarmSheet.swift 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // LoopFollow
  2. // AddAlarmSheet.swift
  3. import SwiftUI
  4. struct AddAlarmSheet: View {
  5. let onSelect: (AlarmType) -> Void
  6. @Environment(\.dismiss) private var dismiss
  7. private let columns = [
  8. GridItem(.adaptive(minimum: 110), spacing: 16),
  9. ]
  10. var body: some View {
  11. NavigationStack {
  12. ScrollView {
  13. LazyVGrid(columns: columns, spacing: 16) {
  14. ForEach(AlarmType.Group.allCases, id: \.self) { group in
  15. if AlarmType.allCases.contains(where: { $0.group == group }) {
  16. Section(header: Text(group.rawValue)
  17. .font(.headline)
  18. .frame(maxWidth: .infinity, alignment: .leading)
  19. .padding(.horizontal, 4)
  20. ) {
  21. ForEach(AlarmType.allCases.filter { $0.group == group }, id: \.self) { type in
  22. AlarmTile(type: type) {
  23. onSelect(type)
  24. }
  25. }
  26. }
  27. }
  28. }
  29. }
  30. .padding()
  31. }
  32. .navigationTitle("Add Alarm")
  33. .toolbar {
  34. ToolbarItem(placement: .cancellationAction) {
  35. Button("Cancel") { dismiss() }
  36. }
  37. }
  38. }
  39. .preferredColorScheme(Storage.shared.forceDarkMode.value ? .dark : nil)
  40. }
  41. }