mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 06:55:41 +00:00
Create a dummy value by default for LocalSnackbarDispatcher. (#715)
This should solve the issue with needing to provide a `LocalSnackbarDispatcher` for previews and screenshot tests.
This commit is contained in:
committed by
GitHub
parent
2ce614ae97
commit
679ee301dd
+1
-3
@@ -59,9 +59,7 @@ class SnackbarDispatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Used to provide a [SnackbarDispatcher] to composable functions, it's needed for [rememberSnackbarHostState]. */
|
/** Used to provide a [SnackbarDispatcher] to composable functions, it's needed for [rememberSnackbarHostState]. */
|
||||||
val LocalSnackbarDispatcher = compositionLocalOf<SnackbarDispatcher> {
|
val LocalSnackbarDispatcher = compositionLocalOf<SnackbarDispatcher> { SnackbarDispatcher() }
|
||||||
error("No SnackbarDispatcher provided")
|
|
||||||
}
|
|
||||||
|
|
||||||
@Composable
|
@Composable
|
||||||
fun SnackbarDispatcher.collectSnackbarMessageAsState(): State<SnackbarMessage?> {
|
fun SnackbarDispatcher.collectSnackbarMessageAsState(): State<SnackbarMessage?> {
|
||||||
|
|||||||
@@ -39,8 +39,6 @@ import com.android.ide.common.rendering.api.SessionParams
|
|||||||
import com.google.testing.junit.testparameterinjector.TestParameter
|
import com.google.testing.junit.testparameterinjector.TestParameter
|
||||||
import com.google.testing.junit.testparameterinjector.TestParameterInjector
|
import com.google.testing.junit.testparameterinjector.TestParameterInjector
|
||||||
import io.element.android.libraries.theme.ElementTheme
|
import io.element.android.libraries.theme.ElementTheme
|
||||||
import io.element.android.libraries.designsystem.utils.LocalSnackbarDispatcher
|
|
||||||
import io.element.android.libraries.designsystem.utils.SnackbarDispatcher
|
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
@@ -98,8 +96,6 @@ class ScreenshotTest {
|
|||||||
LocalConfiguration provides Configuration().apply {
|
LocalConfiguration provides Configuration().apply {
|
||||||
setLocales(LocaleList(localeStr.toLocale()))
|
setLocales(LocaleList(localeStr.toLocale()))
|
||||||
},
|
},
|
||||||
// Needed to display Snackbars and avoid crashes during screenshot tests
|
|
||||||
LocalSnackbarDispatcher provides SnackbarDispatcher(),
|
|
||||||
// Needed so that UI that uses it don't crash during screenshot tests
|
// Needed so that UI that uses it don't crash during screenshot tests
|
||||||
LocalOnBackPressedDispatcherOwner provides object : OnBackPressedDispatcherOwner {
|
LocalOnBackPressedDispatcherOwner provides object : OnBackPressedDispatcherOwner {
|
||||||
override val lifecycle: Lifecycle get() = lifecycleOwner.lifecycle
|
override val lifecycle: Lifecycle get() = lifecycleOwner.lifecycle
|
||||||
|
|||||||
Reference in New Issue
Block a user