package com.example.myapplication.components.templates

import ButtonNice
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.aspectRatio
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import androidx.navigation.compose.rememberNavController
import com.example.myapplication.product.ProductOld
import myColor1

@Composable
fun ProductCard(product: ProductOld, onClickAction: () -> Unit) {
    Column (modifier = Modifier.padding(top = 20.dp, start = 10.dp, end=10.dp)) {
        Row {
            Image(
                painter = painterResource(id = product.imgId),
                contentDescription = null,
                modifier = Modifier
                    .size(200.dp)
                    .aspectRatio(1f) // Устанавливаем соотношение сторон 1:1 (квадрат)
            )
            Column (modifier = Modifier.padding(start = 15.dp, end = 15.dp)){
                Text(text = product.name, fontSize = 24.sp, color = Color.Black)
                Text(text = product.price.toString() + " ₽", fontSize = 16.sp, color = Color.Black)
            }
        }
        ButtonNice(text ="Добавить в корзину" , color = myColor1, onClickAction)
    }
}

@Preview(showBackground = true)
@Composable
fun ProductCardPreview() {
    val navController = rememberNavController()
    //val product: Product = Product("MSI GeForce RTX 4090 VENTUS 3X OC" ,"Инфо",15000, R.drawable.product1)
    //ProductCard(product, {navController.navigate("main")})
}