package com.isidroid.c23.ui._component

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.height
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.rounded.KeyboardArrowLeft
import androidx.compose.material3.CenterAlignedTopAppBar
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBarColors
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp

@OptIn(ExperimentalMaterial3Api::class)
@Composable
internal fun TopAppBarComponent(
    text: String,
    modifier: Modifier = Modifier,
    alpha: Float = 1f,
    onNavigationClick: (() -> Unit)? = null,
    colors: TopAppBarColors? = null
) {
    CenterAlignedTopAppBar(
        modifier = modifier.height(64.dp),
        title = {
            Text(
                text = text,
                style = MaterialTheme.typography.bodyLarge,
            )

        },
        colors = colors ?: TopAppBarDefaults.topAppBarColors().copy(containerColor = MaterialTheme.colorScheme.secondaryContainer.copy(alpha = alpha)),
        navigationIcon = {
            if (onNavigationClick != null)
                Icon(Icons.AutoMirrored.Rounded.KeyboardArrowLeft, contentDescription = null, modifier = Modifier.clickable { onNavigationClick() })
        }
    )
}