Skip to content

Instantly share code, notes, and snippets.

@jai-adapptor
Last active July 25, 2022 13:53
Show Gist options
  • Select an option

  • Save jai-adapptor/7b5effcfd9a594dc36b2b8c65b68f6fe to your computer and use it in GitHub Desktop.

Select an option

Save jai-adapptor/7b5effcfd9a594dc36b2b8c65b68f6fe to your computer and use it in GitHub Desktop.
2: Heights
const Sheet: React.FC<SheetProps> = (props) => {
const [dimensions, setDimensions] = useState({ window, screen });
useEffect(() => {
// Watch for screen size changes and update the dimensions
const subscription = Dimensions.addEventListener(
'change',
({ window, screen }) => {
setDimensions({ window, screen });
},
);
return () => subscription?.remove();
});
// Fixed values (for snap positions)
const minHeight = props.minHeight || 120;
const maxHeight = props.maxHeight || dimensions.screen.height;
const expandedHeight = props.expandedHeight || dimensions.screen.height * 0.6;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment