Skip to content

Commit

Permalink
Fix VariantAnimationTimelineTest
Browse files Browse the repository at this point in the history
Fixes #1945: Add functions to VariantTransitionContext that allow access to the view names.
  • Loading branch information
rylin8 committed Jan 10, 2025
1 parent b2cc317 commit 45c2ad3
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,27 @@ internal class VariantAnimationInfo(
val transition: AnimationTransition,
)

class VariantTransitionContext(val from: View?, val to: View?) {
class VariantTransitionContext(private val from: View?, private val to: View?) {
@Discouraged(
message =
"This helper function will the name of the `from` View. This function is intended to " +
"temporarily help with creating custom variant transitions, but may be deprecated or " +
"removed in the future."
)
fun getFromViewName(): String {
return from?.name ?: ""
}

@Discouraged(
message =
"This helper function will the name of the `to` View. This function is intended to " +
"temporarily help with creating custom variant transitions, but may be deprecated or " +
"removed in the future."
)
fun getToViewName(): String {
return to?.name ?: ""
}

@Discouraged(
message =
"This helper function will return true if the transition is within a variant from the " +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import com.android.designcompose.definition.layout.LayoutSizing
import com.android.designcompose.definition.layout.Overflow
import com.android.designcompose.definition.layout.PositionType
import com.android.designcompose.definition.layout.copy
import com.android.designcompose.definition.layout.layoutStyle
import com.android.designcompose.definition.modifier.BlendMode
import com.android.designcompose.definition.modifier.TextAlign
import com.android.designcompose.definition.modifier.TextAlignVertical
Expand All @@ -41,7 +40,6 @@ import com.android.designcompose.definition.view.ViewStyle
import com.android.designcompose.definition.view.copy
import com.android.designcompose.definition.view.fontStretchOrNull
import com.android.designcompose.definition.view.nodeSizeOrNull
import com.android.designcompose.definition.view.nodeStyle
import com.android.designcompose.definition.view.strokeOrNull
import com.android.designcompose.definition.view.viewStyle

Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,11 @@ val EXAMPLES: ArrayList<Triple<String, @Composable () -> Unit, String?>> =
// Animations
Triple("SA", { SmartAnimateTest() }, SmartAnimateTestDoc.javaClass.name),
Triple("SA Variant", { VariantAnimationTest() }, VariantAnimationTestDoc.javaClass.name),
/**
* Temporarily disabled: GH-1945 Triple( "SA Variant Timelines", {
* VariantAnimationTimelineTest() }, VariantAnimationTimelineTestDoc.javaClass.name, ),
*/
Triple(
"SA Variant Timelines",
{ VariantAnimationTimelineTest() },
VariantAnimationTimelineTestDoc.javaClass.name,
),
// No support for hyperlinks in squoosh.
Triple("Hyperlink", { HyperlinkTest() }, HyperlinkValidationDoc.javaClass.name),
// GH-636: Test takes too long to execute.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@
*/

package com.android.designcompose.testapp.validation.examples
/** Temporarily disabled: GH-1945

import androidx.compose.animation.core.CubicBezierEasing
import androidx.compose.animation.core.tween
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.absoluteOffset
import androidx.compose.material.Text
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.mutableStateOf
Expand Down Expand Up @@ -78,10 +77,10 @@ fun VariantAnimationTimelineTest() {
DesignDocSettings(
customVariantTransition = { context ->
val defaultEasing = CubicBezierEasing(0.37f, 0f, 0.63f, 1f)
val regexMatch = tNumRegex.find(context.from?.name ?: "")
val regexMatch = tNumRegex.find(context.getFromViewName())
val tNum = regexMatch?.let { it.groupValues[1].toInt() }
if (
context.from?.name == "T3Rect" &&
context.getFromViewName() == "T3Rect" &&
childAnimType.value != ChildAnimType.Normal
) {
val delayMillis =
Expand Down Expand Up @@ -213,4 +212,3 @@ fun VariantAnimationTimelineTest() {
}
}
}
*/

0 comments on commit 45c2ad3

Please sign in to comment.