Skip to content

Conversation

@avishain
Copy link
Contributor

@avishain avishain commented Apr 24, 2025

Description

New component - addition to existing library.

The component name is SwipeableCards.
It receives the following props:

  • currentItem: T;
  • nextItems: T[];
  • onSwipe?: SwipeableCardProps['onSwipe'];
  • currentIndex: number;
  • renderNextCard: (nextItem: T) => JSX.Element;
  • renderRightCard: () => JSX.Element;
  • renderLeftCard: () => JSX.Element;
  • renderMainCard: () => JSX.Element;

Changelog

SwipeableCard - new component

Usage example

interface MyUseCaseSwipeableCardsProps extends MyUseCaseItemProps {
  items: MyUseCaseItem[];
  currentIndex: number;
}

const MyUseCaseSwipeableCards = (props: MyUseCaseSwipeableCardsProps) => {
  const {items, currentIndex} = props;

  const currentItem = items[currentIndex];
  const nextFeedItems = items.slice(currentIndex + 1, currentIndex + 5);

  const onSwipe = {
    right: () => {
      // DO SOMETHING 1
    },
    left: () => {
      // DO SOMETHING 2
    },
  };

  const renderMainCard = () => {
    return (
      <MyUseCaseItem item={currentItem} />
    );
  };

  const renderLeftCard = () => {
    return (
      <View flex center backgroundColor={Colors.red40}>
        <Text text20BL white>LEFT</Text>
      </View>
    );
  };
  const renderRightCard = () => {
    return (
      <View flex center backgroundColor={Colors.yellow40}>
        <Text text20BL white>RIGHT</Text>
      </View>
    );
  };

  const renderPlaceHolderCard = (item: MyUseCaseItemType) => {
    return (
      <View flex center>
        <Text text20BL white>{item.id}</Text>
        <Image source={Assets.illustrations.placeholderCover} size={125} />
      </View>
    );
  };

  return (
    <SwipeableCardsView
      nextItems={nextFeedItems}
      renderMainCard={renderMainCard}
      onSwipe={onSwipe}
      currentIndex={currentIndex}
      currentItem={currentItem}
      renderLeftCard={renderLeftCard}
      renderRightCard={renderRightCard}
      renderPlaceHolderCard={renderPlaceHolderCard}
    />
  );
};

export default MyUseCaseSwipeableCards;

Visuals



drawing

Additional info

None

@ethanshar ethanshar self-assigned this Apr 27, 2025
@M-i-k-e-l M-i-k-e-l self-requested a review April 30, 2025 05:58
@M-i-k-e-l M-i-k-e-l self-assigned this Apr 30, 2025
@stale
Copy link

stale bot commented Dec 17, 2025

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Dec 17, 2025
@M-i-k-e-l M-i-k-e-l removed the wontfix label Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants