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