//
//  DebugSettingsView.swift
//  PadelClub
//
//  Created by Laurent Morvillier on 28/05/2024.
//

import SwiftUI
import LeStorage

struct DebugSettingsView: View {
    var body: some View {
        List {
            LabeledContent("UUID", value: self._userId)
            LabeledContent("User Name", value: self._userName)
            LabeledContent("Token", value: self._token)
            LabeledContent("Server", value: self._server)
            LabeledContent("Synchronized", value: self._synchronized)
            LabeledContent("CollectionsCanSynchronize", value: self._canSynchronize)
        }
    }
    
    fileprivate var _userId: String {
        return Store.main.userId ?? ""
    }
    
    fileprivate var _userName: String {
        return Store.main.userName() ?? ""
    }
    
    fileprivate var _token: String {
        return Store.main.token() ?? ""
    }
    
    fileprivate var _server: String {
        return PListReader.readString(plist: "local", key: "server") ?? ""
    }
    
    fileprivate var _synchronized: String {
        if let synchronized = PListReader.readBool(plist: "local", key: "synchronized") {
            return "\(synchronized)"
        } else {
            return "not specified"
        }
    }
    
    fileprivate var _canSynchronize: String {
        return "\(Store.main.collectionsCanSynchronize)"
    }
}

//#Preview {
//    DebugSettingsView()
//}
