Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>

This commit is contained in:
Matt Bruce 2025-09-08 14:58:58 -05:00
parent 5b21d81fe3
commit f3d841f862
3 changed files with 115 additions and 52 deletions

View File

@ -24,51 +24,63 @@ struct AddAlarmView: View {
var body: some View { var body: some View {
NavigationView { NavigationView {
VStack(spacing: 0) { ScrollView {
TimePickerSection(selectedTime: $newAlarmTime) VStack(spacing: 0) {
TimeUntilAlarmSection(alarmTime: newAlarmTime) 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)
}
}
// Sound Section LazyVStack(spacing: 0) {
NavigationLink(destination: SoundSelectionView(selectedSound: $selectedSoundName)) { // Label Section
HStack { NavigationLink(destination: LabelEditView(label: $alarmLabel)) {
Image(systemName: "music.note") HStack {
.foregroundColor(.orange) Image(systemName: "textformat")
.frame(width: 24) .foregroundColor(.orange)
Text("Sound") .frame(width: 24)
Spacer() Text("Label")
Text(getSoundDisplayName(selectedSoundName)) Spacer()
.foregroundColor(.secondary) Text(alarmLabel)
.foregroundColor(.secondary)
}
.padding()
.background(Color(.systemGroupedBackground))
} }
} .buttonStyle(PlainButtonStyle())
// Snooze Section // Sound Section
NavigationLink(destination: SnoozeSelectionView(snoozeDuration: $snoozeDuration)) { NavigationLink(destination: SoundSelectionView(selectedSound: $selectedSoundName)) {
HStack { HStack {
Image(systemName: "clock.arrow.circlepath") Image(systemName: "music.note")
.foregroundColor(.orange) .foregroundColor(.orange)
.frame(width: 24) .frame(width: 24)
Text("Snooze") Text("Sound")
Spacer() Spacer()
Text("for \(snoozeDuration) min") Text(getSoundDisplayName(selectedSoundName))
.foregroundColor(.secondary) .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") .navigationTitle("Alarm")
.navigationBarTitleDisplayMode(.inline) .navigationBarTitleDisplayMode(.inline)

View File

@ -16,19 +16,31 @@ struct AlarmView: View {
// MARK: - Body // MARK: - Body
var body: some View { var body: some View {
List { Group {
ForEach(viewModel.alarms) { alarm in if viewModel.alarms.isEmpty {
AlarmRowView( EmptyAlarmsView {
alarm: alarm, showAddAlarm = true
onToggle: { }
Task { .contentShape(Rectangle())
await viewModel.toggleAlarm(id: alarm.id) .onTapGesture {
} showAddAlarm = true
}, }
onEdit: { /* TODO: Implement edit functionality */ } } 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") .navigationTitle("Alarms")
.toolbar { .toolbar {

View File

@ -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")
}
}