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

This commit is contained in:
Matt Bruce 2026-02-07 15:56:55 -06:00
parent 3ed7da63f7
commit e03689f38c
4 changed files with 0 additions and 111 deletions

View File

@ -15,7 +15,6 @@ struct AddAlarmView: View {
// MARK: - Properties // MARK: - Properties
let viewModel: AlarmViewModel let viewModel: AlarmViewModel
@Binding var isPresented: Bool @Binding var isPresented: Bool
@AppStorage(ClockStyle.appStorageKey) private var clockStyleData: Data = Data()
@State private var newAlarmTime = Calendar.current.date(bySettingHour: 6, minute: 0, second: 0, of: Date()) ?? Date() @State private var newAlarmTime = Calendar.current.date(bySettingHour: 6, minute: 0, second: 0, of: Date()) ?? Date()
@State private var selectedSoundName = "digital-alarm.caf" @State private var selectedSoundName = "digital-alarm.caf"
@ -35,15 +34,6 @@ struct AddAlarmView: View {
// List for settings below // List for settings below
List { List {
if !isKeepAwakeEnabled {
Section {
AlarmLimitationsBanner()
.listRowInsets(EdgeInsets())
.listRowBackground(Color.clear)
.listRowSeparator(.hidden)
}
}
// Label Section // Label Section
NavigationLink(destination: LabelEditView(label: $alarmLabel)) { NavigationLink(destination: LabelEditView(label: $alarmLabel)) {
HStack { HStack {
@ -138,11 +128,4 @@ struct AddAlarmView: View {
private func getSoundDisplayName(_ fileName: String) -> String { private func getSoundDisplayName(_ fileName: String) -> String {
return AlarmSoundService.shared.getSoundDisplayName(fileName) return AlarmSoundService.shared.getSoundDisplayName(fileName)
} }
private var isKeepAwakeEnabled: Bool {
guard let decoded = try? JSONDecoder().decode(ClockStyle.self, from: clockStyleData) else {
return ClockStyle().keepAwake
}
return decoded.keepAwake
}
} }

View File

@ -16,7 +16,6 @@ struct AlarmView: View {
@Bindable var viewModel: AlarmViewModel @Bindable var viewModel: AlarmViewModel
@State private var showAddAlarm = false @State private var showAddAlarm = false
@State private var selectedAlarmForEdit: Alarm? @State private var selectedAlarmForEdit: Alarm?
@AppStorage(ClockStyle.appStorageKey) private var clockStyleData: Data = Data()
// MARK: - Body // MARK: - Body
var body: some View { var body: some View {
@ -31,10 +30,6 @@ struct AlarmView: View {
Group { Group {
if viewModel.alarms.isEmpty { if viewModel.alarms.isEmpty {
VStack(spacing: Design.Spacing.large) { VStack(spacing: Design.Spacing.large) {
if !isKeepAwakeEnabled {
AlarmLimitationsBanner()
}
EmptyAlarmsView { EmptyAlarmsView {
showAddAlarm = true showAddAlarm = true
} }
@ -45,13 +40,6 @@ struct AlarmView: View {
} }
} else { } else {
List { List {
if !isKeepAwakeEnabled {
AlarmLimitationsBanner()
.listRowInsets(EdgeInsets(top: Design.Spacing.large, leading: Design.Spacing.large, bottom: Design.Spacing.small, trailing: Design.Spacing.large))
.listRowBackground(Color.clear)
.listRowSeparator(.hidden)
}
ForEach(viewModel.alarms) { alarm in ForEach(viewModel.alarms) { alarm in
AlarmRowView( AlarmRowView(
alarm: alarm, alarm: alarm,
@ -128,13 +116,6 @@ struct AlarmView: View {
} }
} }
} }
private var isKeepAwakeEnabled: Bool {
guard let decoded = try? JSONDecoder().decode(ClockStyle.self, from: clockStyleData) else {
return ClockStyle().keepAwake
}
return decoded.keepAwake
}
} }
// MARK: - Preview // MARK: - Preview

View File

@ -1,58 +0,0 @@
//
// AlarmLimitationsBanner.swift
// TheNoiseClock
//
// Created by Matt Bruce on 2/2/26.
//
import SwiftUI
import Bedrock
import Foundation
/// Banner explaining background alarm limitations and mitigation.
struct AlarmLimitationsBanner: View {
@AppStorage(ClockStyle.appStorageKey) private var clockStyleData: Data = Data()
var body: some View {
if isKeepAwakeEnabled {
EmptyView()
} else {
SettingsCard(backgroundColor: AppSurface.card, borderColor: AppBorder.subtle) {
VStack(alignment: .leading, spacing: Design.Spacing.xSmall) {
HStack(spacing: Design.Spacing.xSmall) {
Image(systemName: "exclamationmark.triangle.fill")
.foregroundStyle(AppStatus.warning)
Text("Alarm reliability")
.typography(.body)
.fontWeight(.semibold)
.foregroundStyle(AppTextColors.primary)
}
Text("iOS only allows notification sounds when the app is backgrounded. For a full alarm sound and screen, keep TheNoiseClock open in the foreground.")
.typography(.caption)
.foregroundStyle(AppTextColors.secondary)
Text("Tip: Use the Keep Awake prompt to keep the app on-screen while alarms are active.")
.typography(.caption)
.foregroundStyle(AppTextColors.secondary)
}
.padding(Design.Spacing.medium)
.frame(maxWidth: .infinity, alignment: .leading)
.background(AppSurface.primary)
}
}
}
private var isKeepAwakeEnabled: Bool {
guard let decoded = try? JSONDecoder().decode(ClockStyle.self, from: clockStyleData) else {
return ClockStyle().keepAwake
}
return decoded.keepAwake
}
}
#Preview {
AlarmLimitationsBanner()
.padding()
.background(AppSurface.primary)
}

View File

@ -17,7 +17,6 @@ struct EditAlarmView: View {
let viewModel: AlarmViewModel let viewModel: AlarmViewModel
let alarm: Alarm let alarm: Alarm
@Environment(\.dismiss) private var dismiss @Environment(\.dismiss) private var dismiss
@AppStorage(ClockStyle.appStorageKey) private var clockStyleData: Data = Data()
@State private var alarmTime: Date @State private var alarmTime: Date
@State private var selectedSoundName: String @State private var selectedSoundName: String
@ -54,15 +53,6 @@ struct EditAlarmView: View {
// List for settings below // List for settings below
List { List {
if !isKeepAwakeEnabled {
Section {
AlarmLimitationsBanner()
.listRowInsets(EdgeInsets())
.listRowBackground(Color.clear)
.listRowSeparator(.hidden)
}
}
// Label Section // Label Section
NavigationLink(destination: LabelEditView(label: $alarmLabel)) { NavigationLink(destination: LabelEditView(label: $alarmLabel)) {
HStack { HStack {
@ -169,13 +159,6 @@ struct EditAlarmView: View {
private func getSoundDisplayName(_ fileName: String) -> String { private func getSoundDisplayName(_ fileName: String) -> String {
return AlarmSoundService.shared.getSoundDisplayName(fileName) return AlarmSoundService.shared.getSoundDisplayName(fileName)
} }
private var isKeepAwakeEnabled: Bool {
guard let decoded = try? JSONDecoder().decode(ClockStyle.self, from: clockStyleData) else {
return ClockStyle().keepAwake
}
return decoded.keepAwake
}
} }
// MARK: - Preview // MARK: - Preview