From c39dc24599e6826741ab59171036079ab221c034 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9A=D0=B0=D1=88=D0=B8=D0=BD=20=D0=9C=D0=B0=D0=BA=D1=81?= =?UTF-8?q?=D0=B8=D0=BC?= Date: Fri, 27 Oct 2023 01:57:31 +0400 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D1=87=D1=82=D0=B8=20=D0=B4=D0=BE?= =?UTF-8?q?=20=D0=BA=D0=BE=D0=BD=D1=86=D0=B0=20=D0=BA=D1=80=D0=B0=D1=81?= =?UTF-8?q?=D0=B8=D0=B2=D1=83=D1=8E=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA=D1=83?= =?UTF-8?q?=20=D0=BF=D0=BE=D0=B4=D1=80=D0=BE=D0=B1=D0=BD=D0=B5=D0=B5=20?= =?UTF-8?q?=D1=81=D0=B4=D0=B5=D0=BB=D0=B0=D0=BB,=20=D0=BE=D1=81=D1=82?= =?UTF-8?q?=D0=B0=D0=BB=D0=BE=D1=81=D1=8C=20=D0=BA=D1=81=D1=82=D0=B0=D1=82?= =?UTF-8?q?=D0=B8=20=D1=81=D0=BF=D0=B0=D1=82=D1=8C=204=20=D1=87=D0=B0?= =?UTF-8?q?=D1=81=D0=B0,=20=D0=BD=D0=B0=D0=B4=D0=B5=D1=8E=D1=81=D1=8C,=20?= =?UTF-8?q?=D0=BC=D0=B0=D1=88=D0=B8=D0=BD=D0=B0=20=D0=B7=D0=B0=D0=B2=D1=82?= =?UTF-8?q?=D1=80=D0=B0=20=D0=B7=D0=B0=D0=B2=D0=B5=D0=B4=D0=B5=D1=82=D1=81?= =?UTF-8?q?=D1=8F...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../labwork/button_navigation/Screens.kt | 4 +- .../com/example/labwork/pages/ListProduct.kt | 83 +++++++++++++++---- 2 files changed, 71 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/com/example/labwork/button_navigation/Screens.kt b/app/src/main/java/com/example/labwork/button_navigation/Screens.kt index fac168c..2f8e210 100644 --- a/app/src/main/java/com/example/labwork/button_navigation/Screens.kt +++ b/app/src/main/java/com/example/labwork/button_navigation/Screens.kt @@ -63,8 +63,8 @@ fun ScreenListProduct() { ) { 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,"Золотая рыбка","Сказка"), diff --git a/app/src/main/java/com/example/labwork/pages/ListProduct.kt b/app/src/main/java/com/example/labwork/pages/ListProduct.kt index b1e5cd7..cae2868 100644 --- a/app/src/main/java/com/example/labwork/pages/ListProduct.kt +++ b/app/src/main/java/com/example/labwork/pages/ListProduct.kt @@ -1,5 +1,11 @@ package com.example.labwork.pages +import androidx.compose.animation.AnimatedVisibility +import androidx.compose.animation.core.animateFloatAsState +import androidx.compose.animation.expandIn +import androidx.compose.animation.fadeIn +import androidx.compose.animation.fadeOut +import androidx.compose.animation.shrinkOut import androidx.compose.foundation.Image import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column @@ -9,39 +15,88 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.size import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.RoundedCornerShape +import androidx.compose.material.Button import androidx.compose.material.Card import androidx.compose.material.Text import androidx.compose.runtime.Composable +import androidx.compose.runtime.mutableStateListOf +import androidx.compose.runtime.remember +import androidx.compose.runtime.getValue +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.setValue import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.alpha import androidx.compose.ui.draw.clip +import androidx.compose.ui.draw.scale import androidx.compose.ui.draw.shadow import androidx.compose.ui.layout.ContentScale import androidx.compose.ui.res.painterResource +import androidx.compose.ui.semantics.Role.Companion.Button +import androidx.compose.ui.text.font.FontWeight +import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.unit.dp +import androidx.compose.ui.unit.sp import com.example.labwork.R + @Composable fun ListProduct(item: ItemProduct) { - Card(modifier = Modifier - .fillMaxWidth() - .padding(10.dp), + var isFullAbout by remember { mutableStateOf(false) } + val scale by animateFloatAsState(if (isFullAbout) 1f else 0f) + + Card( + modifier = Modifier + .fillMaxWidth() + .padding(10.dp), shape = RoundedCornerShape(15.dp), - elevation = 5.dp + elevation = 5.dp ) { Box { Row(verticalAlignment = Alignment.CenterVertically) { - Image(painter = painterResource(id = item.imageId), - contentDescription = "book", - contentScale = ContentScale.Crop, - modifier = Modifier - .padding(10.dp) - .size(86.dp) - .shadow(2.dp) - ) Column { - Text(text = item.name) - Text(text = item.about) + Image( + painter = painterResource(id = item.imageId), + contentDescription = "book", + contentScale = ContentScale.Crop, + modifier = Modifier + .padding(10.dp) + .size(94.dp) + .shadow(2.dp) + ) + Button( + modifier = Modifier + .padding(9.dp) + .size(height = 32.dp, width = 95.dp), + onClick = { + isFullAbout = !isFullAbout + }, + shape = RoundedCornerShape(15.dp) + ) { + Text("Подробнее", fontSize = 10.sp) + } + } + Column { + Text(text = item.name, + fontSize = if (isFullAbout) 18.sp else 14.sp, + fontWeight = if (isFullAbout) FontWeight.Bold else FontWeight.Normal, + textAlign = TextAlign.Center, + modifier = Modifier.fillMaxWidth().padding(top = 8.dp) + ) + AnimatedVisibility( + visible = isFullAbout, + enter = fadeIn() + expandIn(), + exit = fadeOut() + shrinkOut(), + modifier = Modifier.scale(scale) + ) { + Text( + text = item.about, + maxLines = 10, + fontSize = 14.sp, + textAlign = TextAlign.Center, + modifier = Modifier.fillMaxWidth().padding(top = 8.dp) + ) + } } } }