package dev.ulfrx.recipe.auth

import android.content.Context
import com.russhwolf.settings.Settings
import com.russhwolf.settings.SharedPreferencesSettings
import dev.lokksmith.Lokksmith
import dev.lokksmith.SingletonLokksmithProvider
import dev.lokksmith.createLokksmith
import org.koin.android.ext.koin.androidContext
import org.koin.dsl.module

val androidAuthModule =
    module {
        single<Lokksmith> {
            createLokksmith(androidContext().applicationContext).also { lokksmith ->
                SingletonLokksmithProvider.set(lokksmith)
            }
        }
        single<Settings> {
            val prefs = androidContext().applicationContext.getSharedPreferences("recipe_auth_state", Context.MODE_PRIVATE)
            SharedPreferencesSettings(prefs)
        }
    }
