import * as React from 'react'; import { View, Text, Animated, Pressable, ViewStyle } from 'react-native'; import Icon from '../icon'; import ClearInput from '../clear-input'; import Theme from '../style/theme'; import styles from './style'; const prefixCls = 'search-bar'; export interface SearchBarProps { value?: string; returnKeyType?: 'done' | 'go' | 'next' | 'search' | 'send'; showActionButton?: boolean; placeholder?: string; style?: ViewStyle; containerStyle?: ViewStyle; clearButtonMode?: string; autoFocus?: boolean; onFocus?: (e: any) => void; onBlur?: (e: any) => void; onActionPress?: () => void; onChangeText?: (text: string) => void; onSubmitEditing?: (e: any) => void; } const SearchBar: React.ForwardRefRenderFunction = (props, ref) => { const { value, returnKeyType, showActionButton, placeholder, style, containerStyle, clearButtonMode = 'while-editing', autoFocus, onFocus, onBlur, onActionPress, onChangeText, onSubmitEditing, } = props; const marginRightAnim = React.useRef(new Animated.Value(-100)).current; React.useEffect(() => { if (showActionButton) { Animated.timing(marginRightAnim, { toValue: 10, duration: 300, useNativeDriver: false, }).start(); } else { Animated.timing(marginRightAnim, { toValue: -100, duration: 300, useNativeDriver: false, }).start(); } }, [showActionButton]); return ( 取消 ); }; export default React.forwardRef(SearchBar);