From f90e1b935cf2714025facb5d08aa52e9d827e74b Mon Sep 17 00:00:00 2001 From: arkon Date: Fri, 29 Jul 2022 23:13:40 -0400 Subject: [PATCH] Bump dependencies --- .../kanade/presentation/components/Button.kt | 5 +- .../kanade/presentation/components/Surface.kt | 4 +- .../util/TopAppBarScrollBehavior.kt | 158 ------------------ gradle/androidx.versions.toml | 2 +- gradle/compose.versions.toml | 10 +- 5 files changed, 10 insertions(+), 169 deletions(-) delete mode 100644 app/src/main/java/eu/kanade/presentation/util/TopAppBarScrollBehavior.kt diff --git a/app/src/main/java/eu/kanade/presentation/components/Button.kt b/app/src/main/java/eu/kanade/presentation/components/Button.kt index b1472ae32..e8edba9e6 100644 --- a/app/src/main/java/eu/kanade/presentation/components/Button.kt +++ b/app/src/main/java/eu/kanade/presentation/components/Button.kt @@ -14,7 +14,6 @@ import androidx.compose.material3.ButtonElevation import androidx.compose.material3.LocalContentColor import androidx.compose.material3.MaterialTheme import androidx.compose.material3.ProvideTextStyle -import androidx.compose.material3.Shapes import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider import androidx.compose.runtime.remember @@ -31,7 +30,7 @@ fun TextButton( enabled: Boolean = true, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, elevation: ButtonElevation? = null, - shape: Shape = Shapes.Full, + shape: Shape = ButtonDefaults.textShape, border: BorderStroke? = null, colors: ButtonColors = ButtonDefaults.textButtonColors(), contentPadding: PaddingValues = ButtonDefaults.TextButtonContentPadding, @@ -59,7 +58,7 @@ fun Button( enabled: Boolean = true, interactionSource: MutableInteractionSource = remember { MutableInteractionSource() }, elevation: ButtonElevation? = ButtonDefaults.buttonElevation(), - shape: Shape = Shapes.Full, + shape: Shape = ButtonDefaults.textShape, border: BorderStroke? = null, colors: ButtonColors = ButtonDefaults.buttonColors(), contentPadding: PaddingValues = ButtonDefaults.ContentPadding, diff --git a/app/src/main/java/eu/kanade/presentation/components/Surface.kt b/app/src/main/java/eu/kanade/presentation/components/Surface.kt index c27c06712..b20dd525b 100644 --- a/app/src/main/java/eu/kanade/presentation/components/Surface.kt +++ b/app/src/main/java/eu/kanade/presentation/components/Surface.kt @@ -11,7 +11,6 @@ import androidx.compose.material3.ColorScheme import androidx.compose.material3.LocalAbsoluteTonalElevation import androidx.compose.material3.LocalContentColor import androidx.compose.material3.MaterialTheme -import androidx.compose.material3.Shapes import androidx.compose.material3.contentColorFor import androidx.compose.runtime.Composable import androidx.compose.runtime.CompositionLocalProvider @@ -22,6 +21,7 @@ import androidx.compose.ui.Modifier import androidx.compose.ui.draw.clip import androidx.compose.ui.draw.shadow import androidx.compose.ui.graphics.Color +import androidx.compose.ui.graphics.RectangleShape import androidx.compose.ui.graphics.Shape import androidx.compose.ui.graphics.compositeOver import androidx.compose.ui.semantics.Role @@ -37,7 +37,7 @@ fun Surface( modifier: Modifier = Modifier, onLongClick: (() -> Unit)? = null, enabled: Boolean = true, - shape: Shape = Shapes.None, + shape: Shape = RectangleShape, color: Color = MaterialTheme.colorScheme.surface, contentColor: Color = contentColorFor(color), tonalElevation: Dp = 0.dp, diff --git a/app/src/main/java/eu/kanade/presentation/util/TopAppBarScrollBehavior.kt b/app/src/main/java/eu/kanade/presentation/util/TopAppBarScrollBehavior.kt deleted file mode 100644 index cd9351eb5..000000000 --- a/app/src/main/java/eu/kanade/presentation/util/TopAppBarScrollBehavior.kt +++ /dev/null @@ -1,158 +0,0 @@ -/* - * Copyright 2021 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package eu.kanade.presentation.util - -import androidx.compose.animation.core.AnimationState -import androidx.compose.animation.core.DecayAnimationSpec -import androidx.compose.animation.core.animateDecay -import androidx.compose.material3.TopAppBarScrollBehavior -import androidx.compose.material3.TopAppBarScrollState -import androidx.compose.ui.geometry.Offset -import androidx.compose.ui.input.nestedscroll.NestedScrollConnection -import androidx.compose.ui.input.nestedscroll.NestedScrollSource -import androidx.compose.ui.unit.Velocity -import kotlin.math.abs - -/** - * A [TopAppBarScrollBehavior] that adjusts its properties to affect the colors and height of a top - * app bar. - * - * A top app bar that is set up with this [TopAppBarScrollBehavior] will immediately collapse when - * the nested content is pulled up, and will expand back the collapsed area when the content is - * pulled all the way down. - * - * @param decayAnimationSpec a [DecayAnimationSpec] that will be used by the top app bar motion - * when the user flings the content. Preferably, this should match the animation spec used by the - * scrollable content. See also [androidx.compose.animation.rememberSplineBasedDecay] for a - * default [DecayAnimationSpec] that can be used with this behavior. - * @param canScroll a callback used to determine whether scroll events are to be - * handled by this [ExitUntilCollapsedScrollBehavior] - */ -class ExitUntilCollapsedScrollBehavior( - override val state: TopAppBarScrollState, - val decayAnimationSpec: DecayAnimationSpec, - val canScroll: () -> Boolean = { true }, -) : TopAppBarScrollBehavior { - override val scrollFraction: Float - get() = if (state.offsetLimit != 0f) state.offset / state.offsetLimit else 0f - override var nestedScrollConnection = - object : NestedScrollConnection { - override fun onPreScroll(available: Offset, source: NestedScrollSource): Offset { - // Don't intercept if scrolling down. - if (!canScroll() || available.y > 0f) return Offset.Zero - - val newOffset = (state.offset + available.y) - val coerced = - newOffset.coerceIn(minimumValue = state.offsetLimit, maximumValue = 0f) - return if (newOffset == coerced) { - // Nothing coerced, meaning we're in the middle of top app bar collapse or - // expand. - state.offset = coerced - // Consume only the scroll on the Y axis. - available.copy(x = 0f) - } else { - Offset.Zero - } - } - - override fun onPostScroll( - consumed: Offset, - available: Offset, - source: NestedScrollSource, - ): Offset { - if (!canScroll()) return Offset.Zero - state.contentOffset += consumed.y - - if (available.y < 0f || consumed.y < 0f) { - // When scrolling up, just update the state's offset. - val oldOffset = state.offset - state.offset = (state.offset + consumed.y).coerceIn( - minimumValue = state.offsetLimit, - maximumValue = 0f, - ) - return Offset(0f, state.offset - oldOffset) - } - - if (consumed.y == 0f && available.y > 0) { - // Reset the total offset to zero when scrolling all the way down. This will - // eliminate some float precision inaccuracies. - state.contentOffset = 0f - } - - if (available.y > 0f) { - // Adjust the offset in case the consumed delta Y is less than what was recorded - // as available delta Y in the pre-scroll. - val oldOffset = state.offset - state.offset = (state.offset + available.y).coerceIn( - minimumValue = state.offsetLimit, - maximumValue = 0f, - ) - return Offset(0f, state.offset - oldOffset) - } - return Offset.Zero - } - - override suspend fun onPostFling(consumed: Velocity, available: Velocity): Velocity { - val result = super.onPostFling(consumed, available) - if ((available.y < 0f && state.contentOffset == 0f) || - (available.y > 0f && state.offset < 0f) - ) { - return result + - onTopBarFling( - scrollBehavior = this@ExitUntilCollapsedScrollBehavior, - initialVelocity = available.y, - decayAnimationSpec = decayAnimationSpec, - ) - } - return result - } - } -} - -/** - * Tachiyomi: Remove snap behavior - */ -private suspend fun onTopBarFling( - scrollBehavior: TopAppBarScrollBehavior, - initialVelocity: Float, - decayAnimationSpec: DecayAnimationSpec, -): Velocity { - if (abs(initialVelocity) > 1f) { - var remainingVelocity = initialVelocity - var lastValue = 0f - AnimationState( - initialValue = 0f, - initialVelocity = initialVelocity, - ) - .animateDecay(decayAnimationSpec) { - val delta = value - lastValue - val initialOffset = scrollBehavior.state.offset - scrollBehavior.state.offset = - (initialOffset + delta).coerceIn( - minimumValue = scrollBehavior.state.offsetLimit, - maximumValue = 0f, - ) - val consumed = abs(initialOffset - scrollBehavior.state.offset) - lastValue = value - remainingVelocity = this.velocity - // avoid rounding errors and stop if anything is unconsumed - if (abs(delta - consumed) > 0.5f) this.cancelAnimation() - } - return Velocity(0f, remainingVelocity) - } - return Velocity.Zero -} diff --git a/gradle/androidx.versions.toml b/gradle/androidx.versions.toml index 47275cc34..4965242ba 100644 --- a/gradle/androidx.versions.toml +++ b/gradle/androidx.versions.toml @@ -1,6 +1,6 @@ [versions] agp_version = "7.2.1" -lifecycle_version = "2.5.0" +lifecycle_version = "2.5.1" [libraries] annotation = "androidx.annotation:annotation:1.4.0" diff --git a/gradle/compose.versions.toml b/gradle/compose.versions.toml index e48edbf8a..d160e0cb0 100644 --- a/gradle/compose.versions.toml +++ b/gradle/compose.versions.toml @@ -1,8 +1,8 @@ [versions] -compiler = "1.3.0-beta01" -compose = "1.2.0-rc03" -accompanist = "0.24.13-rc" -material3 = "1.0.0-alpha14" +compiler = "1.3.0-rc01" +compose = "1.2.0" +accompanist = "0.25.0" +material3 = "1.0.0-alpha15" [libraries] activity = "androidx.activity:activity-compose:1.6.0-alpha05" @@ -14,7 +14,7 @@ ui-util = { module = "androidx.compose.ui:ui-util", version.ref = "compose" } material3-core = { module = "androidx.compose.material3:material3", version.ref = "material3" } material3-windowsizeclass = { module = "androidx.compose.material3:material3-window-size-class", version.ref = "material3" } -material3-adapter = "com.google.android.material:compose-theme-adapter-3:1.0.14" +material3-adapter = "com.google.android.material:compose-theme-adapter-3:1.0.15" material-icons = { module = "androidx.compose.material:material-icons-extended", version.ref = "compose" } accompanist-webview = { module = "com.google.accompanist:accompanist-webview", version.ref = "accompanist" }