From 2d4642891defe3e75835e63c89ccdc733b635f54 Mon Sep 17 00:00:00 2001 From: Victor Date: Wed, 17 Sep 2025 10:13:12 +0200 Subject: [PATCH] fix - bottomSheet keyboard --- .../bottomsheets/CommentsBottomSheet.js | 320 ++++++++++-------- 1 file changed, 172 insertions(+), 148 deletions(-) diff --git a/src/components/bottomsheets/CommentsBottomSheet.js b/src/components/bottomsheets/CommentsBottomSheet.js index 1b868d9..c496692 100644 --- a/src/components/bottomsheets/CommentsBottomSheet.js +++ b/src/components/bottomsheets/CommentsBottomSheet.js @@ -20,6 +20,7 @@ import { Text, TextInput, View, + KeyboardAvoidingView, } from 'react-native'; import { useSafeAreaInsets } from 'react-native-safe-area-context'; import { icons } from '../../assets'; @@ -61,6 +62,7 @@ const CommentsBottomSheet = () => { const modalRef = useRef(null); const insets = useSafeAreaInsets(); const { currentUID, currentUserData } = useUser(); + const scrollRef = useRef(null); const [projectId, setProjectId] = useState(null); const [text, setText] = useState(''); @@ -82,7 +84,7 @@ const CommentsBottomSheet = () => { }; }, []); - const snapPoints = useMemo(() => ['50%', '90%'], []); + const snapPoints = useMemo(() => ['90%'], []); const commentsRef = useMemo(() => { try { @@ -156,7 +158,7 @@ const CommentsBottomSheet = () => { {...props} appearsOnIndex={0} disappearsOnIndex={-1} - pressBehavior="close" + pressBehavior='close' /> ), [] @@ -183,11 +185,11 @@ const CommentsBottomSheet = () => { { // Platform.OS !== "ios" ? "dimezisBlurView" : "none" // } > - - modalRef.current?.dismiss?.()} - style={{ position: 'absolute', right: 10, top: 8, padding: 6 }} - hitSlop={8}> - - - - Commentaires - - - - - {Array.isArray(comments) && comments.length > 0 ? ( - comments.map((c) => ( - - {c?.profilePicture ? ( - - ) : ( - - )} - - - - {c?.userId === currentUID ? 'vous' : c?.userName || ''} - - - • {formatRelativeTime(c?.createdAt)} - - - - {c?.text} - - - - )) - ) : ( - - Aucun commentaire pour le moment - - )} - - {/* INPUT en bas du contenu */} - - - setTyping(true)} - onBlur={() => setTyping(false)} - style={{ - flex: 1, - color: Palette.white, - fontSize: 14, - fontFamily: FONT_FAMILY.InterRegular, - }} - /> - + + + modalRef.current?.dismiss?.()} + style={{ position: 'absolute', right: 10, top: 8, padding: 6 }} + hitSlop={8}> - - - + + Commentaires + + + + { + if (typing) { + try { + scrollRef.current?.scrollToEnd?.({ animated: true }); + } catch {} + } + }} + onScroll={handleScroll} + scrollEventThrottle={100} + contentContainerStyle={{ + paddingHorizontal: 14, + paddingBottom: (insets?.bottom || 0) + 40, + }} + showsVerticalScrollIndicator> + {Array.isArray(comments) && comments.length > 0 ? ( + comments.map((c) => ( + + {c?.profilePicture ? ( + + ) : ( + + )} + + + + {c?.userId === currentUID ? 'vous' : c?.userName || ''} + + + • {formatRelativeTime(c?.createdAt)} + + + + {c?.text} + + + + )) + ) : ( + + Aucun commentaire pour le moment + + )} + + {/* INPUT en bas du contenu */} + + + { + setText(t); + }} + onFocus={() => { + setTyping(true); + setTimeout(() => { + try { + scrollRef.current?.scrollToEnd?.({ animated: true }); + } catch {} + }, 50); + }} + onBlur={() => setTyping(false)} + style={{ + flex: 1, + color: Palette.white, + fontSize: 14, + fontFamily: FONT_FAMILY.InterRegular, + }} + /> + + + + + + + );