From 5e992dbf8a21e592057aaa9b9b71399a65ba64ff Mon Sep 17 00:00:00 2001 From: dasha Date: Tue, 19 Dec 2023 19:44:47 +0400 Subject: [PATCH] =?UTF-8?q?=D0=BD=D0=B5=D0=B8=D1=81=D0=BF=D0=BE=D0=BB?= =?UTF-8?q?=D1=8C=D0=B7=D1=83=D0=B5=D0=BC=D1=8B=D0=B9=20=D1=84=D1=83=D0=BD?= =?UTF-8?q?=D0=BA=D1=86=D0=B8=D0=BE=D0=BD=D0=B0=D0=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../example/myapplication/composeui/Cart.kt | 43 ------------------- 1 file changed, 43 deletions(-) diff --git a/app/src/main/java/com/example/myapplication/composeui/Cart.kt b/app/src/main/java/com/example/myapplication/composeui/Cart.kt index 8f95ee7..24a789a 100644 --- a/app/src/main/java/com/example/myapplication/composeui/Cart.kt +++ b/app/src/main/java/com/example/myapplication/composeui/Cart.kt @@ -1,6 +1,5 @@ package com.example.myapplication.composeui -import android.content.res.Configuration import android.graphics.BitmapFactory import androidx.compose.foundation.Image import androidx.compose.foundation.background @@ -18,15 +17,11 @@ import androidx.compose.foundation.shape.RoundedCornerShape import androidx.compose.material.icons.Icons import androidx.compose.material.icons.filled.Add import androidx.compose.material3.Button -import androidx.compose.material3.DismissDirection -import androidx.compose.material3.DismissState import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.Icon import androidx.compose.material3.IconButton import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Surface import androidx.compose.material3.Text -import androidx.compose.material3.rememberDismissState import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.livedata.observeAsState @@ -37,7 +32,6 @@ import androidx.compose.ui.draw.clip import androidx.compose.ui.graphics.asImageBitmap import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.res.vectorResource -import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.unit.dp import androidx.lifecycle.viewmodel.compose.viewModel import com.example.myapplication.LiveStore @@ -46,7 +40,6 @@ import com.example.myapplication.database.entities.composeui.AppViewModelProvide import com.example.myapplication.database.entities.model.Session import com.example.myapplication.database.entities.model.SessionFromCart import com.example.myapplication.database.entities.model.UserRole -import com.example.myapplication.ui.theme.PmudemoTheme import kotlinx.coroutines.launch import org.threeten.bp.format.DateTimeFormatter @@ -64,19 +57,6 @@ fun Cart( cartUiState = cartUiState, modifier = Modifier .padding(all = 10.dp), - onSwipe = { session: SessionFromCart -> - coroutineScope.launch { - viewModel.removeFromCart( - session = Session( - uid = session.uid, - dateTime = session.dateTime, - price = session.price, - maxCount = 0, - cinemaId = session.cinemaId - ) - ) - } - }, onChangeCount = { session: SessionFromCart, count: Int -> coroutineScope.launch { viewModel.updateFromCart( @@ -103,7 +83,6 @@ fun Cart( private fun Cart( cartUiState: CartUiState, modifier: Modifier, - onSwipe: (SessionFromCart) -> Unit, onChangeCount: (SessionFromCart, Int) -> Unit, onAddToOrder: (List) -> Unit ) { @@ -111,13 +90,6 @@ private fun Cart( modifier = modifier ) { items(cartUiState.sessionList, key = { it.uid.toString() }) { session -> - val dismissState: DismissState = rememberDismissState( - positionalThreshold = { 200.dp.toPx() } - ) - - if (dismissState.isDismissed(direction = DismissDirection.EndToStart)) { - onSwipe(session) - } SessionListItem( session = session, modifier = Modifier @@ -150,8 +122,6 @@ private fun SessionListItem( modifier: Modifier = Modifier, onChangeCount: (SessionFromCart, Int) -> Unit, ) { - //var currentCount by remember { mutableIntStateOf(session.count) } - val dateFormatter = DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm") val formattedDate = dateFormatter.format(session.dateTime) Column { @@ -241,16 +211,3 @@ private fun SessionListItem( } } } - -@Preview(name = "Light Mode", showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_NO) -@Preview(name = "Dark Mode", showBackground = true, uiMode = Configuration.UI_MODE_NIGHT_YES) -@Composable -fun CartPreview() { - PmudemoTheme { - Surface( - color = MaterialTheme.colorScheme.background - ) { - Cart() - } - } -}