Implement pull to refresh in GalleryCommentsScreen (#272)
* Use AndroidX snapshot builds * Implement pull to refresh in GalleryCommentsScreen * Don't use snapshot builds for other libraries
This commit is contained in:
1 parent
d0fe9fac8c
commit
941e7d18f3
6 files changed
+23
-6
No files matched your search
@@ -419,7 +419,7 @@ private fun SearchBarInputField(
|
||||
keyboardOptions = KeyboardOptions(imeAction = ImeAction.Search),
|
||||
keyboardActions = KeyboardActions(onSearch = { onSearch() }),
|
||||
interactionSource = interactionSource,
|
||||
decorationBox = @Composable { innerTextField ->
|
||||
decorator = @Composable { innerTextField ->
|
||||
TextFieldDefaults.DecorationBox(
|
||||
value = state.text.toString(),
|
||||
innerTextField = innerTextField,
|
||||
|
||||
@@ -17,8 +17,8 @@ import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.ElevatedCard
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.SecondaryTabRow
|
||||
import androidx.compose.material3.Tab
|
||||
import androidx.compose.material3.TabRow
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.windowsizeclass.WindowWidthSizeClass
|
||||
import androidx.compose.material3.windowsizeclass.calculateWindowSizeClass
|
||||
@@ -137,7 +137,7 @@ class SearchLayout @JvmOverloads constructor(
|
||||
}
|
||||
}
|
||||
}
|
||||
TabRow(
|
||||
SecondaryTabRow(
|
||||
selectedTabIndex = if (vm.isNormalMode) 0 else 1,
|
||||
divider = {},
|
||||
) {
|
||||
|
||||
@@ -59,6 +59,8 @@ import androidx.compose.material3.Text
|
||||
import androidx.compose.material3.TextButton
|
||||
import androidx.compose.material3.TopAppBar
|
||||
import androidx.compose.material3.TopAppBarDefaults
|
||||
import androidx.compose.material3.pulltorefresh.PullToRefreshContainer
|
||||
import androidx.compose.material3.pulltorefresh.rememberPullToRefreshState
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.CompositionLocalProvider
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
@@ -123,6 +125,7 @@ import com.hippo.ehviewer.util.findActivity
|
||||
import com.hippo.ehviewer.util.getParcelableCompat
|
||||
import com.ramcosta.composedestinations.annotation.Destination
|
||||
import eu.kanade.tachiyomi.util.lang.launchIO
|
||||
import eu.kanade.tachiyomi.util.lang.withIOContext
|
||||
import eu.kanade.tachiyomi.util.lang.withUIContext
|
||||
import eu.kanade.tachiyomi.util.system.logcat
|
||||
import kotlin.math.roundToInt
|
||||
@@ -300,7 +303,16 @@ fun GalleryCommentsScreen(galleryDetail: GalleryDetail, navigator: NavController
|
||||
) { paddingValues ->
|
||||
val keylineMargin = dimensionResource(id = R.dimen.keyline_margin)
|
||||
var editTextMeasured by remember { mutableStateOf(MinimumContentPaddingEditText) }
|
||||
Box(modifier = Modifier.fillMaxSize().imePadding()) {
|
||||
val refreshState = rememberPullToRefreshState()
|
||||
if (refreshState.isRefreshing) {
|
||||
LaunchedEffect(Unit) {
|
||||
runSuspendCatching {
|
||||
withIOContext { refreshComment(true) }
|
||||
}
|
||||
refreshState.endRefresh()
|
||||
}
|
||||
}
|
||||
Box(modifier = Modifier.fillMaxSize().imePadding().nestedScroll(refreshState.nestedScrollConnection)) {
|
||||
val additionalPadding = if (commenting) {
|
||||
editTextMeasured
|
||||
} else {
|
||||
@@ -419,6 +431,10 @@ fun GalleryCommentsScreen(galleryDetail: GalleryDetail, navigator: NavController
|
||||
}
|
||||
}
|
||||
}
|
||||
PullToRefreshContainer(
|
||||
state = refreshState,
|
||||
modifier = Modifier.align(Alignment.TopCenter).padding(top = paddingValues.calculateTopPadding()),
|
||||
)
|
||||
Surface(
|
||||
modifier = Modifier.align(Alignment.BottomCenter).layout { measurable, constraints ->
|
||||
val origin = measurable.measure(constraints)
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ fun CombinedCircularProgressIndicator(progress: Float) {
|
||||
label = "rotation",
|
||||
)
|
||||
CircularProgressIndicator(
|
||||
progress = animatedProgress,
|
||||
progress = { animatedProgress },
|
||||
modifier = Modifier.rotate(rotation),
|
||||
)
|
||||
}
|
||||
|
||||
@@ -84,7 +84,7 @@ compose-bom = { module = "dev.chrisbanes.compose:compose-bom", version.ref = "co
|
||||
# For renovate
|
||||
compose-compiler = { module = "androidx.compose.compiler:compiler", version.ref = "compose-compiler" }
|
||||
compose-material-icons-extended = { module = "androidx.compose.material:material-icons-extended" }
|
||||
compose-material3 = { module = "androidx.compose.material3:material3" }
|
||||
compose-material3 = { module = "androidx.compose.material3:material3", version = "1.2.0-SNAPSHOT" }
|
||||
compose-material3-windowsizeclass = { module = "androidx.compose.material3:material3-window-size-class" }
|
||||
compose-ui-util = { module = "androidx.compose.ui:ui-util" }
|
||||
compose-ui-viewbinding = { module = "androidx.compose.ui:ui-viewbinding" }
|
||||
|
||||
@@ -15,6 +15,7 @@ dependencyResolutionManagement {
|
||||
maven("https://jcenter.bintray.com")
|
||||
maven("https://jitpack.io")
|
||||
maven("https://androidx.dev/storage/compose-compiler/repository/")
|
||||
maven("https://androidx.dev/snapshots/builds/11101851/artifacts/repository")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user