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,11 +24,12 @@ struct AddAlarmView: View {
var body: some View { var body: some View {
NavigationView { NavigationView {
ScrollView {
VStack(spacing: 0) { VStack(spacing: 0) {
TimePickerSection(selectedTime: $newAlarmTime) TimePickerSection(selectedTime: $newAlarmTime)
TimeUntilAlarmSection(alarmTime: newAlarmTime) TimeUntilAlarmSection(alarmTime: newAlarmTime)
List { LazyVStack(spacing: 0) {
// Label Section // Label Section
NavigationLink(destination: LabelEditView(label: $alarmLabel)) { NavigationLink(destination: LabelEditView(label: $alarmLabel)) {
HStack { HStack {
@ -40,7 +41,10 @@ struct AddAlarmView: View {
Text(alarmLabel) Text(alarmLabel)
.foregroundColor(.secondary) .foregroundColor(.secondary)
} }
.padding()
.background(Color(.systemGroupedBackground))
} }
.buttonStyle(PlainButtonStyle())
// Sound Section // Sound Section
NavigationLink(destination: SoundSelectionView(selectedSound: $selectedSoundName)) { NavigationLink(destination: SoundSelectionView(selectedSound: $selectedSoundName)) {
@ -53,7 +57,10 @@ struct AddAlarmView: View {
Text(getSoundDisplayName(selectedSoundName)) Text(getSoundDisplayName(selectedSoundName))
.foregroundColor(.secondary) .foregroundColor(.secondary)
} }
.padding()
.background(Color(.systemGroupedBackground))
} }
.buttonStyle(PlainButtonStyle())
// Snooze Section // Snooze Section
NavigationLink(destination: SnoozeSelectionView(snoozeDuration: $snoozeDuration)) { NavigationLink(destination: SnoozeSelectionView(snoozeDuration: $snoozeDuration)) {
@ -66,9 +73,14 @@ struct AddAlarmView: View {
Text("for \(snoozeDuration) min") Text("for \(snoozeDuration) min")
.foregroundColor(.secondary) .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,6 +16,16 @@ struct AlarmView: View {
// MARK: - Body // MARK: - Body
var body: some View { var body: some View {
Group {
if viewModel.alarms.isEmpty {
EmptyAlarmsView {
showAddAlarm = true
}
.contentShape(Rectangle())
.onTapGesture {
showAddAlarm = true
}
} else {
List { List {
ForEach(viewModel.alarms) { alarm in ForEach(viewModel.alarms) { alarm in
AlarmRowView( AlarmRowView(
@ -30,6 +40,8 @@ struct AlarmView: View {
} }
.onDelete(perform: deleteAlarm) .onDelete(perform: deleteAlarm)
} }
}
}
.navigationTitle("Alarms") .navigationTitle("Alarms")
.toolbar { .toolbar {
ToolbarItem(placement: .navigationBarTrailing) { ToolbarItem(placement: .navigationBarTrailing) {

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