package cl.homelogic.platform.designsystem.themes

import cl.homelogic.platform.common.logging.Trace
import cl.homelogic.platform.common.logging.TreeRoots
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
import kotlinx.coroutines.launch

enum class StatusBarState {
    LIGHT,
    DARK,
}

@Suppress("EXPECT_ACTUAL_CLASSIFIERS_ARE_IN_BETA_WARNING")
actual class StatusBarManager : IStatusBarManager {
    private val _coroutineScope = CoroutineScope(Dispatchers.Default)

    companion object {
        private val _statusBarState = MutableStateFlow(StatusBarState.LIGHT)
        val state: StateFlow<StatusBarState> = _statusBarState.asStateFlow()
    }

    override fun lightMode() {
        Trace.d(TreeRoots.DesignSystem, "Android - requesting light status bar")
        _coroutineScope.launch {
            _statusBarState.emit(StatusBarState.LIGHT)
        }
    }

    override fun darkMode() {
        Trace.d(TreeRoots.DesignSystem, "Android - requesting dark status bar")
        _coroutineScope.launch {
            _statusBarState.emit(StatusBarState.DARK)
        }
    }
}
