Работает добавление
This commit is contained in:
parent
36c001ca2e
commit
96d09edf51
@ -50,7 +50,7 @@ fun ScreenListProduct(
|
||||
Column(
|
||||
modifier = Modifier.fillMaxHeight().padding(bottom = 65.dp)
|
||||
) {
|
||||
//FormNewProduct(bicycleViewModel, navHostController)
|
||||
FormNewProduct(bicycleViewModel, navHostController)
|
||||
LazyColumn {
|
||||
itemsIndexed(bicycles) { index, item ->
|
||||
ListProduct(
|
||||
|
@ -28,7 +28,10 @@ import com.example.labwork.viewmodel.BicycleViewModel
|
||||
import kotlinx.coroutines.GlobalScope
|
||||
import kotlinx.coroutines.launch
|
||||
@Composable
|
||||
fun FormNewProduct(bicycleDao: BicycleDao, navHostController: NavHostController) {
|
||||
fun FormNewProduct(
|
||||
bicycleViewModel: BicycleViewModel,
|
||||
navHostController: NavHostController
|
||||
) {
|
||||
val isFormVisible = remember { mutableStateOf(false) }
|
||||
var brand by remember { mutableStateOf("") }
|
||||
var model by remember { mutableStateOf("") }
|
||||
@ -96,10 +99,8 @@ fun FormNewProduct(bicycleDao: BicycleDao, navHostController: NavHostController)
|
||||
.fillMaxWidth()
|
||||
.padding(9.dp),
|
||||
onClick = {
|
||||
GlobalScope.launch {
|
||||
val newBicycle = Bicycle(null, brand, model, color, null)
|
||||
bicycleDao.insertBicycle(newBicycle)
|
||||
}
|
||||
bicycleViewModel.insertBicycle(newBicycle)
|
||||
isFormVisible.value = false
|
||||
navHostController.navigate("ListProduct")
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user