diff --git a/src/fab-common.ts b/src/fab-common.ts index 829bfe9..42fed1e 100644 --- a/src/fab-common.ts +++ b/src/fab-common.ts @@ -236,3 +236,8 @@ export const androidScaleTypeProperty = new Property< affectsLayout: true, }); androidScaleTypeProperty.register(FloatingActionButtonBase); +export const colorProperty = new Property({ + name: 'color', + valueConverter: (v) => new Color(v), +}); +colorProperty.register(FloatingActionButtonBase); diff --git a/src/fab.android.ts b/src/fab.android.ts index 2a3cadc..34fa976 100644 --- a/src/fab.android.ts +++ b/src/fab.android.ts @@ -78,6 +78,22 @@ export class Fab extends FloatingActionButtonBase { // NOOP } + [colorProperty.setNative](value) { + let newValue; + if (value instanceof Color) { + newValue = android.content.res.ColorStateList.valueOf(value.android); + } + else { + newValue = value; + } + try { + this.nativeView.setSupportImageTintList(newValue); + } + catch (err) { + console.log(`Error setNative colorProperty: `, err); + } + } + [rippleColorProperty.setNative](value: Color) { this.nativeView.setRippleColor(value.android); } diff --git a/src/index.d.ts b/src/index.d.ts index 80fad58..1a6561a 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -11,5 +11,6 @@ export declare class Fab extends View { | 'scale'; public hideAnimationDuration: number; public rippleColor: Color; + public color: Color; public icon: string; }