From b5c8270c1c597ea9d850847e947bcd82818e9a0d Mon Sep 17 00:00:00 2001 From: Danya_Mochalov Date: Wed, 11 Oct 2023 00:55:22 +0400 Subject: [PATCH] =?UTF-8?q?=D0=AD=D0=BA=D1=80=D0=B0=D0=BD=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=BA=D1=83=D0=BF=D0=BE=D0=BA=20=D0=A2=D0=9E=D0=A7=D0=9D=D0=9E?= =?UTF-8?q?=20=D0=B3=D0=BE=D1=82=D0=BE=D0=B2.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../shawarma/screens/cart/CartScreen.kt | 304 +++++++++++------- 1 file changed, 182 insertions(+), 122 deletions(-) diff --git a/app/src/main/java/com/example/shawarma/screens/cart/CartScreen.kt b/app/src/main/java/com/example/shawarma/screens/cart/CartScreen.kt index 8dbde3a..e97ed92 100644 --- a/app/src/main/java/com/example/shawarma/screens/cart/CartScreen.kt +++ b/app/src/main/java/com/example/shawarma/screens/cart/CartScreen.kt @@ -2,15 +2,21 @@ package com.example.shawarma.screens.cart import androidx.compose.foundation.BorderStroke import androidx.compose.foundation.background +import androidx.compose.foundation.gestures.Orientation import androidx.compose.foundation.gestures.scrollable import androidx.compose.foundation.layout.Arrangement import androidx.compose.foundation.layout.Box import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Row +import androidx.compose.foundation.layout.Spacer +import androidx.compose.foundation.layout.fillMaxHeight import androidx.compose.foundation.layout.fillMaxSize 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.lazy.LazyColumn import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.foundation.verticalScroll @@ -25,6 +31,8 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.Color import androidx.compose.ui.res.painterResource +import androidx.compose.ui.text.font.Font +import androidx.compose.ui.text.font.FontFamily import androidx.compose.ui.text.font.FontWeight import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.sp @@ -59,16 +67,20 @@ fun CartWidget(){ contentAlignment = Alignment.TopCenter ) { + Text( + text = "Корзина", + fontFamily = MarckFamily, + fontSize = 40.sp, + modifier = Modifier.padding(top = 15.dp) + ) Column( horizontalAlignment = Alignment.CenterHorizontally, - modifier = Modifier.verticalScroll(rememberScrollState()) + modifier = Modifier + .fillMaxWidth() + .padding(top=55.dp) + .verticalScroll(rememberScrollState()) ) { - Text( - text = "Корзина", - fontFamily = MarckFamily, - fontSize = 40.sp, - modifier = Modifier.padding(top = 15.dp) - ) + Text( text = "Оплачено:", fontFamily = NunitoFamily, @@ -76,65 +88,13 @@ fun CartWidget(){ modifier = Modifier.padding(top = 15.dp), fontWeight = FontWeight.Bold ) - Card( - border = BorderStroke(width = 2.dp, color = MyOrange), - shape = RoundedCornerShape(size = 20.dp), - backgroundColor = Color.White, - modifier = Modifier.size(340.dp, 100.dp) + LazyColumn( + modifier = Modifier + .width(340.dp) + .height(200.dp) ) { - Column { - Row( - horizontalArrangement = Arrangement.SpaceBetween, - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 20.dp) - ){ - Text( - text = "Классика", - fontFamily = NunitoFamily, - fontSize = 20.sp, - modifier = Modifier.padding(top = 15.dp), - fontWeight = FontWeight.Bold - ) - Text( - text = "x2", - fontFamily = NunitoFamily, - fontSize = 20.sp, - modifier = Modifier.padding(top = 15.dp), - fontWeight = FontWeight.Bold - ) - Text( - text = "300 руб.", - fontFamily = NunitoFamily, - fontSize = 20.sp, - modifier = Modifier.padding(top = 15.dp), - fontWeight = FontWeight.Bold - ) - } - - Row( - horizontalArrangement = Arrangement.SpaceBetween, - modifier = Modifier - .fillMaxWidth() - .padding(horizontal = 20.dp) - ){ - Text( - text = "Статус: ", - fontFamily = NunitoFamily, - fontSize = 20.sp, - modifier = Modifier.padding(top = 15.dp), - fontWeight = FontWeight.Bold, - color = Color.Gray - ) - Text( - text = "Готовится", - fontFamily = NunitoFamily, - fontSize = 20.sp, - modifier = Modifier.padding(top = 15.dp), - fontWeight = FontWeight.Bold, - color = Color.Gray - ) - } + items(2) { + PaidItem() } } Text( @@ -144,68 +104,168 @@ fun CartWidget(){ modifier = Modifier.padding(top = 15.dp), fontWeight = FontWeight.Bold ) - Card( - border = BorderStroke(width = 2.dp, color = MyOrange), - shape = RoundedCornerShape(size = 20.dp), - backgroundColor = Color.White, - modifier = Modifier.size(340.dp, 100.dp) + LazyColumn( + modifier = Modifier + .width(340.dp) + .height(200.dp) ) { - Row( - verticalAlignment = Alignment.CenterVertically, - horizontalArrangement = Arrangement.SpaceBetween, - modifier = Modifier.padding(20.dp) - ) { - Column( - - modifier = Modifier.fillMaxWidth(0.5f) - ) { - Row( - horizontalArrangement = Arrangement.SpaceBetween, - modifier = Modifier.fillMaxWidth() - ){ - Text( - text = "Кока-кола", - fontFamily = NunitoFamily, - fontSize = 20.sp, - fontWeight = FontWeight.Bold - ) - Text( - text = "x2", - fontFamily = NunitoFamily, - fontSize = 20.sp, - fontWeight = FontWeight.Bold - ) - } - Text( - text = "300 руб.", - fontFamily = NunitoFamily, - fontSize = 20.sp, - fontWeight = FontWeight.Bold - ) - } - - Button( - colors = ButtonDefaults.buttonColors( - backgroundColor = MyLightRed - ), - shape = RoundedCornerShape(size = 10.dp), - modifier = Modifier - .size(100.dp, 60.dp) - .fillMaxSize(0.5f), - onClick = { /*TODO*/ } - ) { - Icon( - painter = painterResource(id = R.drawable.trash), - contentDescription = "Delete", - modifier = Modifier.size(42.dp) - ) - } - + items(2) { + CartItem() } } + Spacer(modifier = Modifier.height(20.dp)) + + Button( + colors = ButtonDefaults.buttonColors( + backgroundColor = Color(0xFF91FF87) + ), + shape = RoundedCornerShape(20.dp), + border = BorderStroke(2.dp, Color(0x66000000)), + modifier = Modifier.size(240.dp, 60.dp), + onClick = { /*TODO*/ } + ) { + Text( + "Оплатить", + fontSize = 20.sp, + fontFamily = NunitoFamily, + fontWeight = FontWeight(700), + ) + } + + Spacer(modifier = Modifier.height(70.dp)) + } - } +} + +@Composable +fun PaidItem() { + Card( + border = BorderStroke(width = 2.dp, color = MyOrange), + shape = RoundedCornerShape(size = 20.dp), + backgroundColor = Color.White, + modifier = Modifier.size(340.dp, 100.dp) + ) { + Column { + Row( + horizontalArrangement = Arrangement.SpaceBetween, + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 20.dp) + ){ + Text( + text = "Классика", + fontFamily = NunitoFamily, + fontSize = 20.sp, + modifier = Modifier.padding(top = 15.dp), + fontWeight = FontWeight.Bold + ) + Text( + text = "x2", + fontFamily = NunitoFamily, + fontSize = 20.sp, + modifier = Modifier.padding(top = 15.dp), + fontWeight = FontWeight.Bold + ) + Text( + text = "300 руб.", + fontFamily = NunitoFamily, + fontSize = 20.sp, + modifier = Modifier.padding(top = 15.dp), + fontWeight = FontWeight.Bold + ) + } + + Row( + horizontalArrangement = Arrangement.SpaceBetween, + modifier = Modifier + .fillMaxWidth() + .padding(horizontal = 20.dp) + ){ + Text( + text = "Статус: ", + fontFamily = NunitoFamily, + fontSize = 20.sp, + modifier = Modifier.padding(top = 15.dp), + fontWeight = FontWeight.Bold, + color = Color.Gray + ) + Text( + text = "Готовится", + fontFamily = NunitoFamily, + fontSize = 20.sp, + modifier = Modifier.padding(top = 15.dp), + fontWeight = FontWeight.Bold, + color = Color.Gray + ) + } + } + } + Spacer(modifier = Modifier.height(20.dp)) +} + +@Composable +fun CartItem() { + Card( + border = BorderStroke(width = 2.dp, color = MyOrange), + shape = RoundedCornerShape(size = 20.dp), + backgroundColor = Color.White, + modifier = Modifier.size(340.dp, 100.dp) + ) { + Row( + verticalAlignment = Alignment.CenterVertically, + horizontalArrangement = Arrangement.SpaceBetween, + modifier = Modifier.padding(20.dp) + ) { + Column( + + modifier = Modifier.fillMaxWidth(0.5f) + ) { + Row( + horizontalArrangement = Arrangement.SpaceBetween, + modifier = Modifier.fillMaxWidth() + ){ + Text( + text = "Кока-кола", + fontFamily = NunitoFamily, + fontSize = 20.sp, + fontWeight = FontWeight.Bold + ) + Text( + text = "x2", + fontFamily = NunitoFamily, + fontSize = 20.sp, + fontWeight = FontWeight.Bold + ) + } + Text( + text = "300 руб.", + fontFamily = NunitoFamily, + fontSize = 20.sp, + fontWeight = FontWeight.Bold + ) + } + + Button( + colors = ButtonDefaults.buttonColors( + backgroundColor = MyLightRed + ), + shape = RoundedCornerShape(size = 10.dp), + modifier = Modifier + .size(100.dp, 60.dp) + .fillMaxSize(0.5f), + onClick = { /*TODO*/ } + ) { + Icon( + painter = painterResource(id = R.drawable.trash), + contentDescription = "Delete", + modifier = Modifier.size(42.dp) + ) + } + + } + } + Spacer(modifier = Modifier.height(20.dp)) } \ No newline at end of file