@olo/pay-react-native
Version:
Olo Pay React Native SDK
60 lines (59 loc) • 2.59 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.DigitalWalletButton = void 0;
var _reactNative = require("react-native");
var _react = _interopRequireWildcard(require("react"));
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); } // Copyright © 2022 Olo Inc. All rights reserved.
// This software is made available under the Olo Pay SDK License (See LICENSE.md file)
// Support both Old and New Architecture
const isFabricEnabled = () => {
// @ts-ignore
return global.nativeFabricUIManager != null;
};
let NativeButton;
if (isFabricEnabled()) {
try {
NativeButton = require('./specs/DigitalWalletButtonNativeComponent').default;
} catch (e) {
NativeButton = (0, _reactNative.requireNativeComponent)('DigitalWalletButton');
}
} else {
NativeButton = (0, _reactNative.requireNativeComponent)('DigitalWalletButton');
}
const DigitalWalletButton = ({
onPress,
disabled,
applePayConfig,
googlePayConfig,
styles,
...props
}) => {
const onPressEventHandler = (0, _react.useCallback)(_ => {
onPress === null || onPress === void 0 || onPress();
}, [onPress]);
return /*#__PURE__*/_react.default.createElement(NativeButton, _extends({
style: [defaultStyles.nativeCard, styles],
onClickedEvent: onPressEventHandler,
googlePayConfig: googlePayConfig,
applePayConfig: applePayConfig,
isEnabled: !disabled
}, props));
};
exports.DigitalWalletButton = DigitalWalletButton;
const defaultStyles = _reactNative.StyleSheet.create({
nativeCard: {
minWidth: 80,
..._reactNative.Platform.select({
android: {
minHeight: 40
},
default: {
minHeight: 30
}
})
}
});
//# sourceMappingURL=DigitalWalletButton.js.map