package ru.fincode.tsudesk.core.ui.components

import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.NavigationBar
import androidx.compose.material3.NavigationBarItem
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable

@Composable
fun TsudeskBottomBar(
    items: List<BottomBarItem>,
    selectedKey: String,
    onItemClick: (BottomBarItem) -> Unit,
) {
    NavigationBar {
        items.forEach { item ->
            val selected = item.key == selectedKey

            NavigationBarItem(
                selected = selected,
                onClick = { onItemClick(item) },
                icon = {
                    Icon(
                        imageVector = item.icon,
                        contentDescription = item.label,
                        tint = if (selected)
                            MaterialTheme.colorScheme.primary
                        else
                            MaterialTheme.colorScheme.onSurfaceVariant
                    )
                },
                label = { Text(item.label) }
            )
        }
    }
}