UNPKG

1.52 kBJavaScriptView Raw
1function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
2
3import * as React from 'react';
4import { StyleSheet, View } from 'react-native';
5// This component will render a page which overflows the screen
6// if the container fills the body by comparing the size
7// This lets the document.body handle scrolling of the content
8// It's necessary for mobile browsers to be able to hide address bar on scroll
9export default /*#__PURE__*/React.forwardRef(function CardSheet(_ref, ref) {
10 let {
11 enabled,
12 layout,
13 style,
14 ...rest
15 } = _ref;
16 const [fill, setFill] = React.useState(false);
17 React.useEffect(() => {
18 if (typeof document === 'undefined' || !document.body) {
19 // Only run when DOM is available
20 return;
21 }
22
23 const width = document.body.clientWidth;
24 const height = document.body.clientHeight;
25 setFill(width === layout.width && height === layout.height);
26 }, [layout.height, layout.width]);
27 return /*#__PURE__*/React.createElement(View, _extends({}, rest, {
28 ref: ref,
29 style: [enabled && fill ? styles.page : styles.card, style]
30 }));
31});
32const styles = StyleSheet.create({
33 page: {
34 minHeight: '100%'
35 },
36 card: {
37 flex: 1,
38 overflow: 'hidden'
39 }
40});
41//# sourceMappingURL=CardSheet.js.map
\No newline at end of file