Skip to content

Commit

Permalink
feat(ios): implement remove on longpress
Browse files Browse the repository at this point in the history
  • Loading branch information
Jesse Onolememen committed Mar 31, 2020
1 parent 64afb83 commit 83004c1
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/BubbleSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,15 @@ const RNBubbleSelect = requireNativeComponent('RNBubbleSelectView');
export type BubbleSelectProps = Omit<BubbleProps, 'text' | 'id'> & {
onSelect?: (bubble: BubbleNode) => void;
onDeselect?: (bubble: BubbleNode) => void;
onRemove?: (bubble: BubbleNode) => void;
bubbleSize?: number;
allowsMultipleSelection?: boolean;
children: React.ReactNode;
style?: object;
width?: number;
height?: number;
removeOnLongPress?: boolean;
longPressDuration?: number;
};

const BubbleSelect = ({
Expand All @@ -22,6 +25,9 @@ const BubbleSelect = ({
allowsMultipleSelection,
children,
bubbleSize,
onRemove,
removeOnLongPress,
longPressDuration,
width = 200,
height = 200,
...bubbleProps
Expand All @@ -33,7 +39,6 @@ const BubbleSelect = ({
};

const handleSelect = (event: NativeSyntheticEvent<BubbleNode>) => {
console.log(event);
if (onSelect) {
onSelect(event.nativeEvent);
}
Expand All @@ -45,13 +50,22 @@ const BubbleSelect = ({
}
};

const handleRemove = (event: NativeSyntheticEvent<BubbleNode>) => {
if (onRemove) {
onRemove(event.nativeEvent);
}
};

return (
<RNBubbleSelect
style={[defaultStyle, style]}
allowsMultipleSelection={allowsMultipleSelection}
onSelect={handleSelect}
onDeselect={handleDeselect}
onRemove={handleRemove}
bubbleSize={bubbleSize}
removeNodeOnLongPress={removeOnLongPress}
longPressDuration={longPressDuration}
>
{React.Children.map(children, (child: any) =>
React.cloneElement(child, bubbleProps)
Expand Down

0 comments on commit 83004c1

Please sign in to comment.