Сделал что то типо нормально списка

This commit is contained in:
Кашин Максим 2023-10-27 00:44:20 +04:00
parent d1ca80dc9c
commit f151ccd599
3 changed files with 37 additions and 11 deletions

View File

@ -6,6 +6,7 @@ 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.fillMaxHeight
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.offset
import androidx.compose.foundation.layout.padding
@ -13,6 +14,8 @@ import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.requiredSize
import androidx.compose.foundation.layout.requiredWidth
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.material.Text
import androidx.compose.runtime.Composable
@ -29,6 +32,7 @@ import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.em
import androidx.compose.ui.unit.sp
import com.example.labwork.R
import com.example.labwork.pages.ItemProduct
import com.example.labwork.pages.ListProduct
@Composable
@ -54,13 +58,28 @@ fun ScreenProfile() {
@Composable
fun ScreenListProduct() {
Column {
ListProduct("Максим", "Тест")
ListProduct("Максим", "Тест")
ListProduct("Максим", "Тест")
ListProduct("Максим", "Тест")
ListProduct("Максим", "Тест")
ListProduct("Максим", "Тест")
LazyColumn(
modifier = Modifier.fillMaxHeight()
) {
itemsIndexed(
listOf(
ItemProduct(R.drawable.baseline_menu_book,"Золотая рыбка","Сказка"),
ItemProduct(R.drawable.baseline_menu_book,"Золотая рыбка","Сказка"),
ItemProduct(R.drawable.baseline_menu_book,"Золотая рыбка","Сказка"),
ItemProduct(R.drawable.baseline_menu_book,"Золотая рыбка","Сказка"),
ItemProduct(R.drawable.baseline_menu_book,"Золотая рыбка","Сказка"),
ItemProduct(R.drawable.baseline_menu_book,"Золотая рыбка","Сказка"),
ItemProduct(R.drawable.baseline_menu_book,"Золотая рыбка","Сказка"),
ItemProduct(R.drawable.baseline_menu_book,"Золотая рыбка","Сказка"),
ItemProduct(R.drawable.baseline_menu_book,"Золотая рыбка","Сказка"),
ItemProduct(R.drawable.baseline_menu_book,"Золотая рыбка","Сказка"),
ItemProduct(R.drawable.baseline_menu_book,"Золотая рыбка","Сказка")
)
)
{
_, item ->
ListProduct(item = item)
}
}
}

View File

@ -0,0 +1,7 @@
package com.example.labwork.pages
data class ItemProduct(
val imageId: Int,
val name: String,
val about: String
)

View File

@ -22,7 +22,7 @@ import androidx.compose.ui.unit.dp
import com.example.labwork.R
@Composable
fun ListProduct(name: String, about: String) {
fun ListProduct(item: ItemProduct) {
Card(modifier = Modifier
.fillMaxWidth()
.padding(10.dp),
@ -31,7 +31,7 @@ fun ListProduct(name: String, about: String) {
) {
Box {
Row(verticalAlignment = Alignment.CenterVertically) {
Image(painter = painterResource(id = R.drawable.baseline_menu_book),
Image(painter = painterResource(id = item.imageId),
contentDescription = "book",
contentScale = ContentScale.Crop,
modifier = Modifier
@ -40,8 +40,8 @@ fun ListProduct(name: String, about: String) {
.shadow(2.dp)
)
Column {
Text(text = name)
Text(text = about)
Text(text = item.name)
Text(text = item.about)
}
}
}