import React, { ReactNode } from 'react'; import { TouchableOpacity, Text, StyleSheet, TextStyle, ViewStyle, StyleProp, } from 'react-native'; import { Theme } from '../../styles'; export interface ButtonProps { /** 点击函数 */ onPress?: (e?: any) => void; /** 标题 */ title?: string; /** 是否不能点击 */ disabled?: boolean; /** 按钮圆角 */ borderRadius?: number; /** 背景颜色 */ backgroundColor?: string; /** 不能点击时背景颜色 */ disableBackgroundColor?: string; /** 标题颜色 */ titleColor?: string; /** 能点击时标题颜色 */ disableTitleColor?: string; /** 整体样式 */ style?: StyleProp; /** 标题样式 */ titleStyle?: StyleProp; /** 传入子组件 */ children?: ReactNode; } const Button = (props: ButtonProps) => { const { onPress = () => { }, disabled, style, titleStyle, backgroundColor = Theme.theme, disableBackgroundColor = Theme.disabledColor, titleColor = Theme.white, disableTitleColor = 'rgba(255,255,255,0.6)', borderRadius = px2dp(45), title = 'button', children = null, } = props; return ( {title} {children} ); }; interface Style { btn: ViewStyle; text: TextStyle; } const styles = StyleSheet.create