Android Programming: The Big Nerd Ranch Guide, 5th Edition
by Bryan Sills, Brian Gardner, Kristin Marsicano, Chris Stewart
Dismissing the Dialog
Whenever a dialog is part of your composition, it will be shown onscreen. You have not told your ToppingPlacementDialog when it should stop being displayed, so attempts to dismiss it will do nothing. And none of Compose’s dialog functions has a parameter to set the dialog’s visibility, so you will need another way to dismiss your dialog.
In Chapter 26, you made another UI element that was visible only some of the time: the placement label in your ToppingCell.
You use an if statement so that the Text composable is only invoked when you want it to be visible.
You will use the same approach to show and hide the dialog.
With the dialog’s visibility controlled by an if statement, the job of the onDismissRequest lambda ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access