[notifications] Add support for Android BigPictureStyle and BigTextStyle

This commit is contained in:
Chris Bianca
2018-03-27 16:15:31 +01:00
parent f5f08b716d
commit 6ff34f4daa
3 changed files with 94 additions and 0 deletions

View File

@@ -7,6 +7,8 @@ import { BadgeIconType, Category, GroupAlert, Priority } from './types';
import type Notification from './Notification';
import type {
BadgeIconTypeType,
BigPicture,
BigText,
CategoryType,
DefaultsType,
GroupAlertType,
@@ -22,6 +24,8 @@ export default class AndroidNotification {
_actions: AndroidAction[];
_autoCancel: boolean | void;
_badgeIconType: BadgeIconTypeType | void;
_bigPicture: BigPicture | void;
_bigText: BigText | void;
_category: CategoryType | void;
_channelId: string;
_clickAction: string | void;
@@ -75,6 +79,8 @@ export default class AndroidNotification {
: [];
this._autoCancel = data.autoCancel;
this._badgeIconType = data.badgeIconType;
this._bigPicture = data.bigPicture;
this._bigText = data.bigText;
this._category = data.category;
this._channelId = data.channelId;
this._clickAction = data.clickAction;
@@ -128,6 +134,14 @@ export default class AndroidNotification {
return this._badgeIconType;
}
get bigPicture(): ?BigPicture {
return this._bigPicture;
}
get bigText(): ?BigText {
return this._bigText;
}
get category(): ?CategoryType {
return this._category;
}
@@ -298,6 +312,34 @@ export default class AndroidNotification {
return this._notification;
}
setBigPicture(
picture: string,
largeIcon?: string,
contentTitle?: string,
summaryText?: string
): Notification {
this._bigPicture = {
contentTitle,
largeIcon,
picture,
summaryText,
};
return this._notification;
}
setBigText(
text: string,
contentTitle?: string,
summaryText?: string
): Notification {
this._bigText = {
contentTitle,
summaryText,
text,
};
return this._notification;
}
/**
*
* @param category
@@ -639,6 +681,8 @@ export default class AndroidNotification {
actions: this._actions.map(action => action.build()),
autoCancel: this._autoCancel,
badgeIconType: this._badgeIconType,
bigPicture: this._bigPicture,
bigText: this._bigText,
category: this._category,
channelId: this._channelId,
clickAction: this._clickAction,

View File

@@ -85,6 +85,19 @@ export type PriorityType = $Values<typeof Priority>;
export type SemanticActionType = $Values<typeof SemanticAction>;
export type VisibilityType = $Values<typeof Visibility>;
export type BigPicture = {|
contentTitle?: string,
largeIcon?: string,
picture: string,
summaryText?: string,
|};
export type BigText = {|
contentTitle?: string,
summaryText?: string,
text: string,
|};
export type Lights = {|
argb: number,
onMs: number,
@@ -129,6 +142,8 @@ export type NativeAndroidNotification = {|
actions?: NativeAndroidAction[],
autoCancel?: boolean,
badgeIconType?: BadgeIconTypeType,
bigPicture?: BigPicture,
bigText?: BigText,
category?: CategoryType,
channelId: string,
clickAction?: string,