package com.example.modifier

import android.app.Application
import android.content.Context
import android.util.Log
import coil3.ImageLoader
import coil3.SingletonImageLoader
import coil3.request.crossfade
import com.example.modifier.data.AppContainer
import com.example.modifier.data.AppDataContainer
import com.example.modifier.repo.AppPrefsRepo
import dagger.hilt.android.HiltAndroidApp

const val baseTag = "Modifier"

@HiltAndroidApp
class MyApplication : Application(), SingletonImageLoader.Factory {
    companion object {
        private const val TAG = "$baseTag/MyApplication"
    }

    lateinit var container: AppContainer

    override fun onCreate() {
        super.onCreate()
        //        DynamicColors.applyToActivitiesIfAvailable(this);
        container = AppDataContainer(this)

        Log.i(TAG, "server=${AppPrefsRepo.instance.appPrefs.value.server}")
    }


    override fun newImageLoader(context: Context): ImageLoader {
        return ImageLoader.Builder(context)
            .crossfade(true)
            .build()
    }
}
