Skip to content

Commit 0932a12

Browse files
committed
fix(android): crash on null rippleColor
1 parent f233890 commit 0932a12

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

src/button/button.android.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,9 @@ export class Button extends ButtonBase {
8686
// nativeView.setOnClickListener(clickListener);
8787
// (<any>nativeView).clickListener = clickListener;
8888
// }
89-
[rippleColorProperty.setNative](color: Color) {
90-
this.nativeViewProtected.setRippleColor(getColorStateList(color.android));
89+
[rippleColorProperty.setNative](value: Color) {
90+
const color = !value || value instanceof Color ? value : new Color(value);
91+
this.nativeViewProtected.setRippleColor(color ? getColorStateList(color.android) : null);
9192
}
9293
[shapeProperty.setNative](shape: string) {
9394
const appearanceModel = themer.getShape(shape);

src/core/index.android.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ export function install() {}
170170

171171
export function getRippleColor(color: string | Color) {
172172
if (color) {
173-
const temp = typeof color === 'string' ? new Color(color) : color;
173+
const temp = color instanceof Color ? color : new Color(color);
174174
return new Color(temp.a !== 255 ? temp.a : 61.5, temp.r, temp.g, temp.b).android; // default alpha is 0.24
175175
}
176176
return null;

src/core/index.ios.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ export function install() {}
194194

195195
export function getRippleColor(color: string | Color): UIColor {
196196
if (color) {
197-
const temp = typeof color === 'string' ? new Color(color) : color;
197+
const temp = color instanceof Color ? color : new Color(color);
198198
// return UIColor.colorWithRedGreenBlueAlpha(temp.r / 255, temp.g / 255, temp.b, temp.a !== 255 ? temp.a / 255 : 0.14);
199199
return new Color(temp.a !== 255 ? temp.a : 61.5, temp.r, temp.g, temp.b).ios; // default alpha is 0.24
200200
}

0 commit comments

Comments
 (0)