Skip to content

Calculate a custom tip: Android Basics with Compose #344

@fvkontos

Description

@fvkontos

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?
6

Describe the problem
Minor issue but in the RoundTheTipRow function on switch you have this :
Switch(
modifier = modifier // Takes it from the parameter of the function
.fillMaxWidth()
.wrapContentWidth(Alignment.End),
checked = roundUp,
onCheckedChange = onRoundUpChanged,
)

The modifier should NOT be the same as the one in the row because it will have inconsistency with the rest of the composables items inside the row which may (or may not) have the same modifier (e.g. the Text on the specific composable). This means that the Text and the Switch in this case will have different height (something we don't want in this case). So instead of modifier use Modifier.

Steps to reproduce?
Run the app with the code provided at that point

Versions
Latest Android Studio version

Additional information
Added screenshots with normal Modifier and one from the parameter to show the difference.
Image
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions