Skip to content

Instantly share code, notes, and snippets.

@ivandotv
Created October 17, 2023 13:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivandotv/bce767706f9318d0521e65d4632d53b7 to your computer and use it in GitHub Desktop.
Save ivandotv/bce767706f9318d0521e65d4632d53b7 to your computer and use it in GitHub Desktop.
Bottom sheet popup modal
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