package mg.dot.feufaro.di

import android.content.Context
import com.russhwolf.settings.Settings
import com.russhwolf.settings.SharedPreferencesSettings
import mg.dot.feufaro.AndroidFileRepository
import mg.dot.feufaro.FileRepository
import mg.dot.feufaro.config.AppConfig
import org.koin.dsl.module

val androidModule = module {
    // Koin will automatically provide the Android Context because you called androidContext() in AndroidApp.
    // It then uses this Context to construct AndroidFileRepository.
    single<AppConfig> {
        AppConfig(
            transposeto = "C",
            transposeasif = "C",
        )
    }
    single<Settings> {
        val sharedPrefs = get<Context>().getSharedPreferences("mg.dot.feufaro", Context.MODE_PRIVATE)
        SharedPreferencesSettings(sharedPrefs)
    }

}

// androidMain/kotlin/mg/dot/feufaro/Koin.android.kt
actual val platformModule = module {
    single<FileRepository> { AndroidFileRepository(get()) } // get() récupère androidContext
}