google-developer-training/basic-android-kotlin-compose-training-cupcake

Navigate between screens with Compose: Android Basics with Compose

onions41 opened this issue · 1 comments

Step 7 should use context instead of stringResource() to retrieve the string resource in order to be consistent.

Step 7 instructs to use stringResouce(). However, step 6 sets up to use context, and step 8 shows that context was indeed used, not stringResource(). So, step 7 should be fixed to:

  1. The flavor screen gets the list of flavors from the app's string resources. Create a list of strings from the flavors list in the view model. You can transform the list of resource IDs into a list of strings using the map() function and calling context.resources.getString(id).
composable(route = CupcakeScreen.Flavor.name) {
    val context = LocalContext.current
    SelectOptionScreen(
        subtotal = uiState.price,
        options = flavors.map { id -> context.resources.getString(id) }
    )
}

Hello @onions41,

Thanks for reaching out and sharing your feedback. The step 7 is updated:

Screenshot 2023-01-09 at 11 48 17 AM