在React Native中為gorhom底部表單顯示陰影。
<p>我正在使用gorhom/react-native-bottom-sheet函式庫。我想在使用者向上或向下滑動底部表單時顯示陰影框。如何實現這一點?是否可能?目前我已經設定在isOpen時顯示,但我希望在滑動時顯示。我還嘗試將其包裝在Touchable元件中,當isPressed為true時顯示陰影框,但在移動底部表單時它並沒有起作用。 </p>
<pre class="brush:php;toolbar:false;">export default function BottomSheet() {
const [isPressed, setIsPressed] = useState(false);
const { t } = useTranslation();
const [isOpen, setIsOpen] = useState(false);
const bottomSheetModalRef = useRef(null);
const snapPoints = ["50%"];
function handlePresentModal() {
bottomSheetModalRef.current?.present();
setTimeout(() => {
setIsOpen(true);
}, 100);
}
return (
<>
<Button title="Present Modal" onPress={handlePresentModal} />
<BottomSheetModalProvider>
<StatusBar style="auto" />
<BottomSheetModal
ref={bottomSheetModalRef}
index={0}
snapPoints={snapPoints}
handleComponent={CustomHandler}
onDismiss={() => setIsOpen(false)}
>
<Spacer size={30} />
<BottomSheetScrollView contentContainerStyle={styles.contentContainer}>
//Content here
</BottomSheetScrollView>
</BottomSheetModal>
</BottomSheetModalProvider>
{isOpen && <ShadowBox />}
</>
);
}
const styles = StyleSheet.create({
contentContainer: {
paddingHorizontal: 16,
paddingBottom: 100,
},
});</pre>
<p><br /></p>