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.
This commit is contained in:
Dimitris - Rafail Katsampas
2020-12-28 14:48:14 +02:00
committed by GitHub
parent d09a564296
commit e16bc606ef
2 changed files with 11 additions and 4 deletions

View File

@ -1,4 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Page>
<ActivityIndicator busy="true" verticalAlignment="center" horizontalAlignment="center"/>
<StackLayout>
<ActivityIndicator busy="true" color="red" verticalAlignment="center" horizontalAlignment="center"/>
<ActivityIndicator busy="true" color="green" verticalAlignment="center" horizontalAlignment="center"/>
<ActivityIndicator busy="true" color="blue" verticalAlignment="center" horizontalAlignment="center"/>
<ActivityIndicator busy="true" color="" verticalAlignment="center" horizontalAlignment="center"/>
</StackLayout>
</Page>

View File

@ -47,10 +47,12 @@ export class ActivityIndicator extends ActivityIndicatorBase {
return -1;
}
[colorProperty.setNative](value: number | Color) {
if (value instanceof Color) {
this.nativeViewProtected.getIndeterminateDrawable().setColorFilter(value.android, android.graphics.PorterDuff.Mode.SRC_IN);
const color = value instanceof Color ? value.android : value;
const drawable = this.nativeViewProtected.getIndeterminateDrawable().mutate();
if (color) {
drawable.setColorFilter(color, android.graphics.PorterDuff.Mode.SRC_IN);
} else {
this.nativeViewProtected.getIndeterminateDrawable().clearColorFilter();
drawable.clearColorFilter();
}
}
}