Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
parent
5b21d81fe3
commit
f3d841f862
@ -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 {
|
LazyVStack(spacing: 0) {
|
||||||
// Label Section
|
// Label Section
|
||||||
NavigationLink(destination: LabelEditView(label: $alarmLabel)) {
|
NavigationLink(destination: LabelEditView(label: $alarmLabel)) {
|
||||||
HStack {
|
HStack {
|
||||||
Image(systemName: "textformat")
|
Image(systemName: "textformat")
|
||||||
.foregroundColor(.orange)
|
.foregroundColor(.orange)
|
||||||
.frame(width: 24)
|
.frame(width: 24)
|
||||||
Text("Label")
|
Text("Label")
|
||||||
Spacer()
|
Spacer()
|
||||||
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)) {
|
||||||
HStack {
|
HStack {
|
||||||
Image(systemName: "music.note")
|
Image(systemName: "music.note")
|
||||||
.foregroundColor(.orange)
|
.foregroundColor(.orange)
|
||||||
.frame(width: 24)
|
.frame(width: 24)
|
||||||
Text("Sound")
|
Text("Sound")
|
||||||
Spacer()
|
Spacer()
|
||||||
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)) {
|
||||||
HStack {
|
HStack {
|
||||||
Image(systemName: "clock.arrow.circlepath")
|
Image(systemName: "clock.arrow.circlepath")
|
||||||
.foregroundColor(.orange)
|
.foregroundColor(.orange)
|
||||||
.frame(width: 24)
|
.frame(width: 24)
|
||||||
Text("Snooze")
|
Text("Snooze")
|
||||||
Spacer()
|
Spacer()
|
||||||
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)
|
||||||
|
|||||||
@ -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 {
|
||||||
|
|||||||
39
TheNoiseClock/Views/Alarms/Components/EmptyAlarmsView.swift
Normal file
39
TheNoiseClock/Views/Alarms/Components/EmptyAlarmsView.swift
Normal 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")
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user