Skip to content

Commit

Permalink
feat: switch to material3 1.3.0-beta02
Browse files Browse the repository at this point in the history
  • Loading branch information
ch4rl3x committed Jun 10, 2024
1 parent d2f7409 commit b6c8991
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
7 changes: 4 additions & 3 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@ minSdk = "21"
targetSdk = "34"
ktlint = "0.42.1"

composeBom = "2024.04.01" # https://developer.android.com/jetpack/compose/bom/bom-mapping
composeBom = "2024.05.00" # https://developer.android.com/jetpack/compose/bom/bom-mapping
composeCompiler = "1.5.11" # https://developer.android.com/jetpack/androidx/releases/compose-kotlin
kotlin = "1.9.23" # https://developer.android.com/jetpack/androidx/releases/compose-kotlin
gradlePlugin = "8.1.4" # https://developer.android.com/build/releases/gradle-plugin

material3 = "1.3.0-beta02"

activityComposeVersion = "1.9.0"
lifecycleRuntimeKtxVersion = "2.7.0"

spotless = "6.21.0"
material3AndroidVersion = "1.2.0"

[libraries]
compose-bom = { module = "androidx.compose:compose-bom", version.ref = "composeBom" }
compose-foundation-foundation = { module = "androidx.compose.foundation:foundation" }
compose-material3-material3 = { module = "androidx.compose.material3:material3" }
compose-material3-material3 = { module = "androidx.compose.material3:material3", version.ref = "material3" }
compose-ui-tooling = { module = "androidx.compose.ui:ui-tooling" }
compose-ui-tooling-preview = { module = "androidx.compose.ui:ui-tooling-preview" }
compose-ui-ui = { module = "androidx.compose.ui:ui" }
Expand Down
2 changes: 1 addition & 1 deletion revealswipe/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ apply from: '../buildCompose.gradle'

ext {
PUBLISH_GROUP_ID = 'de.charlex.compose'
PUBLISH_VERSION = '2.0.0-beta02'
PUBLISH_VERSION = '2.1.0-alpha01'
PUBLISH_ARTIFACT_ID = 'revealswipe'
}

Expand Down
12 changes: 9 additions & 3 deletions revealswipe/src/main/java/de/charlex/compose/RevealSwipe.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package de.charlex.compose

import androidx.compose.animation.core.AnimationSpec
import androidx.compose.animation.core.CubicBezierEasing
import androidx.compose.animation.core.DecayAnimationSpec
import androidx.compose.animation.core.Easing
import androidx.compose.animation.core.exponentialDecay
import androidx.compose.animation.core.tween
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.LocalIndication
Expand Down Expand Up @@ -384,6 +386,7 @@ fun rememberRevealState(
positionalThreshold: (totalDistance: Float) -> Float = { distance: Float -> distance * 0.5f },
velocityThreshold: (() -> Float)? = null,
animationSpec: AnimationSpec<Float> = tween(),
decayAnimationSpec:DecayAnimationSpec<Float> = exponentialDecay(),
confirmValueChange: (newValue: RevealValue) -> Boolean = { true }
): RevealState {
val density = LocalDensity.current
Expand All @@ -396,6 +399,7 @@ fun rememberRevealState(
positionalThreshold = positionalThreshold,
velocityThreshold = velocityThreshold ?: { with(density) { 100.dp.toPx() } },
animationSpec = animationSpec,
decayAnimationSpec = decayAnimationSpec,
confirmValueChange = confirmValueChange
)
}
Expand All @@ -410,19 +414,21 @@ data class RevealState(
private val positionalThreshold: (totalDistance: Float) -> Float = { distance: Float -> distance * 0.5f },
private val velocityThreshold: (() -> Float)? = null,
private val animationSpec: AnimationSpec<Float> = tween(),
private val decayAnimationSpec: DecayAnimationSpec<Float>,
private val confirmValueChange: (newValue: RevealValue) -> Boolean = { true }
) {
@OptIn(ExperimentalFoundationApi::class)
val anchoredDraggableState: AnchoredDraggableState<RevealValue> = AnchoredDraggableState(
initialValue = initialValue,
positionalThreshold = positionalThreshold,
velocityThreshold = velocityThreshold ?: { with(density) { 10.dp.toPx() } },
animationSpec = animationSpec,
anchors = DraggableAnchors {
RevealValue.Default at 0f
if (RevealDirection.StartToEnd in directions) RevealValue.FullyRevealedEnd at with(density) { maxRevealDp.toPx() }
if (RevealDirection.EndToStart in directions) RevealValue.FullyRevealedStart at -with(density) { maxRevealDp.toPx() }
},
positionalThreshold = positionalThreshold,
velocityThreshold = velocityThreshold ?: { with(density) { 10.dp.toPx() } },
snapAnimationSpec = animationSpec,
decayAnimationSpec = decayAnimationSpec,
confirmValueChange = confirmValueChange
)
}
Expand Down

0 comments on commit b6c8991

Please sign in to comment.