Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support foreach dynamic properties manipulation #9

Closed
Vaibhav2002 opened this issue Jul 1, 2024 · 6 comments · Fixed by #19
Closed

Support foreach dynamic properties manipulation #9

Vaibhav2002 opened this issue Jul 1, 2024 · 6 comments · Fixed by #19
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@Vaibhav2002
Copy link

Vaibhav2002 commented Jul 1, 2024

What happened?

Changing color using dynamic properties is not working

This is how i did previously in lottie-android

rememberLottieDynamicProperties(
    rememberLottieDynamicProperty(
        property = LottieProperty.COLOR,
        value = color.toArgb(),
        keyPath = listOf("Layer 1 Outlines 2", "**").toTypedArray()
    )
)

This is how I'm doing it in compottie

rememberLottieDynamicProperties {
    shapeLayer("Layer 1 Outlines 2") {
        fill("**") { color { color } }
    }
}

What Compottie version do you experience the bug on?

2.0.0-beta01

What platforms are you seeing the problem on?

Android, iOS

Does Compottie log anythyng to the stdout / your logger set with Compottie.logger?

No response

@alexzhirkevich
Copy link
Owner

alexzhirkevich commented Jul 1, 2024

There is no support for ** currently. Only named fills

@alexzhirkevich alexzhirkevich added enhancement New feature or request and removed non-rendering bug labels Jul 1, 2024
@alexzhirkevich alexzhirkevich changed the title [Bug]: Dynamic Properties not working Support foreach dynamic properties manipulation Jul 1, 2024
@Vaibhav2002
Copy link
Author

Vaibhav2002 commented Jul 1, 2024

@alexzhirkevich I tried this

layer("Layer 1 Outlines 2") {
    shapeLayer("Group 1"){
        fill("Fill 1") { color { color } }
    }
}

for animation
verified.json

But it still did not work

@alexzhirkevich
Copy link
Owner

alexzhirkevich commented Jul 1, 2024

It must be

rememberLottieDynamicProperties {
    shapeLayer("Layer 1 Outlines 2") {
        fill("Group 1", "Fill 1") { color { Color.Red } }
    }
}

@alexzhirkevich
Copy link
Owner

layer(path) is a path to the layer
fill(path) is a path to the fill shape relative to the layer

@Vaibhav2002
Copy link
Author

Thanks a lot, this did work
Would appreciate some documentation on using dynamic properties in Compottie

@alexzhirkevich alexzhirkevich added this to the 2.0.0-beta02 milestone Jul 8, 2024
@sergeys-opera
Copy link
Contributor

It would be really nice to get ** work. Without the wildcard, you need to compose the full path to the layer which might be quite hard. A common use case is to get animation files from the UX team with instructions like "change the layer background color named XXX to some color" or "set a translation string for YYY layer".

sergeys-opera pushed a commit to sergeys-opera/compottie that referenced this issue Aug 15, 2024
…perties

This commit enables layer path matching for dynamic properties
in a similar fashion to the official Lottie library.
Wildcard "*" pattern path segment matches exactly one path segment.
Globstar "**" pattern path segment, matches 0, 1 or many path segments.

Example usage:

    dynamicProperties = rememberLottieDynamicProperties {
        // Match "Shape Layer 4" at any depth.
        shapeLayer("**", "Shape Layer 4") {
            // Match "Fill 3" on the second level, e.g. "ABC/Fill 3" or "XYZ/Fill 3"
            fill("*", "Fill 3") {
                color { Color.Red }
                alpha { .5f }
            }
        }
    }

Current limitations: only the first matching dynamic property is applied.

This commit fixes alexzhirkevich#9.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants