package com.za.base.view

import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.CenterAlignedTopAppBar
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import coil.compose.AsyncImage
import com.za.base.theme.headBgColor
import com.za.servicing.R

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun HeadView(title : String,
	onBack : () -> Unit = {},
	isCanBack : Boolean = true,
	action : @Composable () -> Unit = {}) {
	Column {
		CenterAlignedTopAppBar(modifier = Modifier.fillMaxWidth(),
			colors = TopAppBarDefaults.centerAlignedTopAppBarColors()
				.copy(containerColor = headBgColor, titleContentColor = Color.White),
			title = { Text(text = title, fontSize = 15.sp, fontWeight = FontWeight.Medium) },
			navigationIcon = {
				if (isCanBack) {
					AsyncImage(model = R.drawable.sv_back,
						contentDescription = "",
						modifier = Modifier
							.size(40.dp)
							.clickable { onBack() }
							.padding(10.dp))
				}
			},
			actions = { action() })

		AppTipsView()
	}
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun HeadViewNotBack(title : String) {
	Column {
		CenterAlignedTopAppBar(modifier = Modifier.fillMaxWidth(),
			colors = TopAppBarDefaults.centerAlignedTopAppBarColors()
				.copy(containerColor = headBgColor, titleContentColor = Color.White),
			title = { Text(text = title, fontSize = 15.sp, fontWeight = FontWeight.Medium) },
			navigationIcon = {})

		AppTipsView()
	}
}