Пофиксил всо
This commit is contained in:
parent
1381fe1a37
commit
56b1e815c6
@ -1,17 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="deploymentTargetDropDown">
|
||||
<runningDeviceTargetSelectedWithDropDown>
|
||||
<Target>
|
||||
<type value="RUNNING_DEVICE_TARGET" />
|
||||
<deviceKey>
|
||||
<Key>
|
||||
<type value="VIRTUAL_DEVICE_PATH" />
|
||||
<value value="C:\Users\romai\.android\avd\Pixel_3a_API_34_extension_level_7_x86_64.avd" />
|
||||
</Key>
|
||||
</deviceKey>
|
||||
</Target>
|
||||
</runningDeviceTargetSelectedWithDropDown>
|
||||
<targetSelectedWithDropDown>
|
||||
<Target>
|
||||
<type value="QUICK_BOOT_TARGET" />
|
||||
|
@ -17,6 +17,7 @@ import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.navigation.NavController
|
||||
import com.example.myapplication.components.funs.ProductCardInCart
|
||||
import com.example.myapplication.components.funs.createProductCard
|
||||
import com.example.myapplication.database.AppDb
|
||||
import com.example.myapplication.database.entities.Product
|
||||
@ -49,7 +50,7 @@ fun Cart(navController: NavController){
|
||||
|
||||
item {
|
||||
for (product in products){
|
||||
createProductCard(product.name, product.price, product.img, { } )
|
||||
ProductCardInCart(product.name, product.price, product.img, { navController.navigate("product/" + product.productId)})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -31,10 +31,10 @@ import kotlinx.coroutines.withContext
|
||||
@Composable
|
||||
fun Main(navController: NavController, categoryId: Int) {
|
||||
|
||||
|
||||
val context = LocalContext.current
|
||||
val products = remember { mutableStateListOf<Product>() }
|
||||
|
||||
|
||||
if (categoryId == 0){
|
||||
LaunchedEffect(Unit) {
|
||||
withContext(Dispatchers.IO) {
|
||||
@ -65,23 +65,21 @@ fun Main(navController: NavController, categoryId: Int) {
|
||||
.fillMaxSize()
|
||||
.padding(8.dp)
|
||||
) {
|
||||
item { OutlinedTextField(
|
||||
value = "",
|
||||
onValueChange = { },
|
||||
placeholder = { Text("Поиск товара") },
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(8.dp)
|
||||
) }
|
||||
// item { OutlinedTextField(
|
||||
// value = "",
|
||||
// onValueChange = { },
|
||||
// placeholder = { Text("Поиск товара") },
|
||||
// modifier = Modifier
|
||||
// .fillMaxWidth()
|
||||
// .padding(8.dp)
|
||||
// ) }
|
||||
item {Text(
|
||||
text = "Товары дня:",
|
||||
text = "Товары:",
|
||||
fontSize = 28.sp,
|
||||
color = Color.Black,
|
||||
modifier = Modifier.padding(8.dp)
|
||||
)}
|
||||
|
||||
// createProductCard(productById!!.name, productById!!.price, productById!!.img, { } )
|
||||
|
||||
item{products.forEach {
|
||||
createProductCard(it.name, it.price, it.img, { navController.navigate("product/" + it.productId) } )
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import androidx.annotation.DrawableRes
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.aspectRatio
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
@ -14,6 +15,8 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.size
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
@ -23,7 +26,9 @@ import androidx.compose.ui.graphics.asImageBitmap
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.example.myapplication.R
|
||||
import myColor1
|
||||
import myColor3
|
||||
import myColor4
|
||||
|
||||
@Composable
|
||||
@ -45,32 +50,71 @@ fun createProductCard(name: String, price: Double, img: Bitmap, onClickAction: (
|
||||
ButtonNice("Добавить в корзину" , myColor1, onClickAction)
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun createProductPage(name: String,info: String,price: Int, @DrawableRes imgId: Int, onClickAction: () -> Unit){
|
||||
LazyColumn (modifier = Modifier.fillMaxSize().padding(10.dp)) {
|
||||
fun ProductCardInCart(name: String, price: Double, img: Bitmap, onClickAction: () -> Unit) {
|
||||
Column(modifier = Modifier.padding(top = 20.dp, start = 10.dp, end = 10.dp)) {
|
||||
Row {
|
||||
Image(
|
||||
bitmap = img.asImageBitmap(),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(150.dp)
|
||||
)
|
||||
Column(modifier = Modifier.padding(start = 15.dp, end = 15.dp)) {
|
||||
Text(text = name, fontSize = 24.sp, color = Color.Black)
|
||||
Text(text = price.toString() + " ₽", fontSize = 16.sp, color = Color.Black)
|
||||
|
||||
item{
|
||||
Box(
|
||||
modifier = Modifier.padding(bottom = 10.dp).fillMaxWidth(),
|
||||
contentAlignment = Alignment.Center
|
||||
){
|
||||
TextNice(name)
|
||||
Button(
|
||||
onClick = { onClickAction },
|
||||
colors = ButtonDefaults.buttonColors(
|
||||
containerColor = Color.Transparent,
|
||||
contentColor = myColor3
|
||||
),
|
||||
contentPadding = PaddingValues(0.dp),
|
||||
modifier = Modifier.size(50.dp).padding(top = 10.dp)
|
||||
|
||||
) {
|
||||
Image(
|
||||
painter = painterResource(id = R.drawable.delete),
|
||||
contentDescription = null,
|
||||
modifier = Modifier.size(50.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
item {
|
||||
Image(
|
||||
painter = painterResource(id = imgId),
|
||||
contentDescription = null,
|
||||
modifier = Modifier
|
||||
.size(400.dp)
|
||||
.aspectRatio(1f)
|
||||
)
|
||||
@Composable
|
||||
fun createProductPage(
|
||||
name: String,
|
||||
info: String,
|
||||
price: Int,
|
||||
@DrawableRes imgId: Int,
|
||||
onClickAction: () -> Unit
|
||||
) {
|
||||
LazyColumn(modifier = Modifier.fillMaxSize().padding(10.dp)) {
|
||||
|
||||
item {
|
||||
Box(
|
||||
modifier = Modifier.padding(bottom = 10.dp).fillMaxWidth(),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
TextNice(name)
|
||||
}
|
||||
}
|
||||
|
||||
item {
|
||||
Image(
|
||||
painter = painterResource(id = imgId),
|
||||
contentDescription = null,
|
||||
modifier = Modifier
|
||||
.size(400.dp)
|
||||
.aspectRatio(1f)
|
||||
)
|
||||
}
|
||||
|
||||
item { TextNice("Характеристики: ") }
|
||||
item { Text(info) }
|
||||
item { ButtonNice("Добавить в корзину", myColor4, onClickAction) }
|
||||
}
|
||||
|
||||
item{TextNice("Характеристики: ")}
|
||||
item{Text(info) }
|
||||
item{ButtonNice("Добавить в корзину", myColor4, onClickAction )}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user