silent mode alert

release
Laurent 3 years ago
parent 2f19388cbf
commit 218fa29d8d
  1. 4
      LeCountdown.xcodeproj/project.pbxproj
  2. 24
      LeCountdown/Utils/Preferences.swift
  3. 16
      LeCountdown/Views/DialView.swift

@ -108,6 +108,7 @@
C4BA2B22299BE82E00CB4FBA /* AbstractSoundTimer+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4BA2AEF2996A11900CB4FBA /* AbstractSoundTimer+CoreDataProperties.swift */; };
C4BA2B23299BE82E00CB4FBA /* AbstractSoundTimer+CoreDataProperties.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4BA2AEF2996A11900CB4FBA /* AbstractSoundTimer+CoreDataProperties.swift */; };
C4BA2B25299D35C100CB4FBA /* HomeView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4BA2B24299D35C100CB4FBA /* HomeView.swift */; };
C4BA2B2D299E2DEE00CB4FBA /* Preferences.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4BA2B2C299E2DEE00CB4FBA /* Preferences.swift */; };
C4F8B1532987FE6F005C86A5 /* LaunchWidgetLiveActivity.swift in Sources */ = {isa = PBXBuildFile; fileRef = C438C7D72981216200BF3EF9 /* LaunchWidgetLiveActivity.swift */; };
C4F8B15729891271005C86A5 /* Conductor.swift in Sources */ = {isa = PBXBuildFile; fileRef = C4F8B15629891271005C86A5 /* Conductor.swift */; };
C4F8B15929891528005C86A5 /* forest_stream.mp3 in Resources */ = {isa = PBXBuildFile; fileRef = C4F8B15829891528005C86A5 /* forest_stream.mp3 */; };
@ -289,6 +290,7 @@
C4BA2B0D299BE61E00CB4FBA /* IntervalGroup+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "IntervalGroup+CoreDataProperties.swift"; sourceTree = "<group>"; };
C4BA2B0E299BE61E00CB4FBA /* Countdown+CoreDataProperties.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Countdown+CoreDataProperties.swift"; sourceTree = "<group>"; };
C4BA2B24299D35C100CB4FBA /* HomeView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeView.swift; sourceTree = "<group>"; };
C4BA2B2C299E2DEE00CB4FBA /* Preferences.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Preferences.swift; sourceTree = "<group>"; };
C4F8B15629891271005C86A5 /* Conductor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Conductor.swift; sourceTree = "<group>"; };
C4F8B15829891528005C86A5 /* forest_stream.mp3 */ = {isa = PBXFileReference; lastKnownFileType = audio.mp3; path = forest_stream.mp3; sourceTree = "<group>"; };
C4F8B15E298961A7005C86A5 /* ReorderableForEach.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReorderableForEach.swift; sourceTree = "<group>"; };
@ -493,6 +495,7 @@
children = (
C4BA2AFC299A3A3700CB4FBA /* AppleMusicPlayer.swift */,
C4742B5629840F6400D5D950 /* CoolPic.swift */,
C4BA2B2C299E2DEE00CB4FBA /* Preferences.swift */,
C438C81029829EAF00BF3EF9 /* PropertyWrappers.swift */,
C40FDB612992985C0042A390 /* TextToSpeechRecorder.swift */,
C4060DF4297AE9A7003FAB80 /* TimeInterval+Extensions.swift */,
@ -860,6 +863,7 @@
C445FA8F2987B83B0054D761 /* SoundPlayer.swift in Sources */,
C4F8B1A7298AC2FC005C86A5 /* AbstractSoundTimer+CoreDataClass.swift in Sources */,
C438C7C929803CA000BF3EF9 /* AppDelegate.swift in Sources */,
C4BA2B2D299E2DEE00CB4FBA /* Preferences.swift in Sources */,
C4F8B185298AC234005C86A5 /* AbstractTimer+CoreDataProperties.swift in Sources */,
C4F8B169298AA236005C86A5 /* StopwatchFormView.swift in Sources */,
C4F8B1BD298AC8DE005C86A5 /* AlarmDialView.swift in Sources */,

@ -0,0 +1,24 @@
//
// Preferences.swift
// LeCountdown
//
// Created by Laurent Morvillier on 16/02/2023.
//
import Foundation
enum PreferenceKey: String {
case showSilentModeAlert
}
class Preferences {
static var hideSilentModeAlerts: Bool {
return UserDefaults.standard.bool(forKey: PreferenceKey.showSilentModeAlert.rawValue)
}
static func hideSilentModeAlerts(_ hide: Bool) {
UserDefaults.standard.setValue(true, forKey: PreferenceKey.showSilentModeAlert.rawValue)
}
}

@ -17,6 +17,8 @@ struct DialView: View {
@State var timer: AbstractTimer
var isEditingBinding: Binding<Bool>
@State var showSilentModeAlert: Bool = false
var frameSize: CGFloat
var body: some View {
@ -27,7 +29,11 @@ struct DialView: View {
switch self.isEditingBinding.wrappedValue {
case false:
Button {
self._launchTimer()
if Preferences.hideSilentModeAlerts {
self._launchTimer()
} else {
self.showSilentModeAlert = true
}
} label: {
VStack {
Spacer()
@ -58,6 +64,14 @@ struct DialView: View {
}
.frame(width: frameSize, height: 80.0)
.cornerRadius(20.0)
.alert("Make sure your device is not on silent mode", isPresented: $showSilentModeAlert) {
Button("OK", role: .cancel) { self._launchTimer()
}
Button("Don't show this again", role: .destructive) {
self._launchTimer()
Preferences.hideSilentModeAlerts(true)
}
}
}
@ViewBuilder

Loading…
Cancel
Save