Decathlon / vitamin-compose

Decathlon Design System UI components for Compose applications
https://www.decathlon.design
Apache License 2.0
268 stars 29 forks source link

VitaminSnackbars don't disappear automatically after a set of time #136

Closed tlevavasseur-decathlon closed 1 year ago

tlevavasseur-decathlon commented 1 year ago

Describe the bug

VitaminSnackbars don't disappear automatically after a set of time.

Multiple Snackbar Only one snackbar may be displayed at a time. If multiple snackbars need to appear, the new one replaced the previous one. The snackbar can disappear automatically after a set of time or can be dismissed by the user.

https://www.decathlon.design/726f8c765/p/798580-snackbar/b/81bb90

Expected behavior

An option to enable auto disappearance (and eventually a customisable delay) or at least a sample of how to do it.

ManonPolle commented 1 year ago

Vitamin provide a visual for the Snackbar. It is when you implement it and display it that you can set a duration, with a custom SnackbarHost

SnackbarHost(snackbarHostState) { snackbarData-> 
             Box(modifier = Modifier.padding(4.dp)) {
                VitaminSnackbars.Primary(text = snackbarData.message)
            }
        }

and then

coroutineScope.launch {
                        snackbarHostState.showSnackbar(
                            message = "Description of the snackbar",
                            actionLabel = null,
                            duration = SnackbarDuration.Short,
                        )
                    }

I close this issue as it is not Vitamin responsability but feel free to reach out to me if needed