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 {
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)

View File

@ -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 {

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