diff options
| author | Ivan Chen <ivan@tagg.id> | 2021-06-11 15:41:50 -0400 |
|---|---|---|
| committer | Ivan Chen <ivan@tagg.id> | 2021-06-11 15:41:50 -0400 |
| commit | e4dd6cf05a631197be4d192901d532e8625900bb (patch) | |
| tree | 83638a5a2803c9ca2a4a491dd37180871f3cbdde /src/components/moments | |
| parent | eb672872d85f203085c96005758314d5dba359f2 (diff) | |
Cleanup scrolling logic, Fix scrollTo logic
Diffstat (limited to 'src/components/moments')
| -rw-r--r-- | src/components/moments/MomentPostContent.tsx | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/components/moments/MomentPostContent.tsx b/src/components/moments/MomentPostContent.tsx index da04211f..89f2a281 100644 --- a/src/components/moments/MomentPostContent.tsx +++ b/src/components/moments/MomentPostContent.tsx @@ -49,8 +49,8 @@ const MomentPostContent: React.FC<MomentPostContentProps> = ({ ); const [commentPreview, setCommentPreview] = useState<MomentCommentPreviewType | null>(moment.comment_preview); - const {keyboardVisible, currentScrollToIndex, scrollTo} = - useContext(MomentContext); + const {keyboardVisible, scrollTo} = useContext(MomentContext); + const [hideText, setHideText] = useState(false); useEffect(() => { setTags(momentTags); @@ -67,6 +67,12 @@ const MomentPostContent: React.FC<MomentPostContentProps> = ({ fade(); }, [fadeValue]); + useEffect(() => { + if (!keyboardVisible && hideText) { + setHideText(false); + } + }, [keyboardVisible, hideText]); + return ( <View style={[styles.container, style]}> <TouchableWithoutFeedback @@ -97,7 +103,7 @@ const MomentPostContent: React.FC<MomentPostContentProps> = ({ /> </Animated.View> )} - {(!keyboardVisible || currentScrollToIndex !== index) && ( + {!hideText && ( <> {moment.caption !== '' && renderTextWithMentions({ @@ -130,7 +136,11 @@ const MomentPostContent: React.FC<MomentPostContentProps> = ({ comment: message, }) } - onFocus={() => scrollTo(index)} + onFocus={() => { + setHideText(true); + scrollTo(index); + }} + isKeyboardAvoiding={false} theme={'dark'} /> <Text style={styles.text}>{getTimePosted(moment.date_created)}</Text> |
