Skip to content

Commit

Permalink
Allow repeater contents to have dynamic properties (#2164)
Browse files Browse the repository at this point in the history
Fixes #2143
  • Loading branch information
gpeal authored Nov 14, 2022
1 parent def619c commit 5512f3d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,10 @@ public ContentGroup(final LottieDrawable lottieDrawable, BaseLayer layer, ShapeG
}
}

public List<Content> getContents() {
return contents;
}

List<PathContent> getPathList() {
if (pathContents == null) {
pathContents = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,12 @@ public RepeaterContent(LottieDrawable lottieDrawable, BaseLayer layer, Repeater
@Override public void resolveKeyPath(
KeyPath keyPath, int depth, List<KeyPath> accumulator, KeyPath currentPartialKeyPath) {
MiscUtils.resolveKeyPath(keyPath, depth, accumulator, currentPartialKeyPath, this);
for (int i = 0; i < contentGroup.getContents().size(); i++) {
Content content = contentGroup.getContents().get(i);
if (content instanceof KeyPathElementContent) {
MiscUtils.resolveKeyPath(keyPath, depth, accumulator, currentPartialKeyPath, (KeyPathElementContent) content);
}
}
}

@SuppressWarnings("unchecked")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,20 @@ class DynamicPropertiesTestCase : SnapshotTestCase {
LottieRelativePointValueCallback(PointF(100f, 100f))
)

testDynamicProperty(
"Repeater contents",
KeyPath("Shape Layer 1", "Repeater Shape", "Repeater 1"),
LottieProperty.TRANSFORM_POSITION,
LottieRelativePointValueCallback(PointF(100f, 100f))
)

testDynamicProperty(
"Repeater sub-contents",
KeyPath("Shape Layer 1", "Repeater Shape", "Fill 1"),
LottieProperty.COLOR_FILTER,
LottieValueCallback(SimpleColorFilter(Color.GREEN))
)

testDynamicProperty(
"Repeater transform start opacity",
KeyPath("Shape Layer 1", "Repeater Shape", "Repeater 1"),
Expand Down

0 comments on commit 5512f3d

Please # to comment.