In this example, we create a TopAppBar that has an action icon button that, when clicked, sets a showDialog boolean to true. We also have a MyDialog composable that displays an AlertDialog with an "OK" button that dismisses the dialog.
Inside the actions parameter of the TopAppBar, we check if showDialog is true and if so, we display the MyDialog composable by passing in an onDismiss lambda that sets showDialog to false when the dialog is dismissed or the "OK" button is clicked.
Note that we use remember { mutableStateOf(false) } to create a showDialog state that can be updated by clicking the action icon button and dismissed by clicking the "OK" button in the dialog.