34 lines
839 B
Swift
34 lines
839 B
Swift
//
|
|
// AppSettings.swift
|
|
// MultiChrono
|
|
//
|
|
// Created by Beatrice Dellacà on 27/01/26.
|
|
//
|
|
|
|
import Foundation
|
|
import Combine
|
|
|
|
enum TimeFormat: String, CaseIterable, Codable {
|
|
case millis = "Millis (00:00.000)"
|
|
case cents = "Cents (00:00.00)"
|
|
case tenths = "Tenths (00:00.0)"
|
|
case seconds = "Seconds (00:00)"
|
|
|
|
var displayName: String { self.rawValue }
|
|
}
|
|
|
|
class AppSettings: ObservableObject {
|
|
static let shared = AppSettings()
|
|
|
|
@Published var timeFormat: TimeFormat {
|
|
didSet {
|
|
UserDefaults.standard.set(timeFormat.rawValue, forKey: "timeFormat")
|
|
}
|
|
}
|
|
|
|
private init() {
|
|
let savedFormat = UserDefaults.standard.string(forKey: "timeFormat") ?? TimeFormat.tenths.rawValue
|
|
self.timeFormat = TimeFormat(rawValue: savedFormat) ?? .tenths
|
|
}
|
|
}
|