google-developer-training / basic-android-kotlin-compose-training-inventory-app

Apache License 2.0
77 stars 84 forks source link

Read and update data using Room #132

Closed StarSein closed 2 months ago

StarSein commented 2 months ago

URL of codelab: https://developer.android.com/codelabs/basic-android-kotlin-compose-update-data-room#7

Specify the language of the codelab if it is not English:

In which task and step of the codelab can this issue be found?

  1. Implement sell item Task: Add a function in the ViewModel Step: 13. Run your app. Notice that the app disables the Sell button when the quantity in stock is zero.

Describe the problem I have followed the instruction and run my app. But the Sell button didn't get disabled when the quantity in stock was zero. Another step is missing in the codelab script.

One more task that should be added next to the step 12 is below. Go back to ItemDetailsScreen.kt. In the ItemDetailsBody composable, set the parameter named 'enabled' of the Button composable as !itemDetailsUiState.outOfStock.

Additional information [Before] Button( onClick = onSellItem, modifier = Modifier.fillMaxWidth(), shape = MaterialTheme.shapes.small, enabled = true ) { Text(stringResource(R.string.sell)) }

[After] Button( onClick = onSellItem, modifier = Modifier.fillMaxWidth(), shape = MaterialTheme.shapes.small, enabled = !itemDetailsUiState.outOfStock ) { Text(stringResource(R.string.sell)) }

StarSein commented 2 months ago

Same issue was in https://github.com/google-developer-training/basic-android-kotlin-compose-training-inventory-app/issues/113

Sorry for making duplicate.