неиспользуемый функционал

This commit is contained in:
dasha 2023-12-19 19:44:47 +04:00
parent baf333dea1
commit 5e992dbf8a

View File

@ -1,6 +1,5 @@
package com.example.myapplication.composeui package com.example.myapplication.composeui
import android.content.res.Configuration
import android.graphics.BitmapFactory import android.graphics.BitmapFactory
import androidx.compose.foundation.Image import androidx.compose.foundation.Image
import androidx.compose.foundation.background 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.Icons
import androidx.compose.material.icons.filled.Add import androidx.compose.material.icons.filled.Add
import androidx.compose.material3.Button import androidx.compose.material3.Button
import androidx.compose.material3.DismissDirection
import androidx.compose.material3.DismissState
import androidx.compose.material3.ExperimentalMaterial3Api import androidx.compose.material3.ExperimentalMaterial3Api
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.rememberDismissState
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.livedata.observeAsState 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.asImageBitmap
import androidx.compose.ui.graphics.vector.ImageVector import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.res.vectorResource import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.lifecycle.viewmodel.compose.viewModel import androidx.lifecycle.viewmodel.compose.viewModel
import com.example.myapplication.LiveStore 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.Session
import com.example.myapplication.database.entities.model.SessionFromCart import com.example.myapplication.database.entities.model.SessionFromCart
import com.example.myapplication.database.entities.model.UserRole import com.example.myapplication.database.entities.model.UserRole
import com.example.myapplication.ui.theme.PmudemoTheme
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
import org.threeten.bp.format.DateTimeFormatter import org.threeten.bp.format.DateTimeFormatter
@ -64,19 +57,6 @@ fun Cart(
cartUiState = cartUiState, cartUiState = cartUiState,
modifier = Modifier modifier = Modifier
.padding(all = 10.dp), .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 -> onChangeCount = { session: SessionFromCart, count: Int ->
coroutineScope.launch { coroutineScope.launch {
viewModel.updateFromCart( viewModel.updateFromCart(
@ -103,7 +83,6 @@ fun Cart(
private fun Cart( private fun Cart(
cartUiState: CartUiState, cartUiState: CartUiState,
modifier: Modifier, modifier: Modifier,
onSwipe: (SessionFromCart) -> Unit,
onChangeCount: (SessionFromCart, Int) -> Unit, onChangeCount: (SessionFromCart, Int) -> Unit,
onAddToOrder: (List<SessionFromCart>) -> Unit onAddToOrder: (List<SessionFromCart>) -> Unit
) { ) {
@ -111,13 +90,6 @@ private fun Cart(
modifier = modifier modifier = modifier
) { ) {
items(cartUiState.sessionList, key = { it.uid.toString() }) { session -> 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( SessionListItem(
session = session, session = session,
modifier = Modifier modifier = Modifier
@ -150,8 +122,6 @@ private fun SessionListItem(
modifier: Modifier = Modifier, modifier: Modifier = Modifier,
onChangeCount: (SessionFromCart, Int) -> Unit, onChangeCount: (SessionFromCart, Int) -> Unit,
) { ) {
//var currentCount by remember { mutableIntStateOf(session.count) }
val dateFormatter = DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm") val dateFormatter = DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm")
val formattedDate = dateFormatter.format(session.dateTime) val formattedDate = dateFormatter.format(session.dateTime)
Column { 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()
}
}
}