//
//  AppSettings.swift
//  PadelClub
//
//  Created by Razmig Sarkissian on 26/03/2024.
//

import Foundation
import LeStorage
import SwiftUI

@Observable
final class AppSettings: MicroStorable {
    
    var lastDataSource: String? = nil
    var didCreateAccount: Bool = false
    var didRegisterAccount: Bool = false
    
    required init() {
        
    }
    
    required init(from decoder: Decoder) throws {
        let container = try decoder.container(keyedBy: CodingKeys.self)
        lastDataSource = try container.decodeIfPresent(String.self, forKey: ._lastDataSource)
        didCreateAccount = try container.decodeIfPresent(Bool.self, forKey: ._didCreateAccount) ?? false
        didRegisterAccount = try container.decodeIfPresent(Bool.self, forKey: ._didRegisterAccount) ?? false
    }
    
    enum CodingKeys: String, CodingKey {
        case _lastDataSource = "lastDataSource"
        case _didCreateAccount = "didCreateAccount"
        case _didRegisterAccount = "didRegisterAccount"
    }
}
