sprint-1 #1
261
libary/src/main/java/com/example/libary/Cards.kt
Normal file
261
libary/src/main/java/com/example/libary/Cards.kt
Normal file
@ -0,0 +1,261 @@
|
|||||||
|
package com.example.libary
|
||||||
|
|
||||||
|
import androidx.compose.foundation.BorderStroke
|
||||||
|
import androidx.compose.foundation.Image
|
||||||
|
import androidx.compose.foundation.background
|
||||||
|
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.ColumnScope
|
||||||
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.Spacer
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.height
|
||||||
|
import androidx.compose.foundation.layout.padding
|
||||||
|
import androidx.compose.foundation.layout.width
|
||||||
|
import androidx.compose.foundation.shape.AbsoluteRoundedCornerShape
|
||||||
|
import androidx.compose.material3.Card
|
||||||
|
import androidx.compose.material3.CardDefaults
|
||||||
|
import androidx.compose.material3.Text
|
||||||
|
import androidx.compose.material3.VerticalDivider
|
||||||
|
import androidx.compose.runtime.Composable
|
||||||
|
import androidx.compose.ui.Alignment
|
||||||
|
import androidx.compose.ui.Modifier
|
||||||
|
import androidx.compose.ui.draw.clip
|
||||||
|
import androidx.compose.ui.draw.shadow
|
||||||
|
import androidx.compose.ui.graphics.Color
|
||||||
|
import androidx.compose.ui.res.painterResource
|
||||||
|
import androidx.compose.ui.text.font.FontWeight
|
||||||
|
import androidx.compose.ui.tooling.preview.Preview
|
||||||
|
import androidx.compose.ui.unit.dp
|
||||||
|
import androidx.compose.ui.unit.sp
|
||||||
|
import com.example.libary.theme.DividerColor
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun BaseCard(
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
content: @Composable ColumnScope.() -> Unit
|
||||||
|
) {
|
||||||
|
Card(
|
||||||
|
modifier = modifier
|
||||||
|
.shadow(10.dp, AbsoluteRoundedCornerShape(12.dp), ambientColor = Color(0x99E4E8F5), spotColor = Color(
|
||||||
|
0x99E4E8F5
|
||||||
|
)
|
||||||
|
),
|
||||||
|
shape = AbsoluteRoundedCornerShape(12.dp),
|
||||||
|
colors = CardDefaults.cardColors(
|
||||||
|
containerColor = Color.White
|
||||||
|
),
|
||||||
|
border = BorderStroke(1.dp, DividerColor)
|
||||||
|
) {
|
||||||
|
Column(
|
||||||
|
modifier = Modifier.padding(16.dp)
|
||||||
|
) {
|
||||||
|
content()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun PrimaryCard(
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
name: String,
|
||||||
|
category: String,
|
||||||
|
price: String,
|
||||||
|
isAdd: Boolean,
|
||||||
|
onClick: () -> Unit
|
||||||
|
) {
|
||||||
|
BaseCard(
|
||||||
|
modifier = modifier
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = name,
|
||||||
|
color = Color.Black,
|
||||||
|
fontWeight = FontWeight.W500,
|
||||||
|
fontSize = 16.sp
|
||||||
|
)
|
||||||
|
|
||||||
|
Spacer(Modifier.height(16.dp))
|
||||||
|
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
Column {
|
||||||
|
Text(
|
||||||
|
text = category,
|
||||||
|
color = Color(0xFF939396),
|
||||||
|
fontWeight = FontWeight.W600,
|
||||||
|
fontSize = 14.sp
|
||||||
|
)
|
||||||
|
|
||||||
|
Spacer(Modifier.height(4.dp))
|
||||||
|
|
||||||
|
Text(
|
||||||
|
text = "$price ₽",
|
||||||
|
color = Color.Black,
|
||||||
|
fontWeight = FontWeight.W600,
|
||||||
|
fontSize = 17.sp
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
SmallButton(
|
||||||
|
state = if (isAdd) SmallButtonState.Property else SmallButtonState.Secondary,
|
||||||
|
text = if (isAdd) "Добавить" else "Убрать",
|
||||||
|
onClick = onClick
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun CartCard(
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
name: String,
|
||||||
|
price: String,
|
||||||
|
count: String,
|
||||||
|
onClose: () -> Unit = {},
|
||||||
|
onPlus: () -> Unit = {},
|
||||||
|
onMinus: () -> Unit = {}
|
||||||
|
) {
|
||||||
|
BaseCard(
|
||||||
|
modifier = modifier
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = name,
|
||||||
|
fontWeight = FontWeight.W500,
|
||||||
|
fontSize = 16.sp,
|
||||||
|
color = Color.Black,
|
||||||
|
modifier = Modifier.weight(1.0f)
|
||||||
|
)
|
||||||
|
|
||||||
|
Image(
|
||||||
|
painter = painterResource(R.drawable.delete),
|
||||||
|
contentDescription = null,
|
||||||
|
modifier = Modifier.clickable {
|
||||||
|
onClose()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
Spacer(Modifier.height(34.dp))
|
||||||
|
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = "$price ₽",
|
||||||
|
color = Color.Black,
|
||||||
|
fontWeight = FontWeight.W500,
|
||||||
|
fontSize = 17.sp
|
||||||
|
)
|
||||||
|
|
||||||
|
Row(
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = "$count штук",
|
||||||
|
fontWeight = FontWeight.W400,
|
||||||
|
fontSize = 15.sp,
|
||||||
|
color = Color.Black
|
||||||
|
)
|
||||||
|
|
||||||
|
Spacer(Modifier.width(42.dp))
|
||||||
|
|
||||||
|
Box(
|
||||||
|
modifier = Modifier
|
||||||
|
.width(64.dp)
|
||||||
|
.height(32.dp)
|
||||||
|
.background(Color(0xFFF5F5F9), AbsoluteRoundedCornerShape(8.dp))
|
||||||
|
.clip(AbsoluteRoundedCornerShape(8.dp)),
|
||||||
|
contentAlignment = Alignment.Center
|
||||||
|
) {
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.padding(6.dp)
|
||||||
|
) {
|
||||||
|
Image(
|
||||||
|
painter = painterResource(R.drawable.minus),
|
||||||
|
contentDescription = null,
|
||||||
|
modifier = Modifier.clickable {
|
||||||
|
onMinus()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
Spacer(Modifier.width(6.dp))
|
||||||
|
|
||||||
|
VerticalDivider()
|
||||||
|
|
||||||
|
Spacer(Modifier.width(6.dp))
|
||||||
|
|
||||||
|
Image(
|
||||||
|
painter = painterResource(R.drawable.plus),
|
||||||
|
contentDescription = null,
|
||||||
|
modifier = Modifier.clickable {
|
||||||
|
onPlus()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun ProjectCard(
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
name: String,
|
||||||
|
date: String,
|
||||||
|
open: () -> Unit = {}
|
||||||
|
) {
|
||||||
|
BaseCard(
|
||||||
|
modifier = modifier,
|
||||||
|
content = {
|
||||||
|
Text(
|
||||||
|
text = name,
|
||||||
|
fontWeight = FontWeight.W500,
|
||||||
|
fontSize = 16.sp,
|
||||||
|
color = Color.Black
|
||||||
|
)
|
||||||
|
|
||||||
|
Spacer(Modifier.height(44.dp))
|
||||||
|
|
||||||
|
Row(
|
||||||
|
modifier = Modifier.fillMaxWidth(),
|
||||||
|
horizontalArrangement = Arrangement.SpaceBetween,
|
||||||
|
verticalAlignment = Alignment.CenterVertically
|
||||||
|
) {
|
||||||
|
Text(
|
||||||
|
text = date,
|
||||||
|
color = Color(0xFF939396),
|
||||||
|
fontWeight = FontWeight.W600,
|
||||||
|
fontSize = 14.sp
|
||||||
|
)
|
||||||
|
|
||||||
|
SmallButton(
|
||||||
|
state = SmallButtonState.Property,
|
||||||
|
text = "Открыть",
|
||||||
|
onClick = open
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Preview
|
||||||
|
@Composable
|
||||||
|
private fun PrimaryCardPrev() {
|
||||||
|
ProjectCard(
|
||||||
|
modifier = Modifier.padding(horizontal = 20.dp),
|
||||||
|
name = "Рубашка Воскресенье для машинного вязания",
|
||||||
|
date = "Прошло 2 дня"
|
||||||
|
)
|
||||||
|
}
|
@ -21,4 +21,5 @@ val InputStrokeColor = Color(0xFFE6E6E6)
|
|||||||
val InputIconColor = Color(0xFFBFC7D1)
|
val InputIconColor = Color(0xFFBFC7D1)
|
||||||
val PlaceholderColor = Color(0xFF98989A)
|
val PlaceholderColor = Color(0xFF98989A)
|
||||||
val DescriptionColor = Color(0xFF8787A1)
|
val DescriptionColor = Color(0xFF8787A1)
|
||||||
val CardStrokeColor = Color(0xFFF2F2F2)
|
val CardStrokeColor = Color(0xFFF2F2F2)
|
||||||
|
val DividerColor = Color(0xFFF4F4F4)
|
20
libary/src/main/res/drawable/delete.xml
Normal file
20
libary/src/main/res/drawable/delete.xml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="20dp"
|
||||||
|
android:height="20dp"
|
||||||
|
android:viewportWidth="20"
|
||||||
|
android:viewportHeight="20">
|
||||||
|
<path
|
||||||
|
android:pathData="M15,5L5,15"
|
||||||
|
android:strokeLineJoin="round"
|
||||||
|
android:strokeWidth="2"
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:strokeColor="#7E7E9A"
|
||||||
|
android:strokeLineCap="round"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M5,5L15,15"
|
||||||
|
android:strokeLineJoin="round"
|
||||||
|
android:strokeWidth="2"
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:strokeColor="#7E7E9A"
|
||||||
|
android:strokeLineCap="round"/>
|
||||||
|
</vector>
|
13
libary/src/main/res/drawable/minus.xml
Normal file
13
libary/src/main/res/drawable/minus.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="20dp"
|
||||||
|
android:height="20dp"
|
||||||
|
android:viewportWidth="20"
|
||||||
|
android:viewportHeight="20">
|
||||||
|
<path
|
||||||
|
android:pathData="M4.167,10H15.833"
|
||||||
|
android:strokeLineJoin="round"
|
||||||
|
android:strokeWidth="2"
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:strokeColor="#B8C1CC"
|
||||||
|
android:strokeLineCap="round"/>
|
||||||
|
</vector>
|
20
libary/src/main/res/drawable/plus.xml
Normal file
20
libary/src/main/res/drawable/plus.xml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="20dp"
|
||||||
|
android:height="20dp"
|
||||||
|
android:viewportWidth="20"
|
||||||
|
android:viewportHeight="20">
|
||||||
|
<path
|
||||||
|
android:pathData="M10,4.167V15.833"
|
||||||
|
android:strokeLineJoin="round"
|
||||||
|
android:strokeWidth="2"
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:strokeColor="#939396"
|
||||||
|
android:strokeLineCap="round"/>
|
||||||
|
<path
|
||||||
|
android:pathData="M4.167,10H15.833"
|
||||||
|
android:strokeLineJoin="round"
|
||||||
|
android:strokeWidth="2"
|
||||||
|
android:fillColor="#00000000"
|
||||||
|
android:strokeColor="#939396"
|
||||||
|
android:strokeLineCap="round"/>
|
||||||
|
</vector>
|
Loading…
x
Reference in New Issue
Block a user