package com.isidroid.c23.ui._component

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.RowScope
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.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp

@OptIn(ExperimentalMaterial3Api::class)
@Composable
internal fun TopAppBarComponent(
    text: String,
    modifier: Modifier = Modifier,
    alpha: Float = 1f,
    onNavigationClick: (() -> Unit)? = null,
    colors: TopAppBarColors? = null,
    actions: @Composable RowScope.() -> Unit = {}
) {
    CenterAlignedTopAppBar(
        actions = actions,
        modifier = modifier.height(64.dp),
        title = {
            Text(
                text = text,
                style = MaterialTheme.typography.titleMedium,
                fontWeight = FontWeight.Medium,
                fontSize = 18.sp
            )

        },
        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() })
        }
    )
}