التنقل
Bottom Sheet
استخدام Bottom Sheet لعرض محتوى منبثق من أسفل الشاشة
Bottom Sheet
Bottom Sheet هو نمط شائع في تطبيقات الموبايل لعرض محتوى إضافي من أسفل الشاشة.
التثبيت
npx expo install @gorhom/bottom-sheet react-native-reanimated react-native-gesture-handlerالاستخدام الأساسي
import { useCallback, useMemo, useRef } from 'react';
import { View, Text, Button } from 'react-native';
import BottomSheet from '@gorhom/bottom-sheet';
export default function App() {
const bottomSheetRef = useRef<BottomSheet>(null);
const snapPoints = useMemo(() => ['25%', '50%'], []);
const handleOpen = useCallback(() => {
bottomSheetRef.current?.expand();
}, []);
return (
<View style={{ flex: 1 }}>
<Button title="افتح" onPress={handleOpen} />
<BottomSheet
ref={bottomSheetRef}
snapPoints={snapPoints}
backgroundStyle={{ backgroundColor: '#1a1a2e' }}
handleIndicatorStyle={{ backgroundColor: '#a78bfa' }}
>
<View style={{ padding: 16 }}>
<Text style={{ color: '#fff' }}>محتوى البوتوم شيت</Text>
</View>
</BottomSheet>
</View>
);
}الخطوة التالية
تعلم كيفية تنسيق واجهة المستخدم باستخدام NativeWind.