fun DtConsole()

in hot-reload-devtools/src/main/kotlin/org/jetbrains/compose/devtools/sidecar/DtConsole.kt [38:88]


fun DtConsole(
    logs: List<String>,
    modifier: Modifier = Modifier,
    scrollToBottom: Boolean = true,
    animateBorder: Boolean = true,
) {
    val verticalScrollState = rememberLazyListState()
    val horizontalScrollState = rememberScrollState()

    LaunchedEffect(logs.size) {
        if (logs.isNotEmpty() && scrollToBottom) {
            verticalScrollState.animateScrollToItem(logs.lastIndex)
        }
    }

    Box(
        modifier
            .tag(Tag.Console)
            .apply {
                if (animateBorder) animatedReloadStatusBorder(idleColor = Color.Gray, resetErrorState = true)
                else dtBorder()
            }
            .clip(DtShapes.RoundedCornerShape)
            .fillMaxSize(),
    ) {
        SelectionContainer {
            LazyColumn(
                state = verticalScrollState,
                contentPadding = PaddingValues(
                    horizontal = DtPadding.smallElementPadding,
                    vertical = DtPadding.smallElementPadding,
                ),
                modifier = Modifier.horizontalScroll(horizontalScrollState),
            ) {
                items(logs) { log ->
                    DtCode(log)
                }
            }
        }
        VerticalScrollbar(
            modifier = Modifier.align(Alignment.CenterEnd).fillMaxHeight(),
            adapter = rememberScrollbarAdapter(verticalScrollState),
            style = dtScrollbarStyle(),
        )
        HorizontalScrollbar(
            modifier = Modifier.align(Alignment.BottomCenter).fillMaxWidth(),
            adapter = rememberScrollbarAdapter(horizontalScrollState),
            style = dtScrollbarStyle(),
        )
    }
}