Which is the better own dialog component in Jetpac...
# compose
s
Which is the better own dialog component in Jetpack Compose?
z
What do the button functions in the first case do if they're not composable?
s
here is first case full code.
second case
Since the dismiss button may not be displayed, null can be passed.
o
imo, the 2nd case doesn’t seem to make a big difference from just using an AlertDialog directly. If you want to abstract the composables used internally inside your SimpleAlertDialog, the 1st case looks preferable. I recently created a similar dialog wrapper where callers pass a DialogButton object that contains the text & callback values. Here’s a gist: https://gist.github.com/omar-leyva/72b2d176cfc44cd99694adc8ccac0504
s
I’m wondering if I should always use the Slot API Pattern for my components. https://chris.banes.dev/slotting-in-with-compose-ui/
I think the first case is easy to use but, not flexible. As you said, 2nd case is not a big different from just using an AlertDialog.
IMO: Slot API Pattern is better for reusable generic layouts. This is not the right choice for some UI parts. In this case, depending on whether the dialog is a reusable general layout or a UI part. Our team will consider Dialog as a UI part. Therefore, the first case is better.