From c632785010bf83f9266cebaab50a2d022b120724 Mon Sep 17 00:00:00 2001 From: Maher Aldous Date: Wed, 19 Jul 2023 19:42:34 +0200 Subject: [PATCH] Since the ViewProps will get removed from react native I fixed the code to work without it but in the future we need to use TypeScript --- SwipeCards.js | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/SwipeCards.js b/SwipeCards.js index 45ce746..376f961 100644 --- a/SwipeCards.js +++ b/SwipeCards.js @@ -11,15 +11,7 @@ import { styles } from "./Styles"; let currentIndex = {}; let guid = 0; -const actionShape = PropTypes.shape({ - show: PropTypes.bool, - view: PropTypes.element, // takes priority over text + color - containerStyle: ViewPropTypes.style, - textStyle: ViewPropTypes.style, - text: PropTypes.string, - color: PropTypes.string, - onAction: PropTypes.func, // triggered on action, given card data, must return true if success -}); + const defaultActionsProp = { yup: { show: true, text: "Yup!", color: "green" }, @@ -33,6 +25,16 @@ const mergeActionProps = (actionsProps) => ({ maybe: { ...defaultActionsProp.maybe, ...actionsProps.maybe }, }); +const actionShape = { + show: PropTypes.bool, + view: PropTypes.element, // takes priority over text + color + containerStyle: PropTypes.any, + textStyle: PropTypes.any, + text: PropTypes.string, + color: PropTypes.string, + onAction: PropTypes.func, // triggered on action, given card data, must return true if success +}; + export default class SwipeCards extends Component { constructor(props) { super(props); @@ -594,16 +596,16 @@ SwipeCards.propTypes = { stackOffsetY: PropTypes.number, renderNoMoreCards: PropTypes.func, actions: PropTypes.shape({ - yup: actionShape, - nope: actionShape, - maybe: actionShape, + yup: PropTypes.shape(actionShape), + nope: PropTypes.shape(actionShape), + maybe: PropTypes.shape(actionShape), }), onClickHandler: PropTypes.func, onDragStart: PropTypes.func, onDragRelease: PropTypes.func, cardRemoved: PropTypes.func, renderCard: PropTypes.func.isRequired, - style: ViewPropTypes.style, + style: PropTypes.any, dragY: PropTypes.bool, smoothTransition: PropTypes.bool, keyExtractor: PropTypes.func.isRequired,