|
@@ -2,6 +2,7 @@ package com.example.uniqwearappproj.Screens
|
|
|
|
|
|
import android.graphics.Bitmap
|
|
|
import android.util.Base64
|
|
|
+import android.widget.Toast
|
|
|
import androidx.compose.foundation.Canvas
|
|
|
import androidx.compose.foundation.Image
|
|
|
import androidx.compose.foundation.background
|
|
@@ -28,20 +29,31 @@ import androidx.compose.foundation.shape.RoundedCornerShape
|
|
|
import androidx.compose.material3.Button
|
|
|
import androidx.compose.material3.ButtonDefaults
|
|
|
import androidx.compose.material3.CircularProgressIndicator
|
|
|
+import androidx.compose.material3.DropdownMenuItem
|
|
|
+import androidx.compose.material3.ExperimentalMaterial3Api
|
|
|
+import androidx.compose.material3.ExposedDropdownMenuBox
|
|
|
+import androidx.compose.material3.ExposedDropdownMenuDefaults
|
|
|
import androidx.compose.material3.Icon
|
|
|
import androidx.compose.material3.IconButton
|
|
|
import androidx.compose.material3.Text
|
|
|
+import androidx.compose.material3.TextField
|
|
|
+import androidx.compose.material3.TextFieldDefaults
|
|
|
import androidx.compose.runtime.Composable
|
|
|
+import androidx.compose.runtime.LaunchedEffect
|
|
|
+import androidx.compose.runtime.collectAsState
|
|
|
import androidx.compose.runtime.getValue
|
|
|
import androidx.compose.runtime.mutableStateOf
|
|
|
import androidx.compose.runtime.remember
|
|
|
+import androidx.compose.runtime.saveable.rememberSaveable
|
|
|
import androidx.compose.runtime.setValue
|
|
|
import androidx.compose.ui.Alignment
|
|
|
import androidx.compose.ui.Modifier
|
|
|
import androidx.compose.ui.draw.clip
|
|
|
import androidx.compose.ui.geometry.Offset
|
|
|
+import androidx.compose.ui.geometry.Size
|
|
|
import androidx.compose.ui.graphics.Brush
|
|
|
import androidx.compose.ui.graphics.Color
|
|
|
+import androidx.compose.ui.graphics.drawscope.Stroke
|
|
|
import androidx.compose.ui.graphics.toArgb
|
|
|
import androidx.compose.ui.input.pointer.pointerInput
|
|
|
import androidx.compose.ui.layout.ContentScale
|
|
@@ -58,10 +70,10 @@ import coil.request.ImageRequest
|
|
|
import com.example.uniqwearappproj.MainViewModel
|
|
|
import com.example.uniqwearappproj.R
|
|
|
import java.io.ByteArrayOutputStream
|
|
|
-import java.net.URLEncoder
|
|
|
|
|
|
+@OptIn(ExperimentalMaterial3Api::class)
|
|
|
@Composable
|
|
|
-fun PrintWorkshopScreen(navController: NavHostController, imageUrl: String?, viewModel: MainViewModel) {
|
|
|
+fun PrintWorkshopScreen(navController: NavHostController, idClothesType: Int?, imageUrl: String?, viewModel: MainViewModel) {
|
|
|
var pathPoints by remember { mutableStateOf(mutableListOf<Offset>()) }
|
|
|
var brushColor by remember { mutableStateOf(Color.Black) }
|
|
|
val context = LocalContext.current
|
|
@@ -69,6 +81,30 @@ fun PrintWorkshopScreen(navController: NavHostController, imageUrl: String?, vie
|
|
|
val stream = ByteArrayOutputStream()
|
|
|
val imageData = stream.toByteArray()
|
|
|
|
|
|
+ // Состояния для хранения данных о товаре
|
|
|
+ val clothingType by viewModel.clothingType.collectAsState()
|
|
|
+ val isLoading by viewModel.isLoading.collectAsState()
|
|
|
+
|
|
|
+ //val selectedProduct = cartProductList.find { it.id == currentProductId }
|
|
|
+
|
|
|
+ // Запрос данных о товаре, если id передан
|
|
|
+ LaunchedEffect(idClothesType) {
|
|
|
+ if (idClothesType != null) {
|
|
|
+ viewModel.fetchClothesTypeById(idClothesType)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ var quantity by rememberSaveable { mutableStateOf(1) }
|
|
|
+ val sizes = listOf("S", "M", "L", "X")
|
|
|
+ var selectedSize by remember { mutableStateOf(sizes[0]) }
|
|
|
+ var expanded by remember { mutableStateOf(false) }
|
|
|
+
|
|
|
+ // Установить фиксированную цену за услугу нанесения принта
|
|
|
+ val fixedPrice = 3220.0
|
|
|
+
|
|
|
+ // Вычислить общую цену, основываясь на количестве
|
|
|
+ val totalPrice = fixedPrice * quantity
|
|
|
+
|
|
|
val user by viewModel.user
|
|
|
val flag = remember { mutableStateOf(true) }
|
|
|
|
|
@@ -114,16 +150,21 @@ fun PrintWorkshopScreen(navController: NavHostController, imageUrl: String?, vie
|
|
|
)
|
|
|
|
|
|
// Хедер страницы
|
|
|
- Box(modifier = Modifier.fillMaxWidth().padding(
|
|
|
- top = WindowInsets.statusBars.asPaddingValues()
|
|
|
- .calculateTopPadding(), // Добавляем отступ от верхней части
|
|
|
- bottom = 80.dp
|
|
|
- ),) {
|
|
|
+ Box(
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxWidth()
|
|
|
+ .padding(
|
|
|
+ top = WindowInsets.statusBars
|
|
|
+ .asPaddingValues()
|
|
|
+ .calculateTopPadding(), // Добавляем отступ от верхней части
|
|
|
+ bottom = 80.dp
|
|
|
+ ),
|
|
|
+ ) {
|
|
|
Row(
|
|
|
modifier = Modifier.fillMaxWidth(),
|
|
|
horizontalArrangement = Arrangement.SpaceBetween
|
|
|
) {
|
|
|
- IconButton(onClick = { navController.navigate("main_screen") }) {
|
|
|
+ IconButton(onClick = { navController.navigate("template_selection_screen") }) {
|
|
|
Image(
|
|
|
painter = painterResource(id = R.drawable.backbutton),
|
|
|
contentDescription = "Back Button",
|
|
@@ -136,8 +177,8 @@ fun PrintWorkshopScreen(navController: NavHostController, imageUrl: String?, vie
|
|
|
modifier = Modifier.size(50.dp)
|
|
|
)
|
|
|
// Аватарка
|
|
|
- if (photoUrl is AsyncImagePainter.State.Success){
|
|
|
- IconButton(onClick = { navController.navigate("user_profile_screen") }){
|
|
|
+ if (photoUrl is AsyncImagePainter.State.Success) {
|
|
|
+ IconButton(onClick = { navController.navigate("user_profile_screen") }) {
|
|
|
Box(
|
|
|
modifier = Modifier
|
|
|
.size(50.dp)
|
|
@@ -153,8 +194,8 @@ fun PrintWorkshopScreen(navController: NavHostController, imageUrl: String?, vie
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (photoUrl is AsyncImagePainter.State.Loading){
|
|
|
- IconButton(onClick = { navController.navigate("user_profile_screen") }){
|
|
|
+ if (photoUrl is AsyncImagePainter.State.Loading) {
|
|
|
+ IconButton(onClick = { navController.navigate("user_profile_screen") }) {
|
|
|
Box(
|
|
|
modifier = Modifier
|
|
|
.size(50.dp)
|
|
@@ -166,7 +207,7 @@ fun PrintWorkshopScreen(navController: NavHostController, imageUrl: String?, vie
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (photoUrl is AsyncImagePainter.State.Error){
|
|
|
+ if (photoUrl is AsyncImagePainter.State.Error) {
|
|
|
IconButton(onClick = { navController.navigate("user_profile_screen") }) {
|
|
|
Box(
|
|
|
modifier = Modifier
|
|
@@ -190,7 +231,9 @@ fun PrintWorkshopScreen(navController: NavHostController, imageUrl: String?, vie
|
|
|
modifier = Modifier
|
|
|
.fillMaxSize()
|
|
|
.padding(
|
|
|
- top = WindowInsets.statusBars.asPaddingValues().calculateTopPadding(),
|
|
|
+ top = WindowInsets.statusBars
|
|
|
+ .asPaddingValues()
|
|
|
+ .calculateTopPadding(),
|
|
|
bottom = 80.dp,
|
|
|
start = 16.dp, // Добавляем отступы слева
|
|
|
end = 16.dp
|
|
@@ -198,106 +241,264 @@ fun PrintWorkshopScreen(navController: NavHostController, imageUrl: String?, vie
|
|
|
verticalArrangement = Arrangement.Center,
|
|
|
horizontalAlignment = Alignment.CenterHorizontally
|
|
|
) {
|
|
|
- Text(
|
|
|
- text = "Мастерская",
|
|
|
- fontSize = 20.sp,
|
|
|
- fontWeight = FontWeight.Bold,
|
|
|
- color = Color.White,
|
|
|
- modifier = Modifier.padding(start = 16.dp) // Добавляем отступ слева
|
|
|
- )
|
|
|
- Text(
|
|
|
- text = "Нарисуйте свой принт:",
|
|
|
- fontSize = 18.sp,
|
|
|
- modifier = Modifier
|
|
|
- .padding(
|
|
|
- top = 8.dp,
|
|
|
- bottom = 16.dp,
|
|
|
- start = 16.dp
|
|
|
- ), // Добавляем отступ слева
|
|
|
- color = Color.White
|
|
|
- )
|
|
|
- Box(
|
|
|
- modifier = Modifier
|
|
|
- .fillMaxWidth()
|
|
|
- .aspectRatio(1f)
|
|
|
- .padding(16.dp)
|
|
|
- ) {
|
|
|
- if (imageUrl != null) {
|
|
|
- AsyncImage(
|
|
|
- model = imageUrl,
|
|
|
- contentDescription = "Selected Clothing Image",
|
|
|
- modifier = Modifier
|
|
|
- .size(400.dp)
|
|
|
- .clip(RoundedCornerShape(13.dp))
|
|
|
- .border(4.dp, Color.Gray, RoundedCornerShape(13.dp))
|
|
|
- .align(Alignment.Center),
|
|
|
- contentScale = ContentScale.Crop
|
|
|
+ if (isLoading) {
|
|
|
+ CircularProgressIndicator()
|
|
|
+ } else {
|
|
|
+ if (clothingType != null) {
|
|
|
+ Text(
|
|
|
+ text = "Мастерская",
|
|
|
+ fontSize = 20.sp,
|
|
|
+ fontWeight = FontWeight.Bold,
|
|
|
+ color = Color.White,
|
|
|
+ modifier = Modifier.padding(start = 16.dp) // Добавляем отступ слева
|
|
|
)
|
|
|
- } else {
|
|
|
Text(
|
|
|
- text = "Ошибка загрузки изображения",
|
|
|
- color = Color.Red,
|
|
|
- modifier = Modifier.align(Alignment.Center)
|
|
|
+ text = "Нарисуйте свой принт:",
|
|
|
+ fontSize = 18.sp,
|
|
|
+ modifier = Modifier
|
|
|
+ .padding(
|
|
|
+ top = 8.dp,
|
|
|
+ bottom = 16.dp,
|
|
|
+ start = 16.dp
|
|
|
+ ), // Добавляем отступ слева
|
|
|
+ color = Color.White
|
|
|
)
|
|
|
- }
|
|
|
- Canvas(
|
|
|
- modifier = Modifier
|
|
|
- .fillMaxSize()
|
|
|
- .pointerInput(Unit) {
|
|
|
- detectDragGestures { change, _ ->
|
|
|
- val newPoint = change.position
|
|
|
- pathPoints = (pathPoints + newPoint).toMutableList()
|
|
|
+ Box(
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxWidth()
|
|
|
+ .aspectRatio(1f)
|
|
|
+ .padding(16.dp)
|
|
|
+ ) {
|
|
|
+ if (imageUrl != null) {
|
|
|
+ AsyncImage(
|
|
|
+ model = clothingType!!.image_url,
|
|
|
+ contentDescription = "Selected Clothing Image",
|
|
|
+ modifier = Modifier
|
|
|
+ .size(400.dp)
|
|
|
+ .clip(RoundedCornerShape(13.dp))
|
|
|
+ .border(4.dp, Color.Gray, RoundedCornerShape(13.dp))
|
|
|
+ .align(Alignment.Center),
|
|
|
+ contentScale = ContentScale.Crop
|
|
|
+ )
|
|
|
+ } else {
|
|
|
+ Text(
|
|
|
+ text = "Ошибка загрузки изображения",
|
|
|
+ color = Color.Red,
|
|
|
+ modifier = Modifier.align(Alignment.Center)
|
|
|
+ )
|
|
|
+ }
|
|
|
+ Canvas(
|
|
|
+ modifier = Modifier
|
|
|
+ .fillMaxSize()
|
|
|
+ .pointerInput(Unit) {
|
|
|
+ detectDragGestures { change, _ ->
|
|
|
+ val canvasWidth = size.width
|
|
|
+ val canvasHeight = size.height
|
|
|
+
|
|
|
+ // Вычисляем границы области рисования (центр 240x240)
|
|
|
+ val centerX = canvasWidth / 2
|
|
|
+ val centerY = canvasHeight / 2
|
|
|
+ val drawingAreaSize = 335.dp.toPx() // Размер области 240x240
|
|
|
+ val leftBound = centerX - drawingAreaSize / 2
|
|
|
+ val rightBound = centerX + drawingAreaSize / 2
|
|
|
+ val topBound = centerY - drawingAreaSize / 2
|
|
|
+ val bottomBound = centerY + drawingAreaSize / 2
|
|
|
+
|
|
|
+ val newPoint = change.position
|
|
|
+
|
|
|
+ // Проверяем, входит ли точка в разрешённую область
|
|
|
+ if (newPoint.x in leftBound..rightBound && newPoint.y in topBound..bottomBound) {
|
|
|
+ pathPoints = (pathPoints + newPoint).toMutableList()
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ) {
|
|
|
+ val canvasWidth = size.width
|
|
|
+ val canvasHeight = size.height
|
|
|
+
|
|
|
+ // Вычисляем границы разрешенной области (центр 240x240)
|
|
|
+ val centerX = canvasWidth / 2
|
|
|
+ val centerY = canvasHeight / 2
|
|
|
+ val drawingAreaSize = 335.dp.toPx() // Размер области 240x240
|
|
|
+ val leftBound = centerX - drawingAreaSize / 2
|
|
|
+ val rightBound = centerX + drawingAreaSize / 2
|
|
|
+ val topBound = centerY - drawingAreaSize / 2
|
|
|
+ val bottomBound = centerY + drawingAreaSize / 2
|
|
|
+
|
|
|
+ // Удаляем или делаем рамку прозрачной (в данном случае не рисуем её)
|
|
|
+ drawRect(
|
|
|
+ color = Color.Transparent,
|
|
|
+ topLeft = Offset(leftBound, topBound),
|
|
|
+ size = Size(drawingAreaSize, drawingAreaSize),
|
|
|
+ style = Stroke(width = 4f)
|
|
|
+ )
|
|
|
+
|
|
|
+ // Рисуем линии только внутри разрешенной области
|
|
|
+ for (i in 1 until pathPoints.size) {
|
|
|
+ if (pathPoints[i - 1].x in leftBound..rightBound &&
|
|
|
+ pathPoints[i - 1].y in topBound..bottomBound &&
|
|
|
+ pathPoints[i].x in leftBound..rightBound &&
|
|
|
+ pathPoints[i].y in topBound..bottomBound
|
|
|
+ ) {
|
|
|
+ drawLine(
|
|
|
+ color = brushColor,
|
|
|
+ start = pathPoints[i - 1],
|
|
|
+ end = pathPoints[i],
|
|
|
+ strokeWidth = 5f
|
|
|
+ )
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- ) {
|
|
|
- for (i in 1 until pathPoints.size) {
|
|
|
- drawLine(
|
|
|
- color = brushColor,
|
|
|
- start = pathPoints[i - 1],
|
|
|
- end = pathPoints[i],
|
|
|
- strokeWidth = 5f
|
|
|
+ }
|
|
|
+ Spacer(modifier = Modifier.height(8.dp))
|
|
|
+ ClearColor(onClear = { pathPoints = mutableListOf() })
|
|
|
+
|
|
|
+ Spacer(modifier = Modifier.height(8.dp))
|
|
|
+
|
|
|
+ //Изменение количества
|
|
|
+ Box(
|
|
|
+ modifier = Modifier
|
|
|
+ .background(Color(0xFFD9D9D9).copy(alpha = 0.5f), RoundedCornerShape(10.dp)) // Заливка и закругленные углы
|
|
|
+ .border(2.dp, Color(0xFF5F5EB7), RoundedCornerShape(10.dp)) // Рамка
|
|
|
+ .padding(4.dp) // Паддинг внутри бокса
|
|
|
+ ) {
|
|
|
+ // Управление количеством
|
|
|
+ Row(
|
|
|
+ verticalAlignment = Alignment.CenterVertically,
|
|
|
+ horizontalArrangement = Arrangement.Center // Центрирование содержимого
|
|
|
+ ) {
|
|
|
+ IconButton(
|
|
|
+ onClick = { quantity++ },
|
|
|
+ modifier = Modifier.size(55.dp)
|
|
|
+ ) {
|
|
|
+ Icon(
|
|
|
+ painter = painterResource(id = R.drawable.add),
|
|
|
+ contentDescription = "Increase Quantity",
|
|
|
+ tint = Color.White,
|
|
|
+ modifier = Modifier.size(28.dp) // Увеличение размера иконки
|
|
|
+
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Text(
|
|
|
+ text = "$quantity",
|
|
|
+ fontSize = 20.sp,
|
|
|
+ color = Color.White,
|
|
|
+ modifier = Modifier.padding(horizontal = 8.dp)
|
|
|
+ )
|
|
|
+
|
|
|
+ IconButton(
|
|
|
+ onClick = { if (quantity > 1) quantity-- },
|
|
|
+ modifier = Modifier.size(55.dp)
|
|
|
+ ) {
|
|
|
+ Icon(
|
|
|
+ painter = painterResource(id = R.drawable.minus),
|
|
|
+ contentDescription = "Decrease Quantity",
|
|
|
+ tint = Color.White,
|
|
|
+ modifier = Modifier.size(28.dp) // Увеличение размера иконки
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Spacer(modifier = Modifier.height(8.dp))
|
|
|
+
|
|
|
+ // Выбор размера
|
|
|
+ ExposedDropdownMenuBox(
|
|
|
+ expanded = expanded,
|
|
|
+ onExpandedChange = { expanded = !expanded },
|
|
|
+ modifier = Modifier
|
|
|
+ .background(Color(0xFFD9D9D9), RoundedCornerShape(10.dp))
|
|
|
+ .width(142.dp)
|
|
|
+ ) {
|
|
|
+ TextField(
|
|
|
+ value = selectedSize,
|
|
|
+ onValueChange = {},
|
|
|
+ readOnly = true,
|
|
|
+ label = { Text("Размер") },
|
|
|
+ colors = TextFieldDefaults.colors(
|
|
|
+ unfocusedTextColor = Color.Black,
|
|
|
+ unfocusedContainerColor = Color(0xFFD9D9D9).copy(alpha = 0.5f),
|
|
|
+ focusedTextColor = Color.Black,
|
|
|
+ focusedContainerColor = Color(0xFFD9D9D9).copy(alpha = 0.5f),
|
|
|
+ focusedIndicatorColor = Color.Transparent,
|
|
|
+ unfocusedIndicatorColor = Color.Transparent,
|
|
|
+ ),
|
|
|
+ trailingIcon = {
|
|
|
+ ExposedDropdownMenuDefaults.TrailingIcon(expanded = expanded)
|
|
|
+ },
|
|
|
+ modifier = Modifier
|
|
|
+ .menuAnchor()
|
|
|
+ .background(Color(0xFFD9D9D9), RoundedCornerShape(10.dp))
|
|
|
+ .border(2.dp, Color(0xFF5F5EB7), RoundedCornerShape(10.dp))
|
|
|
)
|
|
|
+ ExposedDropdownMenu(
|
|
|
+ expanded = expanded,
|
|
|
+ onDismissRequest = { expanded = false }
|
|
|
+ ) {
|
|
|
+ sizes.forEach { size ->
|
|
|
+ DropdownMenuItem(
|
|
|
+ text = { Text(size) },
|
|
|
+ onClick = {
|
|
|
+ selectedSize = size
|
|
|
+ expanded = false
|
|
|
+ }
|
|
|
+ )
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
- Spacer(modifier = Modifier.height(8.dp))
|
|
|
- ClearColor(onClear = { pathPoints = mutableListOf() })
|
|
|
- Spacer(modifier = Modifier.height(8.dp))
|
|
|
- Button(
|
|
|
- onClick = {
|
|
|
- // Save the drawing to a bitmap
|
|
|
- val bitmap = Bitmap.createBitmap(200, 200, Bitmap.Config.ARGB_8888)
|
|
|
- val canvas = android.graphics.Canvas(bitmap)
|
|
|
- canvas.drawColor(android.graphics.Color.WHITE) // Background color
|
|
|
- for (i in 1 until pathPoints.size) {
|
|
|
- canvas.drawLine(
|
|
|
- pathPoints[i - 1].x,
|
|
|
- pathPoints[i - 1].y,
|
|
|
- pathPoints[i].x,
|
|
|
- pathPoints[i].y,
|
|
|
- android.graphics.Paint().apply {
|
|
|
+
|
|
|
+ Spacer(modifier = Modifier.height(8.dp))
|
|
|
+ Button(
|
|
|
+ onClick = {
|
|
|
+ // Размер холста, чтобы он был достаточен для изображения
|
|
|
+ val width = 800 // Примерная ширина холста
|
|
|
+ val height = 800 // Примерная высота холста
|
|
|
+
|
|
|
+ // Создаем Bitmap с нужными размерами
|
|
|
+ val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
|
|
|
+ val canvas = android.graphics.Canvas(bitmap)
|
|
|
+ canvas.drawColor(android.graphics.Color.WHITE) // Фон рисунка
|
|
|
+
|
|
|
+ // Рисуем линии из pathPoints на canvas
|
|
|
+ val paint = android.graphics.Paint().apply {
|
|
|
color = brushColor.toArgb()
|
|
|
strokeWidth = 5f
|
|
|
+ isAntiAlias = true
|
|
|
}
|
|
|
+ for (i in 1 until pathPoints.size) {
|
|
|
+ canvas.drawLine(
|
|
|
+ pathPoints[i - 1].x,
|
|
|
+ pathPoints[i - 1].y,
|
|
|
+ pathPoints[i].x,
|
|
|
+ pathPoints[i].y,
|
|
|
+ paint
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
+ // Сохранение рисунка и других данных через функцию ViewModel
|
|
|
+ viewModel.saveCanvasDrawingAsAvatar(bitmap,
|
|
|
+ totalPrice.toFloat(), selectedSize,
|
|
|
+ quantity.toString()
|
|
|
+ )
|
|
|
+ navController.navigate("thx_for_payment_screen")
|
|
|
+ },
|
|
|
+ modifier = Modifier
|
|
|
+ .width(240.dp)
|
|
|
+ .height(48.dp),
|
|
|
+ colors = ButtonDefaults.buttonColors(containerColor = Color(0xFF5F5EB7)),
|
|
|
+ shape = RoundedCornerShape(12.dp)
|
|
|
+ ) {
|
|
|
+ Text(
|
|
|
+ text = "Оплатить: ${"%.2f".format(totalPrice)} ₽",
|
|
|
+ fontWeight = FontWeight.Bold,
|
|
|
+ fontSize = 20.sp,
|
|
|
+ color = Color.White
|
|
|
)
|
|
|
}
|
|
|
-
|
|
|
- // Save to drawingBitmap and navigate to CartScreen
|
|
|
- drawingBitmap.value = bitmap
|
|
|
- val encodedImage = encodeBitmapToBase64(drawingBitmap.value!!)
|
|
|
- val encodedImageUrlSafe = URLEncoder.encode(encodedImage, "UTF-8")
|
|
|
- navController.navigate("cart_screen/$encodedImageUrlSafe")
|
|
|
- },
|
|
|
- modifier = Modifier.width(200.dp).height(48.dp),
|
|
|
- colors = ButtonDefaults.buttonColors(containerColor = Color(0xFF5F5EB7)),
|
|
|
- shape = RoundedCornerShape(12.dp)
|
|
|
- ) {
|
|
|
- Text(
|
|
|
- text = "Готово",
|
|
|
- fontWeight = FontWeight.Bold,
|
|
|
- fontSize = 20.sp,
|
|
|
- color = Color.White
|
|
|
- )
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -359,13 +560,18 @@ fun PrintWorkshopScreen(navController: NavHostController, imageUrl: String?, vie
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ // Иконка для перехода в корзину
|
|
|
IconButton(
|
|
|
- onClick = { navController.navigate("cart_screen") },
|
|
|
+ onClick = {
|
|
|
+ // Вместо перехода показываем сообщение
|
|
|
+ Toast.makeText(context, "Корзина пуста, для начала выберите товар!", Toast.LENGTH_SHORT).show()
|
|
|
+
|
|
|
+ },
|
|
|
modifier = Modifier
|
|
|
- .size(64.dp) // Увеличение размера кнопки
|
|
|
+ .size(64.dp)
|
|
|
.background(
|
|
|
color = Color(0xFFD9D9D9).copy(alpha = 0.5f),
|
|
|
- shape = RoundedCornerShape(10.dp) // Закругление углов
|
|
|
+ shape = RoundedCornerShape(10.dp)
|
|
|
)
|
|
|
) {
|
|
|
Box(
|
|
@@ -376,12 +582,13 @@ fun PrintWorkshopScreen(navController: NavHostController, imageUrl: String?, vie
|
|
|
Icon(
|
|
|
painter = painterResource(id = R.drawable.cart),
|
|
|
contentDescription = "Go to Cart",
|
|
|
- tint = Color(0xFFFFFFFF), // Цвет иконки
|
|
|
- modifier = Modifier.size(39.dp) // Увеличение размера иконки (при желании)
|
|
|
+ tint = Color(0xFFFFFFFF),
|
|
|
+ modifier = Modifier.size(39.dp)
|
|
|
)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
IconButton(
|
|
|
onClick = { navController.navigate("user_profile_screen") },
|
|
|
modifier = Modifier
|
|
@@ -409,6 +616,7 @@ fun PrintWorkshopScreen(navController: NavHostController, imageUrl: String?, vie
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Composable
|
|
|
fun ClearColor(onClear: () -> Unit) {
|
|
|
Row(
|