KwikAccordionGroup

fun <T> KwikAccordionGroup(allowMultipleExpanded: Boolean = true, initialExpandedIndices: List<Int> = emptyList(), items: List<T>, titleProvider: (T) -> String, headerIconProvider: (T) -> Int?? = null, containerColor: Color = MaterialTheme.colorScheme.surface, elevation: Int = 8, headerTextColor: Color = MaterialTheme.colorScheme.onSurface, errorProvider: (T) -> Boolean? = null, @DrawableRes errorIcon: Int? = null, content: @Composable (T) -> Unit)

AccordionGroup component that manages a group of accordions. Can be configured to allow multiple accordions to be expanded at once or only one at a time.

Parameters

allowMultipleExpanded

: If true, multiple accordions can be expanded at once. If false, only one accordion can be expanded at a time.

initialExpandedIndices

: List of indices that should be expanded initially.

items

: List of items to create accordions for.

titleProvider

: Function to extract the title from an item.

headerIconProvider

: Function to extract the header icon from an item (optional).

containerColor

: The color of the accordion containers.

elevation

: The elevation of the accordions.

headerTextColor

: The color of the titles.

errorProvider

: Function to determine if an item should display an error (optional).

errorIconProvider

: Function to extract the error icon from an item (optional).

contentProvider

: Function to provide the content for each accordion.

Example usage:

val items = listOf(
AccordionItem("First Item", "Content for first item"),
AccordionItem("Second Item", "Content for second item", true),
AccordionItem("Third Item", "Content for third item")
)

KwikAccordionGroup(
allowMultipleExpanded = false,
initialExpandedIndices = listOf(0),
items = items,
titleProvider = { it.title },
containerColor = Color.White,
elevation = 8,
headerTextColor = Color.Black,
errorProvider = { it.hasError },
errorIcon = R.drawable.error_icon
) { item ->
Text(text = item.content, modifier = Modifier.padding(16.dp))
}