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 - Step 6 #141

Closed shiv19 closed 12 months ago

shiv19 commented 12 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#5

In which task and step of the codelab can this issue be found? In the sub step number 8 image

Describe the problem The code uses the modifier with the small letter m. Which means the modifier that was passed to RoundTheTipRow composable is the same modifier that will be used for the switch. This should be changed to a new instance of the modifier. The code should be:

Switch(
            checked = roundUp,
            onCheckedChange = onRoundUpChanged,
            modifier = Modifier
                .fillMaxWidth()
                .wrapContentWidth(Alignment.End)
        )

Without this, when you follow sub step 11, and supply padding the RoundTheTipRow, you'll notice that the switch gets an unwanted padding because it uses the same modifier.

shiv19 commented 12 months ago

Closing this, because it is a duplicate of #137