mirror of https://github.com/Ashinch/ReadYou.git
fix(ui): webview renderer nested scrolling (#847)
This commit is contained in:
parent
5eb0edcc78
commit
438cee5694
|
@ -4,6 +4,7 @@ import androidx.compose.foundation.layout.Column
|
|||
import androidx.compose.foundation.layout.Spacer
|
||||
import androidx.compose.foundation.layout.WindowInsets
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.height
|
||||
import androidx.compose.foundation.layout.navigationBars
|
||||
import androidx.compose.foundation.layout.padding
|
||||
|
@ -11,13 +12,17 @@ import androidx.compose.foundation.layout.size
|
|||
import androidx.compose.foundation.layout.windowInsetsBottomHeight
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.LazyListState
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.text.selection.DisableSelection
|
||||
import androidx.compose.foundation.text.selection.SelectionContainer
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.CircularProgressIndicator
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.input.nestedscroll.nestedScroll
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.rememberNestedScrollInteropConnection
|
||||
import androidx.compose.ui.unit.dp
|
||||
import me.ash.reader.infrastructure.preference.LocalOpenLink
|
||||
import me.ash.reader.infrastructure.preference.LocalOpenLinkSpecificBrowser
|
||||
|
@ -60,47 +65,74 @@ fun Content(
|
|||
}
|
||||
} else {
|
||||
|
||||
SelectionContainer {
|
||||
LazyColumn(
|
||||
modifier = modifier
|
||||
.fillMaxSize()
|
||||
.drawVerticalScrollbar(listState),
|
||||
state = listState,
|
||||
) {
|
||||
item {
|
||||
// Top bar height
|
||||
Spacer(modifier = Modifier.height(64.dp))
|
||||
// padding
|
||||
Spacer(modifier = Modifier.height(22.dp))
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 12.dp)
|
||||
) {
|
||||
DisableSelection {
|
||||
Metadata(
|
||||
feedName = feedName,
|
||||
title = title,
|
||||
author = author,
|
||||
link = link,
|
||||
publishedDate = publishedDate,
|
||||
)
|
||||
when (renderer) {
|
||||
ReadingRendererPreference.WebView -> {
|
||||
Column(modifier = modifier) {
|
||||
Column(modifier = Modifier.verticalScroll(rememberScrollState())) {
|
||||
// Top bar height
|
||||
Spacer(modifier = Modifier.height(64.dp))
|
||||
// padding
|
||||
Spacer(modifier = Modifier.height(22.dp))
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 12.dp)
|
||||
) {
|
||||
DisableSelection {
|
||||
Metadata(
|
||||
feedName = feedName,
|
||||
title = title,
|
||||
author = author,
|
||||
link = link,
|
||||
publishedDate = publishedDate,
|
||||
)
|
||||
}
|
||||
}
|
||||
Spacer(modifier = Modifier.height(22.dp))
|
||||
|
||||
RYWebView(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
content = content,
|
||||
refererDomain = link.extractDomain(),
|
||||
onImageClick = onImageClick,
|
||||
)
|
||||
Spacer(modifier = Modifier.height(128.dp))
|
||||
Spacer(modifier = Modifier.windowInsetsBottomHeight(WindowInsets.navigationBars))
|
||||
|
||||
}
|
||||
Spacer(modifier = Modifier.height(22.dp))
|
||||
}
|
||||
|
||||
when (renderer) {
|
||||
ReadingRendererPreference.WebView -> {
|
||||
item {
|
||||
RYWebView(
|
||||
content = content,
|
||||
refererDomain = link.extractDomain(),
|
||||
onImageClick = onImageClick,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ReadingRendererPreference.NativeComponent -> {
|
||||
SelectionContainer {
|
||||
LazyColumn(
|
||||
modifier = modifier
|
||||
.fillMaxSize()
|
||||
.drawVerticalScrollbar(listState),
|
||||
state = listState,
|
||||
) {
|
||||
item {
|
||||
// Top bar height
|
||||
Spacer(modifier = Modifier.height(64.dp))
|
||||
// padding
|
||||
Spacer(modifier = Modifier.height(22.dp))
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.padding(horizontal = 12.dp)
|
||||
) {
|
||||
DisableSelection {
|
||||
Metadata(
|
||||
feedName = feedName,
|
||||
title = title,
|
||||
author = author,
|
||||
link = link,
|
||||
publishedDate = publishedDate,
|
||||
)
|
||||
}
|
||||
}
|
||||
Spacer(modifier = Modifier.height(22.dp))
|
||||
}
|
||||
|
||||
ReadingRendererPreference.NativeComponent -> {
|
||||
Reader(
|
||||
context = context,
|
||||
subheadUpperCase = subheadUpperCase.value,
|
||||
|
@ -111,14 +143,16 @@ fun Content(
|
|||
context.openURL(it, openLink, openLinkSpecificBrowser)
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
item {
|
||||
Spacer(modifier = Modifier.height(128.dp))
|
||||
Spacer(modifier = Modifier.windowInsetsBottomHeight(WindowInsets.navigationBars))
|
||||
item {
|
||||
Spacer(modifier = Modifier.height(128.dp))
|
||||
Spacer(modifier = Modifier.windowInsetsBottomHeight(WindowInsets.navigationBars))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -65,7 +65,7 @@ private class ReaderNestedScrollConnection(
|
|||
!enabled || available.y == 0f -> Offset.Zero
|
||||
|
||||
// Scroll down to reduce the progress when the offset is currently pulled up, same for the opposite
|
||||
source == Drag -> {
|
||||
source == NestedScrollSource.UserInput -> {
|
||||
Offset(0f, onPreScroll(available.y))
|
||||
}
|
||||
|
||||
|
@ -78,7 +78,7 @@ private class ReaderNestedScrollConnection(
|
|||
consumed: Offset, available: Offset, source: NestedScrollSource
|
||||
): Offset = when {
|
||||
!enabled -> Offset.Zero
|
||||
source == Drag -> Offset(0f, onPostScroll(available.y)) // Pull to load
|
||||
source == NestedScrollSource.UserInput -> Offset(0f, onPostScroll(available.y)) // Pull to load
|
||||
else -> Offset.Zero
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue