import React from 'react'; import Module from '../lib/Module'; import {StyleSheet ,TextInput, View, Button , Text } from 'react-native'; import Types from '../lib/Types'; const Inp = [ { textContentType :"username", placeholder:"username" }, { textContentType :"password", placeholder:"password" }] export default class FormComp extends Module { constructor(props) { super(props); this.state = { } this.submit = this.submit.bind(this) } submit(e){ e.preventDefault() return this.state } display() { let { inputs, // number of inputs this must be Object inputsMargin, ButtonText, ButtonColor, backgroundColor, Formtitle } = this.props //Init if(!inputs) inputs = Inp; if(!inputsMargin) inputsMargin = 7 if(!backgroundColor) backgroundColor = "#f7e6ff" let Inputs = Object.keys(inputs).map((key,indx) => { let state = {} return ( { state[indx] = text; this.setState(state)}} value={this.state.key} placeholder={inputs[key].placeholder} textContentType={inputs[key].textContentType} secureTextEntry={ inputs[key].textContentType === "password" ? true :false} />) }) let fn = this.props.submit || this.submit return ( {this.props.Formtitle ? ( {this.props.Formtitle} ):(null)} {Inputs}