import React, { Component, ReactNode, ReactChild } from 'react' import { Text, View, StyleSheet, TouchableOpacity } from 'react-native' import { Icon } from '../Icon' import variables from '../../common/styles/variables' import formStyles from './styles' const styles = StyleSheet.create(formStyles) export interface FormItemProps { style?: any label?: string | ReactNode labelWidth?: number hasLine?: boolean children?: ReactChild[] | ReactChild } interface FormItemState { } export class FormItem extends Component { static defaultProps = { style: {}, label: '标题', labelWidth: variables.formItemLabelWidth, hasLine: false } constructor (props) { super(props) this.state = { validation: '', valid: false, validating: false } } componentDidMount () { } componentWillUnmount () { } renderItem = () => { const children = this.props.children && Array.isArray(this.props.children) ? this.props.children : [this.props.children] return ( { this.props.label && { React.isValidElement(this.props.label) ? this.props.label : {this.props.label} } {children[0]} } { [].slice.call(children, 1).length ? {[].slice.call(children, 1)} : null } {this.props.hasLine ? : null} ) } render () { return this.renderItem() } }