sprint-1 #1

Merged
user10 merged 20 commits from sprint-1 into main 2025-05-26 14:29:49 +00:00
4 changed files with 336 additions and 0 deletions
Showing only changes of commit d4d210e06f - Show all commits

View File

@ -0,0 +1,279 @@
package com.example.libary
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.Image
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.PaddingValues
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.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.AbsoluteRoundedCornerShape
import androidx.compose.material3.Button
import androidx.compose.material3.ButtonDefaults
import androidx.compose.material3.Icon
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import com.example.libary.theme.AccentColor
import com.example.libary.theme.BlackColor
import com.example.libary.theme.WhiteColor
enum class BigButtonState(
val containerColor: Color,
val textColor: Color,
val enabled: Boolean = true,
val border: BorderStroke? = null
) {
Property(
containerColor = AccentColor,
textColor = Color.White,
),
Inactive(
containerColor = Color(0xFFC9D4FB),
textColor = WhiteColor,
enabled = false
),
Secondary(
containerColor = Color.White,
textColor = AccentColor,
border = BorderStroke(1.dp, AccentColor)
),
Tetriary(
containerColor = Color(0xFFF5F5F9),
textColor = BlackColor,
)
}
@Composable
fun BigButton(
state: BigButtonState,
modifier: Modifier = Modifier,
onClick: () -> Unit = {},
text: String = ""
) {
Button(
onClick = {
if (state.enabled) onClick()
},
modifier = modifier
.width(335.dp)
.height(56.dp),
border = state.border,
shape = AbsoluteRoundedCornerShape(10.dp),
colors = ButtonDefaults.buttonColors(
containerColor = state.containerColor
),
contentPadding = PaddingValues(0.dp)
) {
Text(
text = text,
color = state.textColor,
fontWeight = FontWeight.W600,
fontSize = 17.sp
)
}
}
enum class SmallButtonState(
val containerColor: Color,
val textColor: Color,
val enabled: Boolean = true,
val border: BorderStroke? = null
) {
Property(
containerColor = AccentColor,
textColor = Color.White,
),
Inactive(
containerColor = Color(0xFFC9D4FB),
textColor = WhiteColor,
enabled = false
),
Secondary(
containerColor = Color.White,
textColor = AccentColor,
border = BorderStroke(1.dp, AccentColor)
),
Tetriary(
containerColor = Color(0xFFF5F5F9),
textColor = BlackColor,
)
}
@Composable
fun SmallButton(
state: SmallButtonState,
modifier: Modifier = Modifier,
onClick: () -> Unit = {},
text: String = ""
) {
Button(
onClick = {
if (state.enabled) onClick()
},
modifier = modifier
.width(96.dp)
.height(40.dp),
border = state.border,
shape = AbsoluteRoundedCornerShape(10.dp),
colors = ButtonDefaults.buttonColors(
containerColor = state.containerColor
),
contentPadding = PaddingValues(0.dp)
) {
Text(
text = text,
color = state.textColor,
maxLines = 1,
fontWeight = FontWeight.W600,
fontSize = 14.sp,
overflow = TextOverflow.Ellipsis
)
}
}
@Composable
fun CartButton(
modifier: Modifier = Modifier,
onClick: () -> Unit = {},
price: String = ""
) {
Button(
onClick = onClick,
modifier = modifier
.width(335.dp)
.height(56.dp),
contentPadding = PaddingValues(0.dp),
colors = ButtonDefaults.buttonColors(
containerColor = AccentColor
),
shape = AbsoluteRoundedCornerShape(10.dp)
) {
Row(
modifier = Modifier
.fillMaxWidth()
.padding(16.dp),
horizontalArrangement = Arrangement.SpaceBetween,
verticalAlignment = Alignment.CenterVertically
) {
Row(
verticalAlignment = Alignment.CenterVertically
) {
Icon(
painter = painterResource(R.drawable.cart),
contentDescription = null
)
Spacer(Modifier.width(16.dp))
Text(
text = "В корзину",
fontWeight = FontWeight.W600,
fontSize = 17.sp,
color = WhiteColor
)
}
Text(
text = "$price",
fontWeight = FontWeight.W600,
fontSize = 17.sp,
color = WhiteColor
)
}
}
}
enum class LoginState(
val icon: Int,
val text: String
) {
VK(R.drawable.vk, "Войти с VK"),
Yandex(R.drawable.yandex, "Войти с Yandex")
}
@Composable
fun LoginButton(
modifier: Modifier = Modifier,
state: LoginState = LoginState.VK,
onClick: () -> Unit = {}
) {
Button(
onClick = onClick,
modifier = modifier
.width(335.dp)
.height(60.dp),
shape = AbsoluteRoundedCornerShape(10.dp),
border = BorderStroke(1.dp, Color(0xFFEBEBEB)),
colors = ButtonDefaults.buttonColors(
containerColor = Color.White
)
) {
Row(
verticalAlignment = Alignment.CenterVertically
) {
Image(
painter = painterResource(state.icon),
contentDescription = null,
modifier = Modifier.size(32.dp)
)
Spacer(Modifier.width(16.dp))
Text(
text = state.text,
color = Color.Black,
fontWeight = FontWeight.W500,
fontSize = 17.sp
)
}
}
}
enum class ChipButtonState(
val containerColor: Color,
val textColor: Color
) {
On(AccentColor, Color.White),
Off(Color(0xFFF5F5F9), Color(0xFF7E7E9A))
}
@Composable
fun ChipButton(
modifier: Modifier = Modifier,
onClick: () -> Unit = {},
state: ChipButtonState = ChipButtonState.On,
text: String = ""
) {
Button(
onClick = onClick,
modifier = modifier
.width(129.dp)
.height(48.dp),
shape = AbsoluteRoundedCornerShape(10.dp),
colors = ButtonDefaults.buttonColors(
containerColor = state.containerColor
),
contentPadding = PaddingValues(0.dp)
) {
Text(
text = text,
color = state.textColor,
maxLines = 1,
fontWeight = FontWeight.W600,
fontSize = 14.sp,
overflow = TextOverflow.Ellipsis
)
}
}

View File

@ -0,0 +1,31 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="20dp"
android:height="20dp"
android:viewportWidth="20"
android:viewportHeight="20">
<group>
<clip-path
android:pathData="M0,0h20v20h-20z"/>
<path
android:pathData="M7.5,18.333C7.96,18.333 8.333,17.96 8.333,17.5C8.333,17.04 7.96,16.667 7.5,16.667C7.04,16.667 6.667,17.04 6.667,17.5C6.667,17.96 7.04,18.333 7.5,18.333Z"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#ffffff"
android:strokeLineCap="round"/>
<path
android:pathData="M16.667,18.333C17.127,18.333 17.5,17.96 17.5,17.5C17.5,17.04 17.127,16.667 16.667,16.667C16.207,16.667 15.833,17.04 15.833,17.5C15.833,17.96 16.207,18.333 16.667,18.333Z"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#ffffff"
android:strokeLineCap="round"/>
<path
android:pathData="M0.833,0.833H4.167L6.4,11.992C6.476,12.375 6.685,12.72 6.99,12.965C7.294,13.211 7.676,13.341 8.067,13.333H16.167C16.558,13.341 16.939,13.211 17.244,12.965C17.549,12.72 17.757,12.375 17.833,11.992L19.167,5H5"
android:strokeLineJoin="round"
android:strokeWidth="2"
android:fillColor="#00000000"
android:strokeColor="#ffffff"
android:strokeLineCap="round"/>
</group>
</vector>

View File

@ -0,0 +1,17 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="33dp"
android:height="32dp"
android:viewportWidth="33"
android:viewportHeight="32">
<group>
<clip-path
android:pathData="M0.5,0h32v32h-32z"/>
<path
android:pathData="M0.5,0H32.5V32H0.5V0Z"
android:fillColor="#0077FF"/>
<path
android:pathData="M8.571,8.622C7.611,9.76 7.611,11.467 7.611,14.915V17.067C7.611,20.498 7.611,22.222 8.571,23.36C8.731,23.573 8.927,23.751 9.105,23.911C10.26,24.871 11.985,24.871 15.416,24.871H17.567C20.998,24.871 22.722,24.871 23.86,23.911C24.074,23.751 24.251,23.556 24.411,23.378C25.371,22.222 25.371,20.498 25.371,17.067V14.933C25.371,11.502 25.371,9.778 24.411,8.64C24.251,8.427 24.056,8.249 23.878,8.071C22.722,7.111 20.998,7.111 17.567,7.111H15.434C12.002,7.111 10.278,7.111 9.14,8.053C8.927,8.231 8.749,8.409 8.589,8.622H8.571ZM10.634,13.298C10.722,14.524 11.131,15.858 11.7,16.764C12.749,18.489 14.349,19.378 16.678,19.502L17.069,19.538V16.978L17.354,17.013C18.473,17.156 19.611,18.044 20.091,19.182L20.234,19.538H20.589C21.176,19.538 22.278,19.573 22.278,19.538C22.06,18.797 21.696,18.107 21.208,17.508C20.719,16.91 20.116,16.415 19.434,16.053L19.291,15.964L19.522,15.787C20.666,15.063 21.493,13.932 21.834,12.622V12.444H19.967L19.825,12.8C19.469,13.689 18.634,14.649 17.905,15.004C17.638,15.129 17.371,15.2 17.069,15.236V12.444H15.345V17.369L15.078,17.28C14.367,17.013 13.691,16.355 13.282,15.573C12.927,14.915 12.678,13.867 12.607,12.942L12.589,12.444H10.58L10.651,13.298H10.634Z"
android:fillColor="#ffffff"
android:fillType="evenOdd"/>
</group>
</vector>

View File

@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="33dp"
android:height="32dp"
android:viewportWidth="33"
android:viewportHeight="32">
<path
android:pathData="M6.17,0C3.029,0 0.5,2.529 0.5,5.67V26.33C0.5,29.471 3.029,32 6.17,32H21.376L32.5,16.004L21.376,0H6.17V0ZM14.685,5.842H18.298C18.52,5.842 18.647,5.923 18.647,6.114V26.026C18.647,26.162 18.583,26.243 18.393,26.243H16.428C16.302,26.243 16.207,26.134 16.207,26.053V18.681H14.621L10.216,26.053C10.153,26.189 10.026,26.243 9.836,26.243H7.586C7.333,26.243 7.175,26.053 7.333,25.808L12.181,18.3C9.583,17.321 8.125,15.335 8.125,12.642C8.125,8.154 11.136,5.842 14.685,5.842L14.685,5.842ZM14.59,7.582C12.657,7.582 10.755,8.969 10.755,12.37C10.755,15.634 12.783,16.94 14.875,16.94H16.207V7.582H14.59Z"
android:fillColor="#FFC107"/>
</vector>