fix - comments bottom sheet

This commit is contained in:
Victor
2025-09-17 14:21:33 +02:00
parent 12f87f0c92
commit 5872e47f18
@@ -3,6 +3,7 @@ import {
BottomSheetBackdrop, BottomSheetBackdrop,
BottomSheetModal, BottomSheetModal,
BottomSheetScrollView, BottomSheetScrollView,
BottomSheetTextInput,
} from '@gorhom/bottom-sheet'; } from '@gorhom/bottom-sheet';
import { BlurView } from 'expo-blur'; import { BlurView } from 'expo-blur';
import { Image as ExpoImage } from 'expo-image'; import { Image as ExpoImage } from 'expo-image';
@@ -18,7 +19,6 @@ import {
Platform, Platform,
Pressable, Pressable,
Text, Text,
TextInput,
View, View,
KeyboardAvoidingView, KeyboardAvoidingView,
} from 'react-native'; } from 'react-native';
@@ -86,6 +86,13 @@ const CommentsBottomSheet = () => {
const snapPoints = useMemo(() => ['90%'], []); const snapPoints = useMemo(() => ['90%'], []);
const INPUT_HEIGHT = 54;
const INPUT_MARGIN_VERTICAL = 12;
const bottomPadding = useMemo(
() => INPUT_HEIGHT + INPUT_MARGIN_VERTICAL + (insets?.bottom || 0) + 12,
[insets?.bottom]
);
const commentsRef = useMemo(() => { const commentsRef = useMemo(() => {
try { try {
return projectId return projectId
@@ -237,10 +244,11 @@ const CommentsBottomSheet = () => {
Commentaires Commentaires
</Text> </Text>
</View> </View>
<View style={{ flex: 1 }}>
<BottomSheetScrollView <BottomSheetScrollView
ref={scrollRef} ref={scrollRef}
keyboardShouldPersistTaps='handled' keyboardShouldPersistTaps='handled'
keyboardDismissMode='interactive'
onContentSizeChange={() => { onContentSizeChange={() => {
if (typing) { if (typing) {
try { try {
@@ -252,7 +260,7 @@ const CommentsBottomSheet = () => {
scrollEventThrottle={100} scrollEventThrottle={100}
contentContainerStyle={{ contentContainerStyle={{
paddingHorizontal: 14, paddingHorizontal: 14,
paddingBottom: (insets?.bottom || 0) + 40, paddingBottom: bottomPadding,
}} }}
showsVerticalScrollIndicator> showsVerticalScrollIndicator>
{Array.isArray(comments) && comments.length > 0 ? ( {Array.isArray(comments) && comments.length > 0 ? (
@@ -291,7 +299,9 @@ const CommentsBottomSheet = () => {
color: Palette.white, color: Palette.white,
fontFamily: FONT_FAMILY.InterMedium, fontFamily: FONT_FAMILY.InterMedium,
}}> }}>
{c?.userId === currentUID ? 'vous' : c?.userName || ''} {c?.userId === currentUID
? 'vous'
: c?.userName || ''}
</Text> </Text>
<Text <Text
style={{ style={{
@@ -327,9 +337,15 @@ const CommentsBottomSheet = () => {
Aucun commentaire pour le moment Aucun commentaire pour le moment
</Text> </Text>
)} )}
</BottomSheetScrollView>
{/* INPUT en bas du contenu */} <View
<View style={{ height: 12 }} /> style={{
position: 'absolute',
left: 14,
right: 14,
bottom: (insets?.bottom || 0) + INPUT_MARGIN_VERTICAL,
}}>
<BlurView <BlurView
intensity={Platform.OS !== 'ios' ? 10 : 20} intensity={Platform.OS !== 'ios' ? 10 : 20}
style={{ style={{
@@ -339,14 +355,14 @@ const CommentsBottomSheet = () => {
paddingHorizontal: 16, paddingHorizontal: 16,
backgroundColor: Palette.glass, backgroundColor: Palette.glass,
overflow: 'hidden', overflow: 'hidden',
height: 54, height: INPUT_HEIGHT,
borderRadius: 16, borderRadius: 16,
}} }}
// experimentalBlurMethod={ // experimentalBlurMethod={
// Platform.OS !== "ios" ? "dimezisBlurView" : "none" // Platform.OS !== "ios" ? "dimezisBlurView" : "none"
// } // }
> >
<TextInput <BottomSheetTextInput
placeholder='Ajouter un commentaire' placeholder='Ajouter un commentaire'
placeholderTextColor='#FFFFFFAA' placeholderTextColor='#FFFFFFAA'
value={text} value={text}
@@ -355,11 +371,6 @@ const CommentsBottomSheet = () => {
}} }}
onFocus={() => { onFocus={() => {
setTyping(true); setTyping(true);
setTimeout(() => {
try {
scrollRef.current?.scrollToEnd?.({ animated: true });
} catch {}
}, 50);
}} }}
onBlur={() => setTyping(false)} onBlur={() => setTyping(false)}
style={{ style={{
@@ -377,8 +388,8 @@ const CommentsBottomSheet = () => {
/> />
</Pressable> </Pressable>
</BlurView> </BlurView>
<View style={{ height: (insets?.bottom || 0) + 24 }} /> </View>
</BottomSheetScrollView> </View>
</KeyboardAvoidingView> </KeyboardAvoidingView>
</BlurView> </BlurView>
</BottomSheetModal> </BottomSheetModal>