UNPKG

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

143 lines (110 loc) 3.03 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.fromNativeAndroidRemoteInput = exports.default = void 0; 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; } /** * * AndroidRemoteInput representation wrapper */ class AndroidRemoteInput { constructor(resultKey) { _defineProperty(this, "_allowedDataTypes", void 0); _defineProperty(this, "_allowFreeFormInput", void 0); _defineProperty(this, "_choices", void 0); _defineProperty(this, "_label", void 0); _defineProperty(this, "_resultKey", void 0); this._allowedDataTypes = []; this._choices = []; this._resultKey = resultKey; } get allowedDataTypes() { return this._allowedDataTypes; } get allowFreeFormInput() { return this._allowFreeFormInput; } get choices() { return this._choices; } get label() { return this._label; } get resultKey() { return this._resultKey; } /** * * @param mimeType * @param allow * @returns {AndroidRemoteInput} */ setAllowDataType(mimeType, allow) { this._allowedDataTypes.push({ allow, mimeType }); return this; } /** * * @param allowFreeFormInput * @returns {AndroidRemoteInput} */ setAllowFreeFormInput(allowFreeFormInput) { this._allowFreeFormInput = allowFreeFormInput; return this; } /** * * @param choices * @returns {AndroidRemoteInput} */ setChoices(choices) { this._choices = choices; return this; } /** * * @param label * @returns {AndroidRemoteInput} */ setLabel(label) { this._label = label; return this; } build() { if (!this._resultKey) { throw new Error('AndroidRemoteInput: Missing required `resultKey` property'); } return { allowedDataTypes: this._allowedDataTypes, allowFreeFormInput: this._allowFreeFormInput, choices: this._choices, label: this._label, resultKey: this._resultKey }; } } exports.default = AndroidRemoteInput; const fromNativeAndroidRemoteInput = nativeRemoteInput => { const remoteInput = new AndroidRemoteInput(nativeRemoteInput.resultKey); if (nativeRemoteInput.allowedDataTypes) { for (let i = 0; i < nativeRemoteInput.allowedDataTypes.length; i++) { const allowDataType = nativeRemoteInput.allowedDataTypes[i]; remoteInput.setAllowDataType(allowDataType.mimeType, allowDataType.allow); } } if (nativeRemoteInput.allowFreeFormInput) { remoteInput.setAllowFreeFormInput(nativeRemoteInput.allowFreeFormInput); } if (nativeRemoteInput.choices) { remoteInput.setChoices(nativeRemoteInput.choices); } if (nativeRemoteInput.label) { remoteInput.setLabel(nativeRemoteInput.label); } return remoteInput; }; exports.fromNativeAndroidRemoteInput = fromNativeAndroidRemoteInput;