File tree Expand file tree Collapse file tree 4 files changed +45
-1
lines changed
main/kotlin/com/w2sv/composed/extensions
test/kotlin/com/w2sv/composed Expand file tree Collapse file tree 4 files changed +45
-1
lines changed Original file line number Diff line number Diff line change 1- package com.w2sv.composed
1+ package com.w2sv.composed.extensions
22
33import androidx.compose.ui.Modifier
44
Original file line number Diff line number Diff line change 1+ package com.w2sv.composed.extensions
2+
3+ import androidx.compose.material3.SnackbarDuration
4+ import androidx.compose.material3.SnackbarHostState
5+ import androidx.compose.material3.SnackbarVisuals
6+
7+ /* *
8+ * Dismisses the currently showing snackbar if there is one and shows a new one with the given [snackbarVisuals].
9+ *
10+ * @see SnackbarHostState.showSnackbar
11+ */
12+ suspend fun SnackbarHostState.dismissCurrentSnackbarAndShow (snackbarVisuals : SnackbarVisuals ) {
13+ currentSnackbarData?.dismiss()
14+ showSnackbar(snackbarVisuals)
15+ }
16+
17+ /* *
18+ * Dismisses the currently showing snackbar if there is one and shows a new one with the given parameters.
19+ *
20+ * @see SnackbarHostState.showSnackbar
21+ */
22+ suspend fun SnackbarHostState.dismissCurrentSnackbarAndShow (
23+ message : String ,
24+ actionLabel : String? = null,
25+ withDismissAction : Boolean = false,
26+ duration : SnackbarDuration = if (actionLabel == null) SnackbarDuration .Short else SnackbarDuration .Indefinite
27+ ) {
28+ currentSnackbarData?.dismiss()
29+ showSnackbar(
30+ message = message,
31+ actionLabel = actionLabel,
32+ withDismissAction = withDismissAction,
33+ duration = duration
34+ )
35+ }
Original file line number Diff line number Diff line change 1+ package com.w2sv.composed.extensions
2+
3+ import android.animation.TimeInterpolator
4+ import androidx.compose.animation.core.Easing
5+
6+ fun TimeInterpolator.toEasing () = Easing {
7+ getInterpolation(it)
8+ }
Original file line number Diff line number Diff line change @@ -5,6 +5,7 @@ import androidx.compose.foundation.layout.padding
55import androidx.compose.ui.Modifier
66import androidx.compose.ui.graphics.Color
77import androidx.compose.ui.unit.dp
8+ import com.w2sv.composed.extensions.thenIf
89import junit.framework.TestCase.assertEquals
910import org.junit.Test
1011
You can’t perform that action at this time.
0 commit comments