package com.za.base.view

import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.KeyboardArrowLeft
import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.za.base.theme.headBgColor

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun HeadView(title : String,
	onBack : () -> Unit = {},
	isCanBack : Boolean = true,
	action : @Composable () -> Unit = {}) {
	Column {
		Box(modifier = Modifier
			.fillMaxWidth()
			.background(color = headBgColor)
			.padding(horizontal = 10.dp, vertical = 5.dp), contentAlignment = Alignment.Center) {

			Row(modifier = Modifier.fillMaxWidth(),
				verticalAlignment = Alignment.CenterVertically,
				horizontalArrangement = Arrangement.SpaceBetween) {

				if (isCanBack) {
					Icon(Icons.Default.KeyboardArrowLeft,
						contentDescription = "",
						modifier = Modifier
							.clickable { onBack() }
							.padding(5.dp),
						tint = Color.White)
				}
				action()
			}

			Box(modifier = Modifier.fillMaxWidth(), contentAlignment = Alignment.Center) {
				Text(text = title,
					fontSize = 16.sp,
					color = Color.White.copy(alpha = 0.95f),
					fontWeight = FontWeight.Medium,
					style = TextStyle.Default.copy())
			}
		}

		AppTipsView()
	}
}

@OptIn(ExperimentalMaterial3Api::class)
@Composable
fun HeadViewNotBack(title : String) {
	Column {
		Box(modifier = Modifier
			.fillMaxWidth()
			.background(color = headBgColor)
			.padding(horizontal = 10.dp, vertical = 5.dp), contentAlignment = Alignment.Center) {
			Box(modifier = Modifier.fillMaxWidth(), contentAlignment = Alignment.Center) {
				Text(text = title,
					fontSize = 16.sp,
					color = Color.White.copy(alpha = 0.95f),
					fontWeight = FontWeight.Medium,
					style = TextStyle.Default.copy())
			}
		}

		AppTipsView()
	}
}