Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add onLongPress to ListItem #619

Merged
merged 1 commit into from
Aug 27, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions components/list/ListItem.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -8,9 +8,11 @@ import ListStyles, { ListStyle } from './style/index';
export interface ListItemProps
extends ListItemPropsType,
WithThemeStyles<ListStyle> {
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<ViewStyle>;
}

Expand Down Expand Up @@ -47,6 +49,8 @@ export default class Item extends React.Component<ListItemProps, any> {
static defaultProps: Partial<ListItemProps> = {
multipleLine: false,
wrap: false,
delayLongPress: 500,
onLongPress: () => {},
};
static Brief = Brief;
render() {
Expand All @@ -61,6 +65,8 @@ export default class Item extends React.Component<ListItemProps, any> {
onPress,
onPressIn,
onPressOut,
onLongPress,
delayLongPress,
wrap,
disabled,
align,
Expand Down Expand Up @@ -221,6 +227,8 @@ export default class Item extends React.Component<ListItemProps, any> {
}
onPressIn={onPressIn}
onPressOut={onPressOut}
onLongPress={onLongPress}
delayLongPress={delayLongPress}
>
{itemView}
</TouchableHighlight>
Expand Down