ПВАЗХЩПХЗВАЩЗПХВАХЗПЩВ, ЭТО САМЫЙ ЖОСКИЙ КОСТЫЛЬ, НО ОНО РАБОТАЕТ

This commit is contained in:
Кашин Максим 2023-11-19 23:09:23 +04:00
parent 61b1507973
commit 4df3eff3b1
3 changed files with 8 additions and 5 deletions

View File

@ -11,6 +11,7 @@ import androidx.compose.runtime.mutableStateListOf
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.navigation.NavHostController
import com.example.labwork.database.DAO.BicycleDao import com.example.labwork.database.DAO.BicycleDao
import com.example.labwork.models.Bicycle import com.example.labwork.models.Bicycle
import com.example.labwork.pages.ListInfo import com.example.labwork.pages.ListInfo
@ -31,7 +32,7 @@ fun ScreenProfile() {
@Composable @Composable
fun ScreenListProduct(bicycleDao: BicycleDao) { fun ScreenListProduct(bicycleDao: BicycleDao, navHostController: NavHostController) {
val bicycles = remember { mutableStateListOf<Bicycle>() } val bicycles = remember { mutableStateListOf<Bicycle>() }
LaunchedEffect(Unit) { LaunchedEffect(Unit) {
@ -45,7 +46,7 @@ fun ScreenListProduct(bicycleDao: BicycleDao) {
modifier = Modifier.fillMaxHeight().padding(bottom = 65.dp) modifier = Modifier.fillMaxHeight().padding(bottom = 65.dp)
) { ) {
items(bicycles) { item -> items(bicycles) { item ->
ListProduct(item = item, bicycleDao = bicycleDao) ListProduct(item = item, bicycleDao = bicycleDao, navHostController = navHostController)
} }
} }
} }

View File

@ -24,7 +24,7 @@ fun SlideGraph(
ScreenInfo() ScreenInfo()
} }
composable("ListProduct"){ composable("ListProduct"){
ScreenListProduct(bicycleDao) ScreenListProduct(bicycleDao, navHostController = navHostController)
} }
} }

View File

@ -35,6 +35,7 @@ import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp import androidx.compose.ui.unit.sp
import androidx.navigation.NavHostController
import com.example.labwork.R import com.example.labwork.R
import com.example.labwork.database.DAO.BicycleDao import com.example.labwork.database.DAO.BicycleDao
import com.example.labwork.database.DAO.UserDao import com.example.labwork.database.DAO.UserDao
@ -45,7 +46,7 @@ import kotlinx.coroutines.launch
@Composable @Composable
fun ListProduct(item: Bicycle, bicycleDao: BicycleDao) { fun ListProduct(item: Bicycle, bicycleDao: BicycleDao, navHostController: NavHostController) {
var isFullAbout by remember { mutableStateOf(false) } var isFullAbout by remember { mutableStateOf(false) }
val scale by animateFloatAsState(if (isFullAbout) 1f else 0f) val scale by animateFloatAsState(if (isFullAbout) 1f else 0f)
val textSize by animateDpAsState(if (isFullAbout) 18.dp else 24.dp) val textSize by animateDpAsState(if (isFullAbout) 18.dp else 24.dp)
@ -116,10 +117,11 @@ fun ListProduct(item: Bicycle, bicycleDao: BicycleDao) {
.padding(start = 9.dp, bottom = 9.dp) .padding(start = 9.dp, bottom = 9.dp)
.size(height = 32.dp, width = 40.dp), .size(height = 32.dp, width = 40.dp),
onClick = { onClick = {
// Удаление выбранного велосипеда по нажатию на кнопку // СУПЕР ЖОСКИЙ КОСТЫЛЬ ЭТО ВООБЩЕ ТРЕШ
GlobalScope.launch { GlobalScope.launch {
bicycleDao.deleteBicycle(item) bicycleDao.deleteBicycle(item)
} }
navHostController.navigate("ListProduct")
}, },
shape = RoundedCornerShape(15.dp) shape = RoundedCornerShape(15.dp)
) { ) {