import React, { Component, ReactNode } from 'react'; import { TouchableOpacity, Text, ViewStyle, TextStyle, View, StyleSheet, ImageSourcePropType, ImageStyle, Animated, Easing, StyleProp, Image, GestureResponderEvent, } from 'react-native'; import HorizontalLine from '../HorizontalLine'; import appStyles, { Theme } from '../../styles'; import arrowRight from '../assets/icons/arrow-right.png'; export interface LabelItemProps { /** 点击函数 */ onPress?: (event: GestureResponderEvent) => void; /** 是否不可以点击button, 默认false */ disabled?: boolean; /** 按钮的样式 */ style?: StyleProp; /** 点击透明度, 默认0.6 */ activeOpacity?: number; /** 底部分隔线样式 */ borderStyle?: StyleProp; /** 右边文字点击函数 */ onPressRight?: (event: GestureResponderEvent) => void; /** 左边文字点击函数 */ onPressLeft?: (event: GestureResponderEvent) => void; /** 右边文字 */ textRight?: string; /** 左边文字 */ textLeft?: string; /** 右边第二行文字 */ textRightDes?: string; /** 左边第二行文字 */ textLeftDes?: string; /** 右边文字样式 */ textRightStyle?: StyleProp; /** 左边文字样式 */ textLeftStyle?: StyleProp; /** 右边第二行文字样式 */ textRightDesStyle?: StyleProp; /** 左边第二行文字样式 */ textLeftDesStyle?: StyleProp; /** 是否显示底部分隔线, 默认true */ border?: boolean; /** 是否显示最右边箭头, 默认false */ showArrow?: boolean; /** 传入左边文字前面的控件 */ beforeTextLeftComponent?: ReactNode; /** 传入左边文字后面的控件 */ afterTextLeftComponent?: ReactNode; /** 传入右边文字前面的控件 */ beforeTextRightComponent?: ReactNode; /** 传入右边文字后面的控件 */ afterTextRightComponent?: ReactNode; /** 传入中间的控件 */ centerComponent?: ReactNode; /** 中间控件样式 */ centerStyle?: StyleProp; } export default class LabelItem extends Component { static defaultProps = { disabled: false, activeOpacity: 0.6, textRight: '', textLeft: '', border: true, showArrow: false, }; _onPress = (e) => { const { onPress } = this.props; if (onPress) onPress(e); } render() { const { style, disabled, activeOpacity, borderStyle, onPressRight, onPressLeft, textRight, textLeft, textRightStyle, textLeftStyle, border, showArrow, beforeTextLeftComponent, afterTextLeftComponent, beforeTextRightComponent, afterTextRightComponent, textRightDes, textLeftDes, textRightDesStyle, textLeftDesStyle, centerComponent, centerStyle, } = this.props; return ( {beforeTextLeftComponent} {textLeft ? : null} {afterTextLeftComponent} {centerComponent} {beforeTextRightComponent} {textRight ? : null} {afterTextRightComponent} {showArrow ? : null} {border ? : null} ); } } const TextView = ({ onPress, textStyle, text, des, desStyle }) => { return ( {text ? {text} : null} {des ? {des} : null} ); }; const styles = StyleSheet.create({ container: { paddingHorizontal: px2dp(20), paddingVertical: px2dp(10), flex: 1, height: px2dp(100), flexDirection: 'row', alignItems: 'center', backgroundColor: Theme.white, } as ViewStyle, arrow: { width: px2dp(30), height: px2dp(30), marginHorizontal: px2dp(5), marginLeft: px2dp(10), } as ImageStyle, });