import React from 'react'; import { SafeAreaView, ScrollView, StatusBar, StyleSheet, Text, Image, TouchableOpacity, View, TextInput } from 'react-native'; import { colors, filterEmoji, onePx, px2dp } from '../../utils'; interface Props { theme?: 'gray' | 'black' rowType?: 'input' | 'text' | 'pick' title?: string isNeeded?: boolean value?: string placeholderText?: string rowInputType?: 'number' | 'string' | 'default' onPress?: Function onChangeText?: Function rowInputMaxLength?: number hideRightIcon?: boolean rightIcon?: any isLast?: boolean onInputBlur?: Function fontBold?: boolean hideTitle?: boolean hasPermission?: boolean, multipleLineText?: boolean renderRightIcon?: Function inlineLayout?: boolean } interface State { } export default class KitFormSingleRow extends React.Component { constructor(props: Props) { super(props); }; public readonly state: Readonly = { }; _onChangeText(text) { const newText = filterEmoji(text); const { onChangeText } = this.props; onChangeText && onChangeText(newText); } render() { const { title, isNeeded, rowType, value, placeholderText, rowInputType, onPress, onChangeText, rowInputMaxLength = 30, hideRightIcon = false, rightIcon, isLast = false, theme = 'black', onInputBlur, fontBold = false, hideTitle = false, hasPermission = true, multipleLineText = false, renderRightIcon, inlineLayout = false } = this.props; return ( onPress && onPress()} disabled={!hasPermission} style={[ styles.formSingleRow, isLast ? { marginBottom: 0, borderBottomWidth: 0 } : null, hideTitle ? { paddingBottom: px2dp(18), paddingTop: px2dp(10) } : null, inlineLayout ? styles.formGroupRowInline : null ]}> { hideTitle ? null : {title} {isNeeded && hasPermission && *} } { rowType == 'input' ? onInputBlur && onInputBlur()} /> : <> { value ? {value + ''} : {placeholderText} } } { renderRightIcon ? {renderRightIcon && renderRightIcon()} : { hasPermission ? <> { rightIcon || hideRightIcon ? null : } { rightIcon ? : null } : null } } ) } } const styles = StyleSheet.create({ formSingleRow: { width: px2dp(330), flexDirection: 'row', justifyContent: 'space-between', alignItems: 'flex-start', marginBottom: 1, borderBottomWidth: onePx, borderBottomColor: colors.borderLineColor, marginHorizontal: px2dp(10), paddingVertical: px2dp(12) }, formGroupRowInline: { width: px2dp(324), }, formSingleRowLeft: { width: px2dp(280), justifyContent: 'center', alignItems: 'flex-start', }, formSingleRowRight: { flex: 1, height: '100%', flexDirection: 'row', justifyContent: 'flex-end', alignItems: 'center' }, rightIcon: { width: px2dp(14), height: px2dp(14), tintColor: '#909399', }, formGroupTitleContainer: { width: '100%', height: px2dp(24), justifyContent: 'center', alignItems: 'flex-start', marginBottom: px2dp(4) }, valueContainer: { width: '100%', height: px2dp(28), justifyContent: 'center', alignItems: 'flex-start' }, formRowTitle: { fontSize: 16, lineHeight: px2dp(20), color: colors.blackColor, }, formRowPlaceHolderText: { fontSize: 14, height: px2dp(20), lineHeight: px2dp(20), color: colors.placeholderColor }, formValueText: { // height: px2dp(20), lineHeight: px2dp(20), fontSize: 14, color: '#303133' }, formRowPlaceHolderTextInput: { fontSize: 14, color: '#303133', width: '100%', height: px2dp(20), paddingVertical: px2dp(0), paddingHorizontal: px2dp(0), flexDirection: 'row', justifyContent: 'flex-start', alignItems: 'center', } })