From 954e3ec2c317146c3b6eda5cdb391ee4ad5dda44 Mon Sep 17 00:00:00 2001 From: Zixuan Liu Date: Mon, 26 Aug 2019 21:50:01 +0800 Subject: [PATCH] Add longPress support to ListItem and amend ListItemProps --- components/list/ListItem.tsx | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/components/list/ListItem.tsx b/components/list/ListItem.tsx index 8a6b6efb4..3fc43d65c 100644 --- a/components/list/ListItem.tsx +++ b/components/list/ListItem.tsx @@ -1,5 +1,5 @@ import React from 'react'; -import { Image, StyleProp, StyleSheet, Text, TouchableHighlight, View, ViewStyle } from 'react-native'; +import { GestureResponderEvent, Image, StyleProp, StyleSheet, Text, TouchableHighlight, View, ViewStyle } from 'react-native'; import Icon from '../icon'; import { WithTheme, WithThemeStyles } from '../style'; import { BriefProps as BriefBasePropsType, ListItemPropsType } from './PropsType'; @@ -8,9 +8,11 @@ import ListStyles, { ListStyle } from './style/index'; export interface ListItemProps extends ListItemPropsType, WithThemeStyles { - onPress?: () => void; - onPressIn?: () => void; - onPressOut?: () => void; + onPress?: (event: GestureResponderEvent) => void; + onPressIn?: (event: GestureResponderEvent) => void; + onPressOut?: (event: GestureResponderEvent) => void; + delayLongPress?: number; + onLongPress?: (event: GestureResponderEvent) => void; style?: StyleProp; } @@ -47,6 +49,8 @@ export default class Item extends React.Component { static defaultProps: Partial = { multipleLine: false, wrap: false, + delayLongPress: 500, + onLongPress: () => {}, }; static Brief = Brief; render() { @@ -61,6 +65,8 @@ export default class Item extends React.Component { onPress, onPressIn, onPressOut, + onLongPress, + delayLongPress, wrap, disabled, align, @@ -221,6 +227,8 @@ export default class Item extends React.Component { } onPressIn={onPressIn} onPressOut={onPressOut} + onLongPress={onLongPress} + delayLongPress={delayLongPress} > {itemView}