Разработан RC карточки запроса по автору
Этот коммит содержится в:
родитель
120bcafabc
Коммит
0a5f4dad4f
@ -0,0 +1,5 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||
|
||||
<path android:fillColor="#ffffff" android:pathData="M9,16.17L5.53,12.7c-0.39,-0.39 -1.02,-0.39 -1.41,0 -0.39,0.39 -0.39,1.02 0,1.41l4.18,4.18c0.39,0.39 1.02,0.39 1.41,0L20.29,7.71c0.39,-0.39 0.39,-1.02 0,-1.41 -0.39,-0.39 -1.02,-0.39 -1.41,0L9,16.17z"/>
|
||||
|
||||
</vector>
|
@ -0,0 +1,5 @@
|
||||
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:height="24dp" android:tint="#000000" android:viewportHeight="24" android:viewportWidth="24" android:width="24dp">
|
||||
|
||||
<path android:fillColor="#ffffff" android:pathData="M18.3,5.71c-0.39,-0.39 -1.02,-0.39 -1.41,0L12,10.59 7.11,5.7c-0.39,-0.39 -1.02,-0.39 -1.41,0 -0.39,0.39 -0.39,1.02 0,1.41L10.59,12 5.7,16.89c-0.39,0.39 -0.39,1.02 0,1.41 0.39,0.39 1.02,0.39 1.41,0L12,13.41l4.89,4.89c0.39,0.39 1.02,0.39 1.41,0 0.39,-0.39 0.39,-1.02 0,-1.41L13.41,12l4.89,-4.89c0.38,-0.38 0.38,-1.02 0,-1.4z"/>
|
||||
|
||||
</vector>
|
@ -1,84 +0,0 @@
|
||||
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<Boolean>,
|
||||
) {
|
||||
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 = "Кнопки",
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,172 @@
|
||||
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.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.IntrinsicSize
|
||||
import androidx.compose.foundation.layout.PaddingValues
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material3.Button
|
||||
import androidx.compose.material3.ButtonDefaults
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.CardColors
|
||||
import androidx.compose.material3.CardDefaults
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Icon
|
||||
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.graphics.Color
|
||||
import androidx.compose.ui.graphics.RectangleShape
|
||||
import androidx.compose.ui.graphics.painter.Painter
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.text.style.TextOverflow
|
||||
import androidx.compose.ui.unit.dp
|
||||
import bee_app_frontend.composeapp.generated.resources.Res
|
||||
import bee_app_frontend.composeapp.generated.resources.round_check_24
|
||||
import bee_app_frontend.composeapp.generated.resources.round_close_24
|
||||
import org.jetbrains.compose.resources.painterResource
|
||||
import ru.csasq.beeapp.ui.screens.AuthorRequest
|
||||
|
||||
@Composable
|
||||
fun AuthorRequestButton(
|
||||
authorRequest: AuthorRequest,
|
||||
spoilerState: MutableState<AuthorRequest?>,
|
||||
onAccept: () -> Unit,
|
||||
onDecline: () -> Unit,
|
||||
) {
|
||||
val backgroundColor = animateColorAsState(
|
||||
targetValue = if (spoilerState.value == authorRequest) MaterialTheme.colorScheme.primary.copy(alpha = 0.12f) else Color.Transparent,
|
||||
)
|
||||
val horizontalPadding = animateDpAsState(
|
||||
targetValue = if (spoilerState.value == authorRequest) 16.dp else 0.dp,
|
||||
)
|
||||
val shapeState = animateDpAsState(
|
||||
targetValue = if (spoilerState.value == authorRequest) 28.0.dp else 0.0.dp,
|
||||
)
|
||||
val cardColors = CardDefaults.cardColors()
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.padding(
|
||||
horizontal = horizontalPadding.value,
|
||||
)
|
||||
.fillMaxWidth(),
|
||||
onClick = {
|
||||
spoilerState.value = when (spoilerState.value) {
|
||||
authorRequest -> null
|
||||
else -> authorRequest
|
||||
}
|
||||
},
|
||||
shape = RoundedCornerShape(shapeState.value),
|
||||
colors = CardColors(
|
||||
containerColor = backgroundColor.value,
|
||||
contentColor = cardColors.contentColor,
|
||||
disabledContainerColor = cardColors.disabledContainerColor,
|
||||
disabledContentColor = cardColors.disabledContentColor,
|
||||
),
|
||||
) {
|
||||
Column {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(16.dp),
|
||||
) {
|
||||
Text(
|
||||
text = authorRequest.title,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
maxLines = 1,
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
)
|
||||
Spacer(
|
||||
modifier = Modifier.height(4.dp),
|
||||
)
|
||||
Text(
|
||||
text = authorRequest.description,
|
||||
overflow = TextOverflow.Ellipsis,
|
||||
maxLines = 3,
|
||||
style = MaterialTheme.typography.bodyMedium,
|
||||
)
|
||||
}
|
||||
AnimatedVisibility(
|
||||
visible = spoilerState.value == authorRequest,
|
||||
) {
|
||||
HorizontalDivider()
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.height(IntrinsicSize.Min),
|
||||
horizontalArrangement = Arrangement.SpaceBetween,
|
||||
) {
|
||||
AuthorRequestButton(
|
||||
modifier = Modifier
|
||||
.weight(
|
||||
weight = 1f,
|
||||
fill = true,
|
||||
),
|
||||
title = "Принять",
|
||||
painter = painterResource(Res.drawable.round_check_24),
|
||||
onClick = onAccept,
|
||||
)
|
||||
AuthorRequestButton(
|
||||
modifier = Modifier
|
||||
.weight(
|
||||
weight = 1f,
|
||||
fill = true,
|
||||
),
|
||||
title = "Отклонить",
|
||||
painter = painterResource(Res.drawable.round_close_24),
|
||||
onClick = onDecline,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun AuthorRequestButton(
|
||||
modifier: Modifier = Modifier,
|
||||
title: String,
|
||||
painter: Painter,
|
||||
onClick: () -> Unit,
|
||||
) {
|
||||
Button(
|
||||
onClick = onClick,
|
||||
modifier = modifier
|
||||
.fillMaxHeight(),
|
||||
shape = RectangleShape,
|
||||
colors = ButtonDefaults.textButtonColors(),
|
||||
contentPadding = PaddingValues(),
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.padding(12.dp)
|
||||
.fillMaxHeight(),
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
) {
|
||||
Icon(
|
||||
painter = painter,
|
||||
contentDescription = null,
|
||||
)
|
||||
Spacer(
|
||||
modifier = Modifier
|
||||
.height(4.dp),
|
||||
)
|
||||
Text(
|
||||
text = title,
|
||||
textAlign = TextAlign.Center,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
@ -24,10 +24,7 @@ fun UserButton(
|
||||
.clickable(
|
||||
onClick = onClick,
|
||||
)
|
||||
.padding(
|
||||
horizontal = 16.dp,
|
||||
vertical = 16.dp,
|
||||
),
|
||||
.padding(16.dp),
|
||||
) {
|
||||
Text(
|
||||
text = title,
|
||||
|
@ -6,11 +6,18 @@ import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.navigation.NavController
|
||||
import ru.csasq.beeapp.ui.components.AuthorRequestButton
|
||||
|
||||
data class AuthorRequest(
|
||||
val id: Int,
|
||||
val title: String,
|
||||
val description: String,
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun AuthorRequestsScreen(
|
||||
@ -27,12 +34,26 @@ fun AuthorRequestsScreen(
|
||||
state = rememberScrollState(),
|
||||
),
|
||||
) {
|
||||
Text (
|
||||
text = "Здесь будет список обращений авторов",
|
||||
modifier = Modifier
|
||||
.padding(
|
||||
horizontal = 16.dp,
|
||||
val authorRequestList = mutableListOf<AuthorRequest>()
|
||||
val spoilerState = remember {
|
||||
mutableStateOf<AuthorRequest?>(null)
|
||||
}
|
||||
for (id in 1..25) {
|
||||
authorRequestList.add(
|
||||
AuthorRequest(
|
||||
id = id,
|
||||
title = "Заявляю о пропаже пчел",
|
||||
description = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
authorRequestList.forEach {
|
||||
AuthorRequestButton(
|
||||
authorRequest = it,
|
||||
spoilerState = spoilerState,
|
||||
onAccept = {},
|
||||
onDecline = {},
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
@ -7,11 +7,8 @@ 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
|
||||
@ -35,13 +32,6 @@ fun UsersScreen(
|
||||
caption = "Гавносос последней степени критенизма",
|
||||
onClick = {},
|
||||
)
|
||||
val tempState = remember {
|
||||
mutableStateOf(false)
|
||||
}
|
||||
AuthorRequestButton(
|
||||
title = "Заявляю о пропаже пчел",
|
||||
spoilerState = tempState,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче
Block a user