//
//  Preferences.swift
//  LeCountdown
//
//  Created by Laurent Morvillier on 16/02/2023.
//

import Foundation

enum PreferenceKey: String {
    case countdowns
    case stopwatches
    case showSilentModeAlert
    case soundDurations
}

class Preferences {
    
    @UserDefault(PreferenceKey.countdowns.rawValue, defaultValue: [:]) static var savedCountdowns: [String : DateInterval]
    @UserDefault(PreferenceKey.soundDurations.rawValue, defaultValue: [:]) static var soundDurations: [Int : TimeInterval]

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