Signed-off-by: Matt Bruce <mbrucedogs@gmail.com>
This commit is contained in:
parent
3ed7da63f7
commit
e03689f38c
@ -15,7 +15,6 @@ struct AddAlarmView: View {
|
||||
// MARK: - Properties
|
||||
let viewModel: AlarmViewModel
|
||||
@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 selectedSoundName = "digital-alarm.caf"
|
||||
@ -35,15 +34,6 @@ struct AddAlarmView: View {
|
||||
|
||||
// List for settings below
|
||||
List {
|
||||
if !isKeepAwakeEnabled {
|
||||
Section {
|
||||
AlarmLimitationsBanner()
|
||||
.listRowInsets(EdgeInsets())
|
||||
.listRowBackground(Color.clear)
|
||||
.listRowSeparator(.hidden)
|
||||
}
|
||||
}
|
||||
|
||||
// Label Section
|
||||
NavigationLink(destination: LabelEditView(label: $alarmLabel)) {
|
||||
HStack {
|
||||
@ -138,11 +128,4 @@ struct AddAlarmView: View {
|
||||
private func getSoundDisplayName(_ fileName: String) -> String {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
||||
@ -16,7 +16,6 @@ struct AlarmView: View {
|
||||
@Bindable var viewModel: AlarmViewModel
|
||||
@State private var showAddAlarm = false
|
||||
@State private var selectedAlarmForEdit: Alarm?
|
||||
@AppStorage(ClockStyle.appStorageKey) private var clockStyleData: Data = Data()
|
||||
|
||||
// MARK: - Body
|
||||
var body: some View {
|
||||
@ -31,10 +30,6 @@ struct AlarmView: View {
|
||||
Group {
|
||||
if viewModel.alarms.isEmpty {
|
||||
VStack(spacing: Design.Spacing.large) {
|
||||
if !isKeepAwakeEnabled {
|
||||
AlarmLimitationsBanner()
|
||||
}
|
||||
|
||||
EmptyAlarmsView {
|
||||
showAddAlarm = true
|
||||
}
|
||||
@ -45,13 +40,6 @@ struct AlarmView: View {
|
||||
}
|
||||
} else {
|
||||
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
|
||||
AlarmRowView(
|
||||
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
|
||||
|
||||
@ -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)
|
||||
}
|
||||
@ -17,7 +17,6 @@ struct EditAlarmView: View {
|
||||
let viewModel: AlarmViewModel
|
||||
let alarm: Alarm
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
@AppStorage(ClockStyle.appStorageKey) private var clockStyleData: Data = Data()
|
||||
|
||||
@State private var alarmTime: Date
|
||||
@State private var selectedSoundName: String
|
||||
@ -54,15 +53,6 @@ struct EditAlarmView: View {
|
||||
|
||||
// List for settings below
|
||||
List {
|
||||
if !isKeepAwakeEnabled {
|
||||
Section {
|
||||
AlarmLimitationsBanner()
|
||||
.listRowInsets(EdgeInsets())
|
||||
.listRowBackground(Color.clear)
|
||||
.listRowSeparator(.hidden)
|
||||
}
|
||||
}
|
||||
|
||||
// Label Section
|
||||
NavigationLink(destination: LabelEditView(label: $alarmLabel)) {
|
||||
HStack {
|
||||
@ -169,13 +159,6 @@ struct EditAlarmView: View {
|
||||
private func getSoundDisplayName(_ fileName: String) -> String {
|
||||
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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user