From 120bcafabcd6b9271543f5e501754713f1dec46f Mon Sep 17 00:00:00 2001 From: csasq Date: Thu, 12 Dec 2024 17:50:56 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B0=D0=B7=D1=80=D0=B0=D0=B1=D0=BE?= =?UTF-8?q?=D1=82=D0=B0=D0=BD=D0=B0=20=D0=BF=D1=80=D0=B5=D0=B4=D0=B2=D0=B0?= =?UTF-8?q?=D1=80=D0=B8=D1=82=D0=B5=D0=BB=D1=8C=D0=BD=D0=B0=D1=8F=20=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=D1=81=D0=B8=D1=8F=20=D0=BA=D0=B0=D1=80=D1=82=D0=BE?= =?UTF-8?q?=D1=87=D0=BA=D0=B8=20=D0=B7=D0=B0=D0=BF=D1=80=D0=BE=D1=81=D0=B0?= =?UTF-8?q?=20=D0=BF=D0=BE=20=D0=B0=D0=B2=D1=82=D0=BE=D1=80=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/components/AuthorRequestButton.kt | 84 +++++++++++++++++++ .../ru/csasq/beeapp/ui/screens/UsersScreen.kt | 10 +++ 2 files changed, 94 insertions(+) create mode 100644 composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/components/AuthorRequestButton.kt diff --git a/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/components/AuthorRequestButton.kt b/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/components/AuthorRequestButton.kt new file mode 100644 index 0000000..0f04ac8 --- /dev/null +++ b/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/components/AuthorRequestButton.kt @@ -0,0 +1,84 @@ +package ru.csasq.beeapp.ui.components + +import androidx.compose.animation.AnimatedVisibility +import androidx.compose.animation.animateColorAsState +import androidx.compose.animation.core.animateDpAsState +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.IntrinsicSize +import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.fillMaxWidth +import androidx.compose.foundation.layout.height +import androidx.compose.foundation.layout.padding +import androidx.compose.material3.CardDefaults +import androidx.compose.material3.HorizontalDivider +import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text +import androidx.compose.runtime.Composable +import androidx.compose.runtime.MutableState +import androidx.compose.ui.Alignment +import androidx.compose.ui.Modifier +import androidx.compose.ui.draw.clip +import androidx.compose.ui.graphics.Color +import androidx.compose.ui.unit.dp + +@Composable +fun AuthorRequestButton( + title: String, + spoilerState: MutableState, +) { + val backgroundColor = animateColorAsState( + targetValue = if (spoilerState.value) MaterialTheme.colorScheme.primary.copy(alpha = 0.12f) else Color.Transparent, + ) + val horizontalPadding = animateDpAsState( + targetValue = if (spoilerState.value) 16.dp else 0.dp, + ) + val cardColors = CardDefaults.cardColors() + Box( + modifier = Modifier + .clip(MaterialTheme.shapes.extraLarge) + .padding( + horizontal = horizontalPadding.value, + ) + .fillMaxWidth() + .clickable { + spoilerState.value = !spoilerState.value + }, +// colors = CardColors( +// containerColor = backgroundColor.value, +// contentColor = cardColors.contentColor, +// disabledContainerColor = cardColors.disabledContainerColor, +// disabledContentColor = cardColors.disabledContentColor, +// ), + ) { + Column { + Row( + modifier = Modifier + .padding(16.dp) + .fillMaxWidth(), + verticalAlignment = Alignment.CenterVertically, + ) { + Text( + text = title, + ) + } + AnimatedVisibility( + visible = spoilerState.value, + ) { + HorizontalDivider() + Row( + modifier = Modifier + .fillMaxWidth() + .height(IntrinsicSize.Min), + horizontalArrangement = Arrangement.SpaceBetween, + ) { + Text( + text = "Кнопки", + ) + } + } + } + } +} \ No newline at end of file diff --git a/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/screens/UsersScreen.kt b/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/screens/UsersScreen.kt index c9d57b7..c7749bf 100644 --- a/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/screens/UsersScreen.kt +++ b/composeApp/src/commonMain/kotlin/ru/csasq/beeapp/ui/screens/UsersScreen.kt @@ -7,8 +7,11 @@ import androidx.compose.foundation.layout.padding import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.verticalScroll import androidx.compose.runtime.Composable +import androidx.compose.runtime.mutableStateOf +import androidx.compose.runtime.remember import androidx.compose.ui.Modifier import androidx.navigation.NavController +import ru.csasq.beeapp.ui.components.AuthorRequestButton import ru.csasq.beeapp.ui.components.UserButton @Composable @@ -32,6 +35,13 @@ fun UsersScreen( caption = "Гавносос последней степени критенизма", onClick = {}, ) + val tempState = remember { + mutableStateOf(false) + } + AuthorRequestButton( + title = "Заявляю о пропаже пчел", + spoilerState = tempState, + ) } } } \ No newline at end of file