TreeView

@Composable
fun <T> TreeView(modifier: Modifier = Modifier, tree: Tree<T>, treeState: TreeState = rememberTreeState(), onElementClick: (Tree.Element<T>) -> Unit = { Log.d("click") }, onElementDoubleClick: (Tree.Element<T>) -> Unit = { Log.d("double click") }, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, deepIndentDP: Dp = 20.dp, focusedBackgroundColor: Color = Color.LightGray, selectionFocusedBackgroundColor: Color, selectionBackgroundColor: Color, platformDoubleClickDelay: Long = 500, keyActions: KeyBindingScopedActions = DefaultTreeViewKeyActions(treeState), pointerEventScopedActions: PointerEventScopedActions = DefaultTreeViewPointerEventAction( treeState, platformDoubleClickDelay, onElementClick, onElementDoubleClick ), arrowContent: @Composable (isOpen: Boolean) -> Unit, elementContent: @Composable SelectableLazyItemScope.(Tree.Element<T>) -> Unit)

A composable that displays a tree-like structure of elements in a hierarchical manner.

Parameters

modifier

The modifier to apply to this layout.

tree

The tree structure to be displayed.

treeState

The state object that holds the state information for the tree view.

onElementClick

The callback to be invoked when an element is clicked.

onElementDoubleClick

The callback to be invoked when an element is double-clicked.

interactionSource

The interaction source for handling user input events.

deepIndentDP

The depth of indentation for nested elements in the tree view, in density-independent pixels.

focusedBackgroundColor

The background color to be applied to the focused element.

selectionFocusedBackgroundColor

The background color to be applied to the focused and selected element.

selectionBackgroundColor

The background color to be applied to the selected element.

platformDoubleClickDelay

The delay duration in milliseconds for registering a double-click event based on the platform's behavior.

keyActions

The key binding actions for handling keyboard events.

pointerEventScopedActions

The pointer event actions for handling pointer events.

arrowContent

The content to be displayed for the expand/collapse arrow of each tree node, specified as a lambda function with an isOpen parameter.

elementContent

The content to be displayed for each tree element, specified as a lambda function with a SelectableLazyItemScope receiver and a Tree.Element<T> parameter.

T

The type of data held by each tree element.