google-developer-training / basic-android-kotlin-compose-training-tip-calculator

Apache License 2.0
61 stars 93 forks source link

Calculate a custom tip: Android Basics with Compose - Typo on modifier word -> change "modifier" into "Modifier" #174

Open fabiocarluccio opened 7 months ago

fabiocarluccio commented 7 months ago

URL of codelab https://developer.android.com/codelabs/basic-android-kotlin-compose-calculate-tip?continue=https%3A%2F%2Fdeveloper.android.com%2Fcourses%2Fpathways%2Fandroid-basics-compose-unit-2-pathway-3%23codelab-https%3A%2F%2Fdeveloper.android.com%2Fcodelabs%2Fbasic-android-kotlin-compose-calculate-tip#8

Describe the problem There is a typo on the code shown on this codelab. Instead of using Modifier, it uses modifier, which is wrong because it causes an additional padding of 32.dp under the switch by inheriting the parent's modifier. Note that the code provided on the GitHub repo (https://github.com/google-developer-training/basic-android-kotlin-compose-training-tip-calculator.git) uses in fact Modifier instead of modifier, which is right.

Solution Change this:

  1. In the Switch composable, add this modifier to align the Switch composable to the end of the screen:
       Switch(
           modifier = modifier
               .fillMaxWidth()
               .wrapContentWidth(Alignment.End),
           //...
       )

into this:

  1. In the Switch composable, add this modifier to align the Switch composable to the end of the screen:
       Switch(
           modifier = Modifier
               .fillMaxWidth()
               .wrapContentWidth(Alignment.End),
           //...
       )