From aba5c66eb469757aded9b04021d2cbbe49655660 Mon Sep 17 00:00:00 2001 From: Nouman Tahir Date: Tue, 11 Oct 2022 17:34:02 +0500 Subject: [PATCH] support for long press quick reply modal --- .../view/textWithIcon/textWithIconView.js | 2 ++ .../postView/view/postDisplayView.tsx | 25 ++++++++++--------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/components/basicUIElements/view/textWithIcon/textWithIconView.js b/src/components/basicUIElements/view/textWithIcon/textWithIconView.js index 7647e4b18..4891b9dea 100644 --- a/src/components/basicUIElements/view/textWithIcon/textWithIconView.js +++ b/src/components/basicUIElements/view/textWithIcon/textWithIconView.js @@ -13,6 +13,7 @@ const TextWithIcon = ({ iconSize, wrapperStyle, textStyle, + onLongPress, }) => { const [ltext, setLtext] = useState(text); useEffect(() => { @@ -25,6 +26,7 @@ const TextWithIcon = ({ underlayColor="transparent" disabled={!isClickable || !onPress} onPress={() => onPress && onPress()} + onLongPress={() => onLongPress && onLongPress()} > (); const commentsReached = useRef(false); - const [postHeight, setPostHeight] = useState(0); const [scrollHeight, setScrollHeight] = useState(0); const [cacheVoteIcrement, setCacheVoteIcrement] = useState(0); @@ -89,29 +88,32 @@ const PostDisplayView = ({ const _handleOnScroll = (event) => { const { y } = event.nativeEvent.contentOffset; - console.log("scroll height", y) + console.log('scroll height', y); setScrollHeight(HEIGHT + y); - const _commentButtonBounceOffset = y + (HEIGHT/1.7); - if(!commentsReached.current && commentsRef.current && _commentButtonBounceOffset > postHeight ){ + const _commentButtonBounceOffset = y + HEIGHT / 1.7; + if ( + !commentsReached.current && + commentsRef.current && + _commentButtonBounceOffset > postHeight + ) { commentsRef.current.bounceCommentButton(); commentsReached.current = true; } }; - const _handleOnPostLayout = (event) => { const { height } = event.nativeEvent.layout; - console.log('post height', height) + console.log('post height', height); setPostHeight(height); }; const _scrollToComments = () => { - if(scrollRef.current){ + if (scrollRef.current) { const pos = postHeight; - scrollRef.current.scrollTo({y:pos}) + scrollRef.current.scrollTo({ y: pos }); } - } + }; const _handleOnReblogsPress = () => { if (reblogs.length > 0 && handleOnReblogsPress) { @@ -160,8 +162,8 @@ const PostDisplayView = ({ isClickable text={get(post, 'children', 0)} textMarginLeft={20} + onLongPress={_showQuickReplyModal} onPress={() => _scrollToComments()} - // onPress={() => handleOnReplyPress && handleOnReplyPress()} /> )} {!isLoggedIn && ( @@ -279,8 +281,7 @@ const PostDisplayView = ({ )} {post && !postBodyLoading && (isGetComment || isLoadedComments) && ( - -