import React, { Component } from "react"; import { Platform, StyleSheet, View, TouchableOpacity, ScrollView, Switch, SafeAreaView, } from "react-native"; import { observable, action } from "mobx"; import Text from "react-native-text"; import { observer, inject } from "mobx-react/native"; import { scale, verticalScale, moderateScale } from "react-native-size-matters"; import Icon from "react-native-vector-icons/dist/Ionicons"; import Toast, { DURATION } from "react-native-easy-toast"; import { CreditCardInput, LiteCreditCardInput } from "react-native-credit-card-input"; import DrawerNavigationHeader from "../../components/Public/drawerNavigationHeader"; import Loader from "../../components/Public/loader" import { width, height } from "../../config/screen"; import theme from '../../config/colors' import {Fonts} from '../../config/fonts' import Size from "../../config/size"; const size = new Size(); @inject(["userStore"]) @observer export default class AddCard extends Component { constructor(props) { super(props); this.store = this.props.userStore; } cardData = null; //_onFocus = field => console.log("focusing", field); addCardAction() { var BreakException = {}; if (this.cardData != null) { if (this.cardData.valid) { let data = { num: this.cardData.values.number.replace(/\s/g, ""), expiry: this.cardData.values.expiry.replace("/", ""), cvc: this.cardData.values.cvc }; console.log(this.cardData); this.store.postCreditCard(this.props.navigation,data); } else { try { Object.keys(this.cardData.status).forEach(e => { console.log(e + " - " + this.cardData.status[e]); if ( this.cardData.status[e] == "incomplete" || this.cardData.status[e] == "invalid" ) { this.refs.toast.show(e + " " + this.cardData.status[e]); throw BreakException; } }); } catch (e) { if (e !== BreakException) throw e; } } } else { this.refs.toast.show("please insert card number"); } } render() { return ( { this.props.navigation.goBack(); }} /> Add a Card this.addCardAction()} /> (this.cardData = form)} /> ); } } const styles = StyleSheet.create({ container: { flex: 1, backgroundColor: "#F5FCFF" }, switch: { alignSelf: "center", marginTop: 20, marginBottom: 20 }, label: { color: "black", fontSize: 12 }, input: { fontSize: 16, color: "black" } });