package com.tt.honeyDue.storage

import android.content.Context
import android.content.SharedPreferences

/**
 * Android implementation of biometric preference storage using SharedPreferences.
 * Follows the same pattern as ThemeStorageManager.android.kt.
 */
actual class BiometricPreferenceManager(context: Context) {
    private val prefs: SharedPreferences = context.getSharedPreferences(PREFS_NAME, Context.MODE_PRIVATE)

    actual fun isBiometricEnabled(): Boolean {
        return prefs.getBoolean(KEY_BIOMETRIC_ENABLED, false)
    }

    actual fun setBiometricEnabled(enabled: Boolean) {
        prefs.edit().putBoolean(KEY_BIOMETRIC_ENABLED, enabled).apply()
    }

    companion object {
        private const val PREFS_NAME = "honeydue_biometric_prefs"
        private const val KEY_BIOMETRIC_ENABLED = "biometric_enabled"

        @Volatile
        private var instance: BiometricPreferenceManager? = null

        fun getInstance(context: Context): BiometricPreferenceManager {
            return instance ?: synchronized(this) {
                instance ?: BiometricPreferenceManager(context.applicationContext).also { instance = it }
            }
        }
    }
}
