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

Add Keypath to TextDelegate in order to have same cross platform behavior as iOS AnimationTextProvider. #1932

Closed
greggiacovelli opened this issue Oct 22, 2021 · 0 comments · Fixed by #1931

Comments

@greggiacovelli
Copy link
Contributor

greggiacovelli commented Oct 22, 2021

Lottie is supported and developed on nights and weekends. Issues from Lottie sponsors will be prioritized.

If you don't use this template, your issue will be closed. Delete this text once completed.

Is your feature request related to a problem? Please describe.
Currently if an animation is shared across Android and iOS the text layers are intercepted by their respective libraries differently. Android (TextDelegate) can only replace text with text that is named X, whereas iOS (AnimationTextProvider) will be able to look at either the Keypath and the text, by default (DictionaryTextProvider) will look for matching KeyPath that is named X. This creates a bit of a disconnect but prevents duplicate text among layers in an animation as well for android. Consider the following example set of layers

layer_1 with text "READ IT" // Let's say in context it's a commanding statement
layer_2 with text "READ IT" // Let's say in context it's a statement representing the past

By default the layers would be named the same as the text they contained. However this is just default. In the case where a content author would want to disambiguate the layers they can rename them. In this case, Android would not be able to replace the text on layer1 and layer2 independently. They would both be replaced with the same exact string. If TextDelegate were to be using to localize the text, it might be incorrect as text here could mean different things depending on context.

Describe the solution you'd like
I proposed #1931 as a possible solution. It merely exposes the KeyPath's name to the interface of TextDelegate to make an implementation possible that would address the above example.

Describe alternatives you've considered
We could also generate multiple animations that are organized specifically for Android vs iOS but that may defeat the overall purpose of the portable animation format. It's the current solution that we are going with but it's not ideal and very error prone.

Additional context
Add any other context or screenshots about the feature request here.

@greggiacovelli greggiacovelli changed the title Lottie TextDelegate cannot conditionally replace by layer like iOS AnimationTextProvider can Add Keypath to TextDelegate in order to have same cross platform behavior iOS AnimationTextProvider Oct 29, 2021
@greggiacovelli greggiacovelli changed the title Add Keypath to TextDelegate in order to have same cross platform behavior iOS AnimationTextProvider Add Keypath to TextDelegate in order to have same cross platform behavior as iOS AnimationTextProvider. Oct 29, 2021
greggiacovelli added a commit to greggiacovelli/lottie-android that referenced this issue Nov 2, 2021
gpeal pushed a commit that referenced this issue Nov 2, 2021
…Name (#1931)

If multiple text layers have the same text, it is impossible to disambiguate which one you are setting the text for. This commit adds a second overload for TextDelegate.getText that lets you receive the layerName in addition to the text.

Fixex #1932
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant