package com.example.smartlab

import android.content.Context
import android.content.Intent
import android.content.SharedPreferences
import androidx.appcompat.app.AppCompatActivity
import com.example.smartlab.fragments.CreatePassCodeFragment

class SharedPreferenceManager (context: Context) {

    // Working with Map<String> : String to get and set value


    private val preference = context.getSharedPreferences(
        context.getString(R.string.app_name), AppCompatActivity.MODE_PRIVATE
    )

    private val editor = preference.edit()


    private val keyIsFirstTime = "isFirstTime"


    // For OnBoarding Activity
    var isFirstTime
        get() = preference.getBoolean(keyIsFirstTime, true)
        set(value){
            editor.putBoolean(keyIsFirstTime, value)
            editor.commit()
        }

    // PassCode saver

    var passCode
        get() = preference.getString("PASSCODE", "")
        set(value){
            editor.putString("PASSCODE", value)
            editor.apply()
        }

    // JWT saver

    var jwt
        get() = preference.getString("JWT", "")
        set(value){
            editor.putString("JWT", value)
            editor.apply()
        }

    // Profile saver

    var Name get() =  preference.getString("Name", " ")
        set(value) {
            editor.putString("Name", value)
            editor.apply()
        }

    var Surname get() = preference.getString("Surname", " ")
        set(value){
            editor.putString("Surname", value)
            editor.apply()
        }

    var Patronymic get() = preference.getString("Patronymic", " ")
        set(value){
            editor.putString("Patronymic", value)
            editor.apply()
        }

    var BirthDay get() = preference.getString("BirthDay", " ")
        set(value){
            editor.putString("BirthDay", value)
            editor.apply()
        }

    var Gender get() = preference.getString("Gender", " ")
        set(value){
            editor.putString("Gender", value)
            editor.apply()
        }

    var ProfilePhoto get() = preference.getString("ProfilePhoto", "")
        set(value)  {
            editor.putString("ProfilePhoto", value)
            editor.apply()
        }

}

