UNPKG

react-native-credit-cards

Version:

A customizable credit card form component for React Native with card flip animation and validation

77 lines (76 loc) 3.92 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || (function () { var ownKeys = function(o) { ownKeys = Object.getOwnPropertyNames || function (o) { var ar = []; for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k; return ar; }; return ownKeys(o); }; return function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]); __setModuleDefault(result, mod); return result; }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.AnimatedLinearGradient = void 0; const jsx_runtime_1 = require("react/jsx-runtime"); const react_native_reanimated_1 = __importStar(require("react-native-reanimated")); const cardThemes_1 = require("../../utils/cardThemes"); // Try to create animated version let AnimatedLinearGradientComponent; try { // For expo-linear-gradient const ExpoLinearGradient = require('expo-linear-gradient').LinearGradient; AnimatedLinearGradientComponent = react_native_reanimated_1.default.createAnimatedComponent(ExpoLinearGradient); } catch (error) { try { // For react-native-linear-gradient const RNLinearGradient = require('react-native-linear-gradient').default; AnimatedLinearGradientComponent = react_native_reanimated_1.default.createAnimatedComponent(RNLinearGradient); } catch (error) { // Fallback to a simple View const { View } = require('react-native'); AnimatedLinearGradientComponent = ({ colors, start, end, style, children, ...props }) => ((0, jsx_runtime_1.jsx)(View, { style: [style, { backgroundColor: (colors === null || colors === void 0 ? void 0 : colors[0]) || '#000' }], ...props, children: children })); } } const AnimatedLinearGradient = ({ cardType, previousCardType, animationProgress, customColors, start, end, style, children, }) => { const animatedProps = (0, react_native_reanimated_1.useAnimatedProps)(() => { // Her zaman unknown'dan başla, kart tipine geçiş yap const unknownTheme = cardThemes_1.cardThemes.unknown; const currentTheme = cardThemes_1.cardThemes[cardType]; // Custom colors varsa kullan, yoksa theme'den al const targetColors = customColors || currentTheme.gradient; const sourceColors = unknownTheme.gradient; // Her zaman unknown'dan başla // Smooth transition between unknown (gray) and card type const startColor = (0, react_native_reanimated_1.interpolateColor)(animationProgress.value, [0, 1], [sourceColors.start, targetColors.start]); const endColor = (0, react_native_reanimated_1.interpolateColor)(animationProgress.value, [0, 1], [sourceColors.end, targetColors.end]); return { colors: [startColor, endColor], }; }); return ((0, jsx_runtime_1.jsx)(AnimatedLinearGradientComponent, { animatedProps: animatedProps, start: start, end: end, style: style, children: children })); }; exports.AnimatedLinearGradient = AnimatedLinearGradient;