package mg.dot.feufaro.ui

import androidx.compose.foundation.ScrollState
import androidx.compose.foundation.VerticalScrollbar
import androidx.compose.foundation.background
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.rememberScrollbarAdapter
import androidx.compose.foundation.lazy.LazyListState
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color

@Composable
actual fun MyVerticalScrollbar (
    modifier: Modifier,
    scrollState: ScrollState?,
    lazyListState: LazyListState?,
    content: @Composable () -> Unit,
) {
    Box ( modifier = Modifier.fillMaxSize()){
        content()

        val adapter = when {
            lazyListState != null -> rememberScrollbarAdapter(lazyListState)
            scrollState != null -> rememberScrollbarAdapter(scrollState)
            else -> null
        }

        if (adapter != null) {
            VerticalScrollbar(
                adapter = adapter,
                modifier = modifier.fillMaxHeight(0.5f).background(Color.Green.copy(0.75f))
            )
            //content()
        }
    }
}
