package it.danieleverducci.openweddingapp

import android.app.Application
import it.danieleverducci.openweddingapp.entities.RemoteSettings
import it.danieleverducci.openweddingapp.entities.Token
import it.danieleverducci.openweddingapp.utils.SharedPreferencesManager

class DeRApplication: Application() {
    var token: Token?
    set(value) {
        if (value != null)
            SharedPreferencesManager.saveToken(this, value)
        else
            SharedPreferencesManager.deleteToken(this)
    }
    get() {
        val t = SharedPreferencesManager.loadToken(this)
        if (t != null) {
            return t
        }
        return null
    }

    val remoteSettings: RemoteSettings
    get() {
        return SharedPreferencesManager.loadRemoteSettings(this)
    }

    // Clears all the user data and cache
    fun clearData(){
        SharedPreferencesManager.clear(this)
    }

    // Store true if the user was already asked to connect to wifi connection until the app is restarted
    var askedConnectingToWeddingWifi = false
}