forked from androidx/androidx
-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* developmentTeamToRunOnRealDevice * print jvm arch * iOS run configuration * redundant run configurations * run configurations * Revert "run configurations" This reverts commit 3b04108. * Revert "redundant run configurations" This reverts commit bb18b67. * Revert "iOS run configuration" This reverts commit 69b717e. * simplify * check runOnDevice correctly * update README * update README * run with Xcode * run with Xcode * run with Xcode * doc run mpp/demo-uikit sample on iOS * projectProperties * projectProperties * fix iOS on x86-64 * simplify demo-uikit * Added check to TEAM_ID * Add geometry functions to Offset.kt * Implement DecelerationTimingParameters * add feature flag * Add RubberBand effect business logic * Fix comment * Refactor RubberBand * WIP: start experimenting * Revert Scroll.kt changes * Chop OvercrollEffect actual providers into uikit and macos targets. Implement stub for iOS. * Implement working stub for iOS. * Implement rubber band logic in IOSOverScrollEffect * Delete dead code, mark private members accordingly. * Explicitly pass environmental variables to Xcode build script. * Integrate COMPOSE_DEMO_APPLE_TEAM_ID variable into xcodegen * Add stub for demo with spring animation * Add Underdamped spring solution * Create logic for making spring solution * Snapshot * Remove dead code. * Add spec-based implementation * Add test case to check animation * Snapshot * Snapshot * Snapshot * Snapshot * Snapshot everything except edge case working * Move connecting fling behavior and overscroll further down the tree * Add back button on nested selection screens in Demo App * Play spring animation on zero velocity fling. * Remove dead code * Snapshot before fling from overscroll edge case * Resolve edge case of flinging from inside overscroll area * Update documentation * Refactor boolean value to OverscrollOffsetSpace enum * Refactor boolean value to OverscrollOffsetSpace enum * Modify API to support interaction between OverscrollEffect and FlingBehavior * Delete dead code. * Update comment. * Update comment. * Move division by density outside of Offset * Revert "Add geometry functions to Offset.kt" This reverts commit 947b295. * Remove redundant import * Remove redundant CupertinoFlingBehavior. * Remove redundant constructor arg * Refine documentation * Modify android code and tests to conform to API change * Update document * Reset change * Remove gradle line. * Revert changes * Revert changes * Revert changes * Add comment * Make constant internal * Revert Scrollable.kt. * Bring CupertinoFlingBehavior back * Revert changes. * Revert API change. * Updater converter interface * Update CupertinoOverscrollEffect * Update CupertinoOverscrollEffect * Revert "Modify android code and tests to conform to API change" This reverts commit d5ad295. * Revert changes * Remove dead code mentions * Bind cupertino fling and overscroll behavior together * Fix a wrong construction argument bug * Revert line * Remove unneeded imports * Remove rubberband/linear space logic. iOS seems to calculate everything in rubberband space. * Update stiffness to counteract rubbe-band space visual feedback. * Fix typo. * Return it back. * Refactor density injection logic. * Fix edge case. * Change var to val * Remove new line * Fix formatting * Fix typo * Adjust fling from overscroll logic * Implement Cupertino behavior using old API * Remove println * Fix RTL and add demo * Make added API internal * Add optOut API * Update comment * Remove ScrollValueConverter altogether. * Update documentation * Move CupertinoScrollDecayAnimationSpec to uikit source set * Move CupertinoOverscrollEffect to cupertino module * Change visibility modifer * Change visibility modifier * Move CupertinoScrollDecayAnimationSpec to cupertino module * Revert visibility modifier change. * Fix formatting * Remove dead code. * Use specific type instead of a Pair * Add explicit arguments' names * Update formatting * Replace boolean with enum * Move Velocity<->Offset conversions to file scope. * Replace default decelerationRate with iOS constant instead of literal * Remove extra line * Move opt-out rubber banding to ScrollConfig * Refactor last change a bit * Rename UIKitScroll config * Fix experimental annotation to correct one --------- Co-authored-by: dima.avdeev <[email protected]>
- Loading branch information
1 parent
ae7e3d9
commit aba6dd3
Showing
14 changed files
with
809 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
77 changes: 77 additions & 0 deletions
77
...ain/kotlin/androidx/compose/animation/core/cupertino/CupertinoScrollDecayAnimationSpec.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/* | ||
* Copyright 2023 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 androidx.compose.animation.core.cupertino | ||
|
||
import androidx.compose.animation.core.FloatDecayAnimationSpec | ||
import androidx.compose.animation.core.convertNanosToSeconds | ||
import androidx.compose.animation.core.convertSecondsToNanos | ||
import kotlin.math.abs | ||
import kotlin.math.ln | ||
import kotlin.math.pow | ||
import platform.UIKit.UIScrollViewDecelerationRateNormal | ||
|
||
/** | ||
* A class that represents the animation specification for a scroll decay animation | ||
* using iOS-style decay behavior. | ||
* | ||
* @property decelerationRate The rate at which the velocity decelerates over time. | ||
* Default value is equal to one used by default UIScrollView behavior. | ||
*/ | ||
class CupertinoScrollDecayAnimationSpec( | ||
private val decelerationRate: Float = UIScrollViewDecelerationRateNormal.toFloat() | ||
) : FloatDecayAnimationSpec { | ||
|
||
private val coefficient: Float = 1000f * ln(decelerationRate) | ||
|
||
override val absVelocityThreshold: Float = 0.5f // Half pixel | ||
|
||
override fun getTargetValue(initialValue: Float, initialVelocity: Float): Float = | ||
initialValue - initialVelocity / coefficient | ||
|
||
override fun getValueFromNanos( | ||
playTimeNanos: Long, | ||
initialValue: Float, | ||
initialVelocity: Float | ||
): Float { | ||
val playTimeSeconds = convertNanosToSeconds(playTimeNanos).toFloat() | ||
val initialVelocityOverTimeIntegral = | ||
(decelerationRate.pow(1000f * playTimeSeconds) - 1f) / coefficient * initialVelocity | ||
return initialValue + initialVelocityOverTimeIntegral | ||
} | ||
|
||
override fun getDurationNanos(initialValue: Float, initialVelocity: Float): Long { | ||
val absVelocity = abs(initialVelocity) | ||
|
||
if (absVelocity < absVelocityThreshold) { | ||
return 0 | ||
} | ||
|
||
val seconds = ln(-coefficient * absVelocityThreshold / absVelocity) / coefficient | ||
|
||
return convertSecondsToNanos(seconds) | ||
} | ||
|
||
override fun getVelocityFromNanos( | ||
playTimeNanos: Long, | ||
initialValue: Float, | ||
initialVelocity: Float | ||
): Float { | ||
val playTimeSeconds = convertNanosToSeconds(playTimeNanos).toFloat() | ||
|
||
return initialVelocity * decelerationRate.pow(1000f * playTimeSeconds) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
...dation/src/jsWasmMain/kotlin/androidx/compose/foundation/gestures/FlingBehavior.jsWasm.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright 2023 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 androidx.compose.foundation.gestures | ||
|
||
import androidx.compose.animation.rememberSplineBasedDecay | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
|
||
@Composable | ||
internal actual fun rememberFlingBehavior(): FlingBehavior { | ||
val flingSpec = rememberSplineBasedDecay<Float>() | ||
return remember(flingSpec) { | ||
DefaultFlingBehavior(flingSpec) | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...n/foundation/src/jvmMain/kotlin/androidx/compose/foundation/gestures/FlingBehavior.jvm.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright 2023 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 androidx.compose.foundation.gestures | ||
|
||
import androidx.compose.animation.rememberSplineBasedDecay | ||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
|
||
@Composable | ||
internal actual fun rememberFlingBehavior(): FlingBehavior { | ||
val flingSpec = rememberSplineBasedDecay<Float>() | ||
return remember(flingSpec) { | ||
DefaultFlingBehavior(flingSpec) | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
...oundation/foundation/src/macosMain/kotlin/androidx/compose/foundation/Overscroll.macos.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright 2023 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 androidx.compose.foundation | ||
|
||
import androidx.compose.runtime.Composable | ||
import androidx.compose.runtime.remember | ||
import androidx.compose.foundation.NoOpOverscrollEffect | ||
|
||
@ExperimentalFoundationApi | ||
@Composable | ||
internal actual fun rememberOverscrollEffect(): OverscrollEffect = NoOpOverscrollEffect |
Oops, something went wrong.