Skip to content

Commit e16bc60

Browse files
authored
fix: android ActivityIndicator custom color affecting other indicators on the page (#9026)
* fix(core): Setting color of an Android ActivityIndicator changed the color of the rest of ActivityIndicators in the same page. * test: Updated ActivityIndicator sample. * perf: Call mutate() only if color is actually changed.
1 parent d09a564 commit e16bc60

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
11
<?xml version="1.0" encoding="UTF-8" ?>
22
<Page>
3-
<ActivityIndicator busy="true" verticalAlignment="center" horizontalAlignment="center"/>
3+
<StackLayout>
4+
<ActivityIndicator busy="true" color="red" verticalAlignment="center" horizontalAlignment="center"/>
5+
<ActivityIndicator busy="true" color="green" verticalAlignment="center" horizontalAlignment="center"/>
6+
<ActivityIndicator busy="true" color="blue" verticalAlignment="center" horizontalAlignment="center"/>
7+
<ActivityIndicator busy="true" color="" verticalAlignment="center" horizontalAlignment="center"/>
8+
</StackLayout>
49
</Page>

packages/core/ui/activity-indicator/index.android.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,12 @@ export class ActivityIndicator extends ActivityIndicatorBase {
4747
return -1;
4848
}
4949
[colorProperty.setNative](value: number | Color) {
50-
if (value instanceof Color) {
51-
this.nativeViewProtected.getIndeterminateDrawable().setColorFilter(value.android, android.graphics.PorterDuff.Mode.SRC_IN);
50+
const color = value instanceof Color ? value.android : value;
51+
const drawable = this.nativeViewProtected.getIndeterminateDrawable().mutate();
52+
if (color) {
53+
drawable.setColorFilter(color, android.graphics.PorterDuff.Mode.SRC_IN);
5254
} else {
53-
this.nativeViewProtected.getIndeterminateDrawable().clearColorFilter();
55+
drawable.clearColorFilter();
5456
}
5557
}
5658
}

0 commit comments

Comments
 (0)