From 74d1aeeccb7d53920809e3e026c5e2ee4f5cc534 Mon Sep 17 00:00:00 2001 From: ganfra Date: Fri, 23 Feb 2024 17:36:19 +0100 Subject: [PATCH] AttachmentsPreview: set zoomable state --- .../preview/AttachmentsPreviewView.kt | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/attachments/preview/AttachmentsPreviewView.kt b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/attachments/preview/AttachmentsPreviewView.kt index d0091ba496..e440a8a9cb 100644 --- a/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/attachments/preview/AttachmentsPreviewView.kt +++ b/features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/attachments/preview/AttachmentsPreviewView.kt @@ -44,7 +44,10 @@ import io.element.android.libraries.designsystem.preview.ElementPreviewDark import io.element.android.libraries.designsystem.theme.components.Scaffold import io.element.android.libraries.designsystem.theme.components.TextButton import io.element.android.libraries.mediaviewer.api.local.LocalMediaView +import io.element.android.libraries.mediaviewer.api.local.rememberLocalMediaViewState import io.element.android.libraries.ui.strings.CommonStrings +import me.saket.telephoto.zoomable.ZoomSpec +import me.saket.telephoto.zoomable.rememberZoomableState @Composable fun AttachmentsPreviewView( @@ -127,11 +130,19 @@ private fun AttachmentPreviewContent( contentAlignment = Alignment.Center ) { when (attachment) { - is Attachment.Media -> LocalMediaView( - modifier = Modifier.fillMaxSize(), - localMedia = attachment.localMedia, - onClick = {} - ) + is Attachment.Media -> { + val localMediaViewState = rememberLocalMediaViewState( + zoomableState = rememberZoomableState( + zoomSpec = ZoomSpec(maxZoomFactor = 4f, preventOverOrUnderZoom = false) + ) + ) + LocalMediaView( + modifier = Modifier.fillMaxSize(), + localMedia = attachment.localMedia, + localMediaViewState = localMediaViewState, + onClick = {} + ) + } } } AttachmentsPreviewBottomActions(