diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/model/event/TimelineItemImageContentProvider.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/model/event/TimelineItemImageContentProvider.kt index 004bac390a..dbb32bbab2 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/model/event/TimelineItemImageContentProvider.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/model/event/TimelineItemImageContentProvider.kt @@ -19,6 +19,7 @@ package io.element.android.features.messages.impl.timeline.model.event import androidx.compose.ui.tooling.preview.PreviewParameterProvider import androidx.media3.common.MimeTypes import io.element.android.libraries.matrix.api.media.MediaSource +import io.element.android.libraries.matrix.ui.components.A_BLUR_HASH open class TimelineItemImageContentProvider : PreviewParameterProvider { override val values: Sequence @@ -34,7 +35,7 @@ fun aTimelineItemImageContent() = TimelineItemImageContent( mediaSource = MediaSource(""), thumbnailSource = null, mimeType = MimeTypes.IMAGE_JPEG, - blurhash = "TQF5:I_NtRE4kXt7Z#MwkCIARPjr", + blurhash = A_BLUR_HASH, width = null, height = 300, aspectRatio = 0.5f, diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/model/event/TimelineItemVideoContentProvider.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/model/event/TimelineItemVideoContentProvider.kt index 8310f4a99a..adff01bdc8 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/model/event/TimelineItemVideoContentProvider.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/model/event/TimelineItemVideoContentProvider.kt @@ -19,6 +19,7 @@ package io.element.android.features.messages.impl.timeline.model.event import androidx.compose.ui.tooling.preview.PreviewParameterProvider import io.element.android.libraries.core.mimetype.MimeTypes import io.element.android.libraries.matrix.api.media.MediaSource +import io.element.android.libraries.matrix.ui.components.A_BLUR_HASH open class TimelineItemVideoContentProvider : PreviewParameterProvider { override val values: Sequence @@ -32,7 +33,7 @@ open class TimelineItemVideoContentProvider : PreviewParameterProvider { - PinIcon( - modifier = Modifier.fillMaxSize() + Icon( + resourceId = R.drawable.ic_september_location, + contentDescription = info.textContent, ) } } @@ -125,3 +132,14 @@ data class AttachmentThumbnailInfo( val textContent: String? = null, val blurHash: String? = null, ) : Parcelable + +@PreviewsDayNight +@Composable +internal fun AttachmentThumbnailPreview(@PreviewParameter(AttachmentThumbnailInfoProvider::class) data: AttachmentThumbnailInfo) = ElementPreview { + AttachmentThumbnail( + data, + modifier = Modifier + .size(36.dp) + .clip(RoundedCornerShape(4.dp)) + ) +} diff --git a/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/components/AttachmentThumbnailProvider.kt b/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/components/AttachmentThumbnailProvider.kt new file mode 100644 index 0000000000..83d1a84973 --- /dev/null +++ b/libraries/matrixui/src/main/kotlin/io/element/android/libraries/matrix/ui/components/AttachmentThumbnailProvider.kt @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2023 New Vector Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.element.android.libraries.matrix.ui.components + +import androidx.compose.ui.tooling.preview.PreviewParameterProvider +import io.element.android.libraries.matrix.api.media.MediaSource + +open class AttachmentThumbnailInfoProvider : PreviewParameterProvider { + override val values: Sequence + get() = sequenceOf( + anAttachmentThumbnailInfo(type = AttachmentThumbnailType.Image), + anAttachmentThumbnailInfo(type = AttachmentThumbnailType.Image, blurHash = A_BLUR_HASH), + anAttachmentThumbnailInfo(type = AttachmentThumbnailType.Video), + anAttachmentThumbnailInfo(type = AttachmentThumbnailType.Video, blurHash = A_BLUR_HASH), + anAttachmentThumbnailInfo(type = AttachmentThumbnailType.Audio), + anAttachmentThumbnailInfo(type = AttachmentThumbnailType.File), + anAttachmentThumbnailInfo(type = AttachmentThumbnailType.Location), + anAttachmentThumbnailInfo(type = AttachmentThumbnailType.Voice), + ) +} + +fun anAttachmentThumbnailInfo( + type: AttachmentThumbnailType, + thumbnailSource: MediaSource? = null, + textContent: String? = null, + blurHash: String? = null, +) = + AttachmentThumbnailInfo( + type = type, + thumbnailSource = thumbnailSource, + textContent = textContent, + blurHash = blurHash, + ) + +const val A_BLUR_HASH = "TQF5:I_NtRE4kXt7Z#MwkCIARPjr" diff --git a/libraries/textcomposer/impl/src/main/kotlin/io/element/android/libraries/textcomposer/TextComposer.kt b/libraries/textcomposer/impl/src/main/kotlin/io/element/android/libraries/textcomposer/TextComposer.kt index 4e383dbfda..fef9d40a5b 100644 --- a/libraries/textcomposer/impl/src/main/kotlin/io/element/android/libraries/textcomposer/TextComposer.kt +++ b/libraries/textcomposer/impl/src/main/kotlin/io/element/android/libraries/textcomposer/TextComposer.kt @@ -58,6 +58,7 @@ import io.element.android.libraries.designsystem.utils.CommonDrawables import io.element.android.libraries.matrix.api.core.EventId import io.element.android.libraries.matrix.api.core.TransactionId import io.element.android.libraries.matrix.api.media.MediaSource +import io.element.android.libraries.matrix.ui.components.A_BLUR_HASH import io.element.android.libraries.matrix.ui.components.AttachmentThumbnail import io.element.android.libraries.matrix.ui.components.AttachmentThumbnailInfo import io.element.android.libraries.matrix.ui.components.AttachmentThumbnailType @@ -720,7 +721,7 @@ internal fun TextComposerReplyPreview() = ElementPreview { thumbnailSource = MediaSource("https://domain.com/image.jpg"), textContent = "image.jpg", type = AttachmentThumbnailType.Image, - blurHash = "TQF5:I_NtRE4kXt7Z#MwkCIARPjr", + blurHash = A_BLUR_HASH, ), defaultContent = "image.jpg" ), @@ -741,7 +742,7 @@ internal fun TextComposerReplyPreview() = ElementPreview { thumbnailSource = MediaSource("https://domain.com/video.mp4"), textContent = "video.mp4", type = AttachmentThumbnailType.Video, - blurHash = "TQF5:I_NtRE4kXt7Z#MwkCIARPjr", + blurHash = A_BLUR_HASH, ), defaultContent = "video.mp4" ),