mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:32:34 +00:00
Fix broken preview of BottomSheet in Android Studio.
This commit is contained in:
+1
-1
@@ -216,7 +216,7 @@ private fun RoomListModalBottomSheetContent(
|
||||
@Composable
|
||||
internal fun RoomListContextMenuPreview(
|
||||
@PreviewParameter(RoomListStateContextMenuShownProvider::class) contextMenu: RoomListState.ContextMenu.Shown
|
||||
) = ElementPreview {
|
||||
) = ElementPreview(fillMaxSize = true) {
|
||||
RoomListContextMenu(
|
||||
contextMenu = contextMenu,
|
||||
canReportRoom = true,
|
||||
|
||||
+1
-1
@@ -188,6 +188,6 @@ private fun SpaceFilterItem(
|
||||
|
||||
@PreviewsDayNight
|
||||
@Composable
|
||||
internal fun SpaceFiltersViewPreview(@PreviewParameter(SpaceFiltersStateProvider::class) state: SpaceFiltersState) = ElementPreview {
|
||||
internal fun SpaceFiltersViewPreview(@PreviewParameter(SpaceFiltersStateProvider::class) state: SpaceFiltersState) = ElementPreview(fillMaxSize = true) {
|
||||
SpaceFiltersView(state = state)
|
||||
}
|
||||
|
||||
+3
-2
@@ -153,10 +153,11 @@ private fun AttachmentSourcePickerMenu(
|
||||
|
||||
@PreviewsDayNight
|
||||
@Composable
|
||||
internal fun AttachmentSourcePickerMenuPreview() = ElementPreview {
|
||||
AttachmentSourcePickerMenu(
|
||||
internal fun AttachmentSourcePickerMenuPreview() = ElementPreview(fillMaxSize = true) {
|
||||
AttachmentsBottomSheet(
|
||||
state = aMessageComposerState(
|
||||
canShareLocation = true,
|
||||
showAttachmentSourcePicker = true,
|
||||
),
|
||||
onSendLocationClick = {},
|
||||
onCreatePollClick = {},
|
||||
|
||||
+3
-4
@@ -9,7 +9,6 @@
|
||||
package io.element.android.features.messages.impl.timeline.components.receipt.bottomsheet
|
||||
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
@@ -118,9 +117,9 @@ private fun ReadReceiptBottomSheetContent(
|
||||
|
||||
@PreviewsDayNight
|
||||
@Composable
|
||||
internal fun ReadReceiptBottomSheetPreview(@PreviewParameter(ReadReceiptBottomSheetStateProvider::class) state: ReadReceiptBottomSheetState) = ElementPreview {
|
||||
Column {
|
||||
ReadReceiptBottomSheetContent(
|
||||
internal fun ReadReceiptBottomSheetPreview(@PreviewParameter(ReadReceiptBottomSheetStateProvider::class) state: ReadReceiptBottomSheetState) {
|
||||
ElementPreview(fillMaxSize = true) {
|
||||
ReadReceiptBottomSheet(
|
||||
state = state,
|
||||
onUserDataClick = {},
|
||||
)
|
||||
|
||||
+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()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -115,7 +115,7 @@ private fun AvatarActionBottomSheetContent(
|
||||
|
||||
@PreviewsDayNight
|
||||
@Composable
|
||||
internal fun AvatarActionBottomSheetPreview() = ElementPreview {
|
||||
internal fun AvatarActionBottomSheetPreview() = ElementPreview(fillMaxSize = true) {
|
||||
AvatarActionBottomSheet(
|
||||
actions = persistentListOf(AvatarAction.TakePhoto, AvatarAction.ChoosePhoto, AvatarAction.Remove),
|
||||
isVisible = true,
|
||||
|
||||
+1
-1
@@ -160,7 +160,7 @@ internal fun CreateDmConfirmationBottomSheetPreview(
|
||||
@PreviewParameter(
|
||||
CreateDmConfirmationBottomSheetStateProvider::class
|
||||
) state: CreateDmConfirmationBottomSheetState
|
||||
) = ElementPreview {
|
||||
) = ElementPreview(fillMaxSize = true) {
|
||||
CreateDmConfirmationBottomSheet(
|
||||
matrixUser = state.matrixUser,
|
||||
isUserIdentityUnknown = state.isUserIdentityUnknown,
|
||||
|
||||
+1
-1
@@ -169,7 +169,7 @@ private fun MediaRow(
|
||||
@Composable
|
||||
internal fun MediaDeleteConfirmationBottomSheetPreview(
|
||||
@PreviewParameter(provider = MediaBottomSheetStateDeleteConfirmationProvider::class) state: MediaBottomSheetState.DeleteConfirmation,
|
||||
) = ElementPreview {
|
||||
) = ElementPreview(fillMaxSize = true) {
|
||||
MediaDeleteConfirmationBottomSheet(
|
||||
state = state,
|
||||
onDelete = {},
|
||||
|
||||
+1
-1
@@ -267,7 +267,7 @@ private fun SectionText(
|
||||
@Composable
|
||||
internal fun MediaDetailsBottomSheetPreview(
|
||||
@PreviewParameter(MediaBottomSheetStateDetailsProvider::class) state: MediaBottomSheetState.Details,
|
||||
) = ElementPreview {
|
||||
) = ElementPreview(fillMaxSize = true) {
|
||||
MediaDetailsBottomSheet(
|
||||
state = state,
|
||||
onViewInTimeline = {},
|
||||
|
||||
+1
-1
@@ -71,7 +71,7 @@ fun CaptionWarningBottomSheet(
|
||||
|
||||
@PreviewsDayNight
|
||||
@Composable
|
||||
internal fun CaptionWarningBottomSheetPreview() = ElementPreview {
|
||||
internal fun CaptionWarningBottomSheetPreview() = ElementPreview(fillMaxSize = true) {
|
||||
CaptionWarningBottomSheet(
|
||||
onDismiss = {},
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user