Created
October 17, 2023 13:54
-
-
Save ivandotv/bce767706f9318d0521e65d4632d53b7 to your computer and use it in GitHub Desktop.
Bottom sheet popup modal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function Popup({ | |
showPopup, | |
setShowPopup, | |
}: { | |
showPopup: boolean | |
setShowPopup: (b: boolean) => void | |
}) { | |
const bottomSheetRef = useRef<BottomSheet>(null) | |
const popupSnappoints = ["30%"] | |
useEffect(() => { | |
if (showPopup) { | |
bottomSheetRef.current?.expand() | |
} else { | |
bottomSheetRef.current?.close() | |
} | |
}, [showPopup]) | |
return ( | |
<BottomSheet | |
index={-1} | |
enablePanDownToClose={false} | |
detached={true} | |
ref={bottomSheetRef} | |
style={styles.popup} | |
snapPoints={popupSnappoints} | |
// add bottom inset to elevate the sheet | |
bottomInset={60} | |
> | |
<View style={styles.contentContainer}> | |
<Text style={styles.popupText}>popup! </Text> | |
<Text style={styles.popupText}> 🎉</Text> | |
<View style={styles.btnWrap}> | |
<MyButton | |
onPress={() => { | |
setShowPopup(false) | |
}} | |
title="Close" | |
/> | |
</View> | |
</View> | |
</BottomSheet> | |
) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment