Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/fab-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
16 changes: 16 additions & 0 deletions src/fab.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
1 change: 1 addition & 0 deletions src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@ export declare class Fab extends View {
| 'scale';
public hideAnimationDuration: number;
public rippleColor: Color;
public color: Color;
public icon: string;
}