From 5cb202912286957a78f41c0bcfbe32bda4d93c3a Mon Sep 17 00:00:00 2001 From: Ash Date: Fri, 12 Jul 2024 18:09:01 +0800 Subject: [PATCH] feat(ui): enhance ReaderImageViewer Interactive gestures --- .../reader/ui/page/home/reading/ReaderImagePage.kt | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/me/ash/reader/ui/page/home/reading/ReaderImagePage.kt b/app/src/main/java/me/ash/reader/ui/page/home/reading/ReaderImagePage.kt index 87e48a3f7..e28669eec 100644 --- a/app/src/main/java/me/ash/reader/ui/page/home/reading/ReaderImagePage.kt +++ b/app/src/main/java/me/ash/reader/ui/page/home/reading/ReaderImagePage.kt @@ -79,6 +79,8 @@ fun ReaderImageViewer( ).data(data = imageData.imageUrl).build() ) + var expanded by remember { mutableStateOf(false) } + LaunchedEffect(painter.intrinsicSize) { zoomableState.setContentLocation( ZoomableContentLocation.scaledInsideAndCenterAligned(painter.intrinsicSize) @@ -89,7 +91,13 @@ fun ReaderImageViewer( painter = painter, contentDescription = imageData.altText, modifier = Modifier - .zoomable(state = zoomableState, clipToBounds = true) + .zoomable(state = zoomableState, clipToBounds = true, + onClick = { + onDismissRequest() + }, + onLongClick = { + expanded = true + }) .fillMaxSize(), alignment = Alignment.Center, contentScale = ContentScale.Inside @@ -110,7 +118,7 @@ fun ReaderImageViewer( contentDescription = stringResource(id = R.string.close), ) } - var expanded by remember { mutableStateOf(false) } + IconButton( onClick = { expanded = true }, colors = IconButtonDefaults.iconButtonColors( containerColor = Color.Black.copy(alpha = 0.5f), contentColor = Color.White