package com.ys.bdtp.adm

import androidx.compose.material.MaterialTheme
import androidx.compose.material.Surface
import androidx.compose.runtime.Composable
import androidx.compose.runtime.SideEffect
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import com.google.accompanist.insets.ProvideWindowInsets
import com.google.accompanist.systemuicontroller.rememberSystemUiController
import com.ys.bdtp.adm.app.theme.AdmTheme
import com.ys.bdtp.adm.di.di
import com.ys.bdtp.adm.mvvm.ui.screen.project.ProjectScreen
import org.kodein.di.compose.onDIContext
import org.kodein.di.compose.withDI

@Composable
fun App() = withDI(di(LocalContext.current)) {

    onDIContext(LocalContext.current) {
        val systemUiController = rememberSystemUiController()
        val useDarkIcons = MaterialTheme.colors.isLight

        AdmTheme() {
            ProvideWindowInsets {
                Surface(color = MaterialTheme.colors.background) {
                    SideEffect {
                        systemUiController.setNavigationBarColor(
                            color = Color.Transparent,
                            darkIcons = useDarkIcons,
                        )

                        systemUiController.setStatusBarColor(
                            color = Color.Transparent,
                            darkIcons = useDarkIcons,
                        )
                    }
                    ProjectScreen()
                }
            }
        }
    }
}