Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Image zooming feature #545

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,6 @@ dependencies {
androidTestImplementation "androidx.test.ext:junit:1.1.3"
androidTestImplementation "androidx.test.espresso:espresso-core:3.4.0"

// https://github.com/usuiat/Zoomable
implementation "net.engawapg.lib:zoomable:1.5.3"
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ import org.jsoup.nodes.TextNode
import java.io.InputStream
import kotlin.math.abs
import kotlin.math.roundToInt
import net.engawapg.lib.zoomable.rememberZoomState
import net.engawapg.lib.zoomable.toggleScale
import net.engawapg.lib.zoomable.zoomable

fun LazyListScope.htmlFormattedText(
inputStream: InputStream,
Expand Down Expand Up @@ -497,13 +500,21 @@ private fun TextComposer.appendTextChildren(
// }
) {
val imageSize = maxImageSize()
val zoomState = rememberZoomState()
val targetScale = 1.75f
RYAsyncImage(
modifier = Modifier
.align(Alignment.Center)
.fillMaxWidth()
.padding(horizontal = imageHorizontalPadding().dp)
.clip(imageShape())
.clickable { },
.clickable { }
.zoomable(
zoomState = zoomState,
onDoubleTap = {
position -> zoomState.toggleScale(targetScale, position)
}
),
data = imageCandidates.getBestImageForMaxSize(
pixelDensity = pixelDensity(),
maxSize = imageSize,
Expand Down
Loading