Skip to content

Commit

Permalink
Skip beyondViewportPageCount in viewer
Browse files Browse the repository at this point in the history
The right-hand side of the viewer sometimes cuts off
when paging. This could be due to rendering off the page
and rerendering after scroll.
  • Loading branch information
jocmp committed Feb 6, 2025
1 parent 925778a commit 35a7da7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.PaddingValues
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentHeight
import androidx.compose.foundation.pager.HorizontalPager
import androidx.compose.foundation.pager.rememberPagerState
import androidx.compose.material.icons.Icons
Expand Down Expand Up @@ -123,7 +125,9 @@ fun ArticleView(
) {
HorizontalPager(
state = pagerState,
beyondViewportPageCount = 1,
modifier = Modifier
.fillMaxWidth()
.wrapContentHeight()
) { page ->
articles.find(page)?.let { pagedArticle ->
ArticleReader(
Expand Down
23 changes: 0 additions & 23 deletions app/src/main/java/com/capyreader/app/ui/components/WebView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ package com.capyreader.app.ui.components

import android.annotation.SuppressLint
import android.graphics.Bitmap
import android.view.View
import android.webkit.WebResourceRequest
import android.webkit.WebResourceResponse
import android.webkit.WebView
import android.webkit.WebView.VisualStateCallback
import android.webkit.WebViewClient
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.wrapContentHeight
Expand Down Expand Up @@ -70,16 +68,6 @@ class AccompanistWebViewClient(

private val appPreferences by inject<AppPreferences>()

override fun onPageStarted(view: WebView, url: String?, favicon: Bitmap?) {
super.onPageStarted(view, url, favicon)

view.postVisualStateCallback(0, object : VisualStateCallback() {
override fun onComplete(requestId: Long) {
view.visibility = View.VISIBLE
}
})
}

override fun shouldInterceptRequest(
view: WebView,
request: WebResourceRequest
Expand Down Expand Up @@ -133,21 +121,11 @@ class WebViewState(
private val scope: CoroutineScope,
internal val webView: WebView,
) {
private var htmlId: String? = null

init {
loadEmpty()
}

fun loadHtml(article: Article, showImages: Boolean) {
val id = article.id

if (htmlId == null || id != htmlId) {
webView.visibility = View.INVISIBLE
}

htmlId = id

scope.launch {
withContext(Dispatchers.IO) {
val html = renderer.render(
Expand All @@ -171,7 +149,6 @@ class WebViewState(
}

fun reset() {
htmlId = null
loadEmpty()
}

Expand Down
10 changes: 5 additions & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@ ksp = "2.0.21-1.0.26"
androidx-lifecycle-runtime = "2.8.7"
androidx-adaptive = "1.1.0-alpha08"
mockk = "1.13.12"
navigation-compose = "2.8.5"
navigation-compose = "2.8.6"
okhttp = "4.12.0"
retrofit = "2.11.0"
paging-compose = "3.3.5"
sqldelight = "2.0.2"
zoomable = "0.12.1"

[libraries]
androidx-activity-compose = { module = "androidx.activity:activity-compose", version = "1.9.3" }
androidx-activity-compose = { module = "androidx.activity:activity-compose", version = "1.10.0" }
androidx-adaptive = { module = "androidx.compose.material3.adaptive:adaptive", version.ref = "androidx-adaptive" }
androidx-adaptive-layout = { module = "androidx.compose.material3.adaptive:adaptive-layout", version.ref = "androidx-adaptive" }
androidx-adaptive-navigation = { module = "androidx.compose.material3.adaptive:adaptive-navigation", version.ref = "androidx-adaptive" }
androidx-browser = { module = "androidx.browser:browser", version = "1.8.0" }
androidx-compose-bom = { module = "androidx.compose:compose-bom", version = "2024.12.01" }
androidx-compose-bom = { module = "androidx.compose:compose-bom", version = "2025.01.01" }
androidx-core-ktx = { module = "androidx.core:core-ktx", version = "1.15.0" }
androidx-lifecycle-runtime-compose = { module = "androidx.lifecycle:lifecycle-runtime-compose", version.ref = "androidx-lifecycle-runtime" }
androidx-lifecycle-runtime-ktx = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "androidx-lifecycle-runtime" }
Expand All @@ -42,7 +42,7 @@ coil-compose = { module = "io.coil-kt:coil-compose", version.ref = "coil" }
coil-gif = { module = "io.coil-kt:coil-gif", version.ref = "coil" }
coil-svg = { module = "io.coil-kt:coil-svg", version.ref = "coil" }
converter-scalars = { module = "com.squareup.retrofit2:converter-scalars", version.ref = "retrofit" }
firebase-crashlytics = { module = "com.google.firebase:firebase-crashlytics", version = "19.3.0" }
firebase-crashlytics = { module = "com.google.firebase:firebase-crashlytics", version = "19.4.0" }
jsoup = { module = "org.jsoup:jsoup", version = "1.17.1" }
koin-android = { module = "io.insert-koin:koin-android" }
koin-androidx-compose = { module = "io.insert-koin:koin-androidx-compose" }
Expand All @@ -54,7 +54,7 @@ kotlinx-coroutines-core = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-c
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version = "1.6.3" }
lazycolumnscrollbar = { module = "com.github.nanihadesuka:LazyColumnScrollbar", version = "2.2.0" }
moshi = { module = "com.squareup.moshi:moshi", version = "1.15.1" }
moshi-converter = { module = "com.squareup.retrofit2:converter-moshi", version = "2.9.0" }
moshi-converter = { module = "com.squareup.retrofit2:converter-moshi", version = "2.11.0" }
moshi-kotlin-codegen = { module = "com.squareup.moshi:moshi-kotlin-codegen", version = "1.14.0" }
okhttp-brotli = { module = "com.squareup.okhttp3:okhttp-brotli", version.ref = "okhttp" }
okhttp-client = { module = "com.squareup.okhttp3:okhttp", version.ref = "okhttp" }
Expand Down

0 comments on commit 35a7da7

Please sign in to comment.