react-native-firebase-compiled
Version:
A well tested, feature rich Firebase implementation for React Native, supporting iOS & Android. Individual module support for Admob, Analytics, Auth, Crash Reporting, Cloud Firestore, Database, Dynamic Links, Functions, Messaging (FCM), Remote Config, Sto
168 lines (126 loc) • 4.5 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.fromNativeAndroidAction = exports.default = void 0;
var _AndroidRemoteInput = _interopRequireWildcard(require("./AndroidRemoteInput"));
var _types = require("./types");
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = Object.defineProperty && Object.getOwnPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : {}; if (desc.get || desc.set) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj.default = obj; return newObj; } }
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
class AndroidAction {
constructor(action, icon, title) {
_defineProperty(this, "_action", void 0);
_defineProperty(this, "_allowGeneratedReplies", void 0);
_defineProperty(this, "_icon", void 0);
_defineProperty(this, "_remoteInputs", void 0);
_defineProperty(this, "_semanticAction", void 0);
_defineProperty(this, "_showUserInterface", void 0);
_defineProperty(this, "_title", void 0);
this._action = action;
this._icon = icon;
this._remoteInputs = [];
this._showUserInterface = true;
this._title = title;
}
get action() {
return this._action;
}
get allowGeneratedReplies() {
return this._allowGeneratedReplies;
}
get icon() {
return this._icon;
}
get remoteInputs() {
return this._remoteInputs;
}
get semanticAction() {
return this._semanticAction;
}
get showUserInterface() {
return this._showUserInterface;
}
get title() {
return this._title;
}
/**
*
* @param remoteInput
* @returns {AndroidAction}
*/
addRemoteInput(remoteInput) {
if (!(remoteInput instanceof _AndroidRemoteInput.default)) {
throw new Error(`AndroidAction:addRemoteInput expects an 'RemoteInput' but got type ${typeof remoteInput}`);
}
this._remoteInputs.push(remoteInput);
return this;
}
/**
*
* @param allowGeneratedReplies
* @returns {AndroidAction}
*/
setAllowGenerateReplies(allowGeneratedReplies) {
this._allowGeneratedReplies = allowGeneratedReplies;
return this;
}
/**
*
* @param semanticAction
* @returns {AndroidAction}
*/
setSemanticAction(semanticAction) {
if (!Object.values(_types.SemanticAction).includes(semanticAction)) {
throw new Error(`AndroidAction:setSemanticAction Invalid Semantic Action: ${semanticAction}`);
}
this._semanticAction = semanticAction;
return this;
}
/**
*
* @param showUserInterface
* @returns {AndroidAction}
*/
setShowUserInterface(showUserInterface) {
this._showUserInterface = showUserInterface;
return this;
}
build() {
if (!this._action) {
throw new Error('AndroidAction: Missing required `action` property');
} else if (!this._icon) {
throw new Error('AndroidAction: Missing required `icon` property');
} else if (!this._title) {
throw new Error('AndroidAction: Missing required `title` property');
}
return {
action: this._action,
allowGeneratedReplies: this._allowGeneratedReplies,
icon: this._icon,
remoteInputs: this._remoteInputs.map(remoteInput => remoteInput.build()),
semanticAction: this._semanticAction,
showUserInterface: this._showUserInterface,
title: this._title
};
}
}
exports.default = AndroidAction;
const fromNativeAndroidAction = nativeAction => {
const action = new AndroidAction(nativeAction.action, nativeAction.icon, nativeAction.title);
if (nativeAction.allowGeneratedReplies) {
action.setAllowGenerateReplies(nativeAction.allowGeneratedReplies);
}
if (nativeAction.remoteInputs) {
nativeAction.remoteInputs.forEach(remoteInput => {
action.addRemoteInput((0, _AndroidRemoteInput.fromNativeAndroidRemoteInput)(remoteInput));
});
}
if (nativeAction.semanticAction) {
action.setSemanticAction(nativeAction.semanticAction);
}
if (nativeAction.showUserInterface) {
action.setShowUserInterface(nativeAction.showUserInterface);
}
return action;
};
exports.fromNativeAndroidAction = fromNativeAndroidAction;