diff --git a/TheNoiseClock/Views/Alarms/AddAlarmView.swift b/TheNoiseClock/Views/Alarms/AddAlarmView.swift index da0f854..ba3d642 100644 --- a/TheNoiseClock/Views/Alarms/AddAlarmView.swift +++ b/TheNoiseClock/Views/Alarms/AddAlarmView.swift @@ -24,51 +24,63 @@ struct AddAlarmView: View { var body: some View { NavigationView { - VStack(spacing: 0) { - TimePickerSection(selectedTime: $newAlarmTime) - TimeUntilAlarmSection(alarmTime: newAlarmTime) - - List { - // Label Section - NavigationLink(destination: LabelEditView(label: $alarmLabel)) { - HStack { - Image(systemName: "textformat") - .foregroundColor(.orange) - .frame(width: 24) - Text("Label") - Spacer() - Text(alarmLabel) - .foregroundColor(.secondary) - } - } + ScrollView { + VStack(spacing: 0) { + TimePickerSection(selectedTime: $newAlarmTime) + TimeUntilAlarmSection(alarmTime: newAlarmTime) - // Sound Section - NavigationLink(destination: SoundSelectionView(selectedSound: $selectedSoundName)) { - HStack { - Image(systemName: "music.note") - .foregroundColor(.orange) - .frame(width: 24) - Text("Sound") - Spacer() - Text(getSoundDisplayName(selectedSoundName)) - .foregroundColor(.secondary) + LazyVStack(spacing: 0) { + // Label Section + NavigationLink(destination: LabelEditView(label: $alarmLabel)) { + HStack { + Image(systemName: "textformat") + .foregroundColor(.orange) + .frame(width: 24) + Text("Label") + Spacer() + Text(alarmLabel) + .foregroundColor(.secondary) + } + .padding() + .background(Color(.systemGroupedBackground)) } - } - - // Snooze Section - NavigationLink(destination: SnoozeSelectionView(snoozeDuration: $snoozeDuration)) { - HStack { - Image(systemName: "clock.arrow.circlepath") - .foregroundColor(.orange) - .frame(width: 24) - Text("Snooze") - Spacer() - Text("for \(snoozeDuration) min") - .foregroundColor(.secondary) + .buttonStyle(PlainButtonStyle()) + + // Sound Section + NavigationLink(destination: SoundSelectionView(selectedSound: $selectedSoundName)) { + HStack { + Image(systemName: "music.note") + .foregroundColor(.orange) + .frame(width: 24) + Text("Sound") + Spacer() + Text(getSoundDisplayName(selectedSoundName)) + .foregroundColor(.secondary) + } + .padding() + .background(Color(.systemGroupedBackground)) } + .buttonStyle(PlainButtonStyle()) + + // Snooze Section + NavigationLink(destination: SnoozeSelectionView(snoozeDuration: $snoozeDuration)) { + HStack { + Image(systemName: "clock.arrow.circlepath") + .foregroundColor(.orange) + .frame(width: 24) + Text("Snooze") + Spacer() + Text("for \(snoozeDuration) min") + .foregroundColor(.secondary) + } + .padding() + .background(Color(.systemGroupedBackground)) + } + .buttonStyle(PlainButtonStyle()) } + .cornerRadius(10) + .padding(.horizontal) } - .listStyle(.insetGrouped) } .navigationTitle("Alarm") .navigationBarTitleDisplayMode(.inline) diff --git a/TheNoiseClock/Views/Alarms/AlarmView.swift b/TheNoiseClock/Views/Alarms/AlarmView.swift index b5e7e36..b113d8a 100644 --- a/TheNoiseClock/Views/Alarms/AlarmView.swift +++ b/TheNoiseClock/Views/Alarms/AlarmView.swift @@ -16,19 +16,31 @@ struct AlarmView: View { // MARK: - Body var body: some View { - List { - ForEach(viewModel.alarms) { alarm in - AlarmRowView( - alarm: alarm, - onToggle: { - Task { - await viewModel.toggleAlarm(id: alarm.id) - } - }, - onEdit: { /* TODO: Implement edit functionality */ } - ) + Group { + if viewModel.alarms.isEmpty { + EmptyAlarmsView { + showAddAlarm = true + } + .contentShape(Rectangle()) + .onTapGesture { + showAddAlarm = true + } + } else { + List { + ForEach(viewModel.alarms) { alarm in + AlarmRowView( + alarm: alarm, + onToggle: { + Task { + await viewModel.toggleAlarm(id: alarm.id) + } + }, + onEdit: { /* TODO: Implement edit functionality */ } + ) + } + .onDelete(perform: deleteAlarm) + } } - .onDelete(perform: deleteAlarm) } .navigationTitle("Alarms") .toolbar { diff --git a/TheNoiseClock/Views/Alarms/Components/EmptyAlarmsView.swift b/TheNoiseClock/Views/Alarms/Components/EmptyAlarmsView.swift new file mode 100644 index 0000000..17ef39b --- /dev/null +++ b/TheNoiseClock/Views/Alarms/Components/EmptyAlarmsView.swift @@ -0,0 +1,39 @@ +// +// EmptyAlarmsView.swift +// TheNoiseClock +// +// Created by Matt Bruce on 9/7/25. +// + +import SwiftUI + +/// Empty state view for when no alarms are configured +struct EmptyAlarmsView: View { + + // MARK: - Properties + let onAddAlarm: () -> Void + + // MARK: - Body + var body: some View { + VStack(spacing: UIConstants.Spacing.medium) { + // Icon + Image(systemName: "alarm") + .font(.largeTitle) + .foregroundColor(.secondary) + + // Instructional text + Text("Create an alarm to begin") + .font(.subheadline) + .foregroundColor(.secondary) + } + .frame(maxWidth: .infinity, maxHeight: .infinity) + .background(Color.clear) + } +} + +// MARK: - Preview +#Preview { + EmptyAlarmsView { + print("Add alarm tapped") + } +}