mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-03 06:55:41 +00:00
Fix broken preview of BottomSheet in Android Studio.
This commit is contained in:
+1
-1
@@ -65,7 +65,7 @@ fun SimpleModalBottomSheet(
|
||||
|
||||
@PreviewsDayNight
|
||||
@Composable
|
||||
internal fun SimpleModalBottomSheetPreview() = ElementPreview {
|
||||
internal fun SimpleModalBottomSheetPreview() = ElementPreview(fillMaxSize = true) {
|
||||
SimpleModalBottomSheet(title = "A title", onDismiss = {}) {
|
||||
Text(
|
||||
text = LoremIpsum(20).values.first(),
|
||||
|
||||
+15
-2
@@ -10,8 +10,11 @@ package io.element.android.libraries.designsystem.preview
|
||||
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import coil3.annotation.ExperimentalCoilApi
|
||||
@@ -29,6 +32,7 @@ import io.element.android.libraries.designsystem.utils.CommonDrawables
|
||||
fun ElementPreview(
|
||||
theme: Theme = if (isSystemInDarkTheme()) Theme.Dark else Theme.Light,
|
||||
showBackground: Boolean = true,
|
||||
fillMaxSize: Boolean = false,
|
||||
@DrawableRes
|
||||
drawableFallbackForImages: Int = CommonDrawables.sample_background,
|
||||
content: @Composable () -> Unit
|
||||
@@ -42,9 +46,18 @@ fun ElementPreview(
|
||||
ElementTheme(theme = theme) {
|
||||
if (showBackground) {
|
||||
// If we have a proper contentColor applied we need a Surface instead of a Box
|
||||
Surface(content = content)
|
||||
Surface(
|
||||
modifier = if (fillMaxSize) Modifier.fillMaxSize() else Modifier,
|
||||
content = content,
|
||||
)
|
||||
} else {
|
||||
content()
|
||||
if (fillMaxSize) {
|
||||
Box(modifier = Modifier.fillMaxSize()) {
|
||||
content()
|
||||
}
|
||||
} else {
|
||||
content()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user