UNPKG

@olo/pay-react-native

Version:
54 lines (53 loc) 1.75 kB
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) import { Platform, requireNativeComponent, StyleSheet } from 'react-native'; import React, { useCallback } from 'react'; // 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 = requireNativeComponent('DigitalWalletButton'); } } else { NativeButton = requireNativeComponent('DigitalWalletButton'); } export const DigitalWalletButton = ({ onPress, disabled, applePayConfig, googlePayConfig, styles, ...props }) => { const onPressEventHandler = useCallback(_ => { onPress === null || onPress === void 0 || onPress(); }, [onPress]); return /*#__PURE__*/React.createElement(NativeButton, _extends({ style: [defaultStyles.nativeCard, styles], onClickedEvent: onPressEventHandler, googlePayConfig: googlePayConfig, applePayConfig: applePayConfig, isEnabled: !disabled }, props)); }; const defaultStyles = StyleSheet.create({ nativeCard: { minWidth: 80, ...Platform.select({ android: { minHeight: 40 }, default: { minHeight: 30 } }) } }); //# sourceMappingURL=DigitalWalletButton.js.map