Last active
July 25, 2022 13:53
-
-
Save jai-adapptor/7b5effcfd9a594dc36b2b8c65b68f6fe to your computer and use it in GitHub Desktop.
2: Heights
This file contains hidden or 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
| 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