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 #81

Open LifeIsALesson opened 8 months ago

LifeIsALesson commented 8 months ago

URL of codelab: https://developer.android.com/codelabs/basic-android-kotlin-compose-update-data-room?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fandroid-basics-compose-unit-6-pathway-2%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fbasic-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?

Describe the problem Step 13 in [Read and update data with Room] > (8.) Implement sell item > Add a function in the ViewModel is missing a modification to work as described.

The enabled attribute of the "Sell"-Button in the starter code is set to trueand was not changed in the codelab.

Following adaption needs to be made:

Button(
            onClick = onSellItem,
            modifier = Modifier.fillMaxWidth(),
            shape = MaterialTheme.shapes.small,
            enabled = **!itemDetailsUiState.outOfStock**
// ...

This modification was made in the final code (main branch) in the GitHub repo, but is missing as a step in the codelab starting from the starter code.

Steps to reproduce?

  1. Go to...

Follow the steps in the codelab so far

  1. Click on...

Run the app, Click on the "Sell"-button that never gets disabled

  1. See error...

Not as described in the codelab: "Notice that the app disables the Sell button when the quantity in stock is zero."

Versions Android Studio version: API version of the emulator:

Additional information Include screenshots if they would be useful in clarifying the problem.