import React from 'react';
import { StyleSheet, Text, Pressable, View } from 'react-native';
import Example from '../../shared/example';
const log = (...msg) => {
console.log(...msg);
};
const l1 = { width: '100%', paddingLeft: 0, paddingTop: 0 };
const l2 = { width: '75%', paddingLeft: 10, paddingTop: 10 };
function Box({ pointerEvents }) {
return (
[
styles.box,
pressed && styles.purple,
pointerEventsStyles[pointerEvents]
]}
>
[styles.content, pressed && styles.orange]}
>
{pointerEvents}
);
}
export default function ViewPage() {
const [layoutInfo, setLayoutInfo] = React.useState({});
const [layoutStyle, setLayoutStyle] = React.useState(l1);
React.useEffect(() => {
const interval = setInterval(() => {
setLayoutStyle((l) => (l.width === '100%' ? l2 : l1));
}, 2500);
return () => {
clearInterval(interval);
};
}, []);
const handleLayout = ({ nativeEvent }) => {
setLayoutInfo(() => ({ ...nativeEvent.layout }));
};
return (
onLayout
{JSON.stringify(layoutInfo, null, 2)}
pointerEvents
);
}
const styles = StyleSheet.create({
container: {
alignSelf: 'stretch',
padding: 10
},
heading: {
fontWeight: 'bold',
marginVertical: '1rem'
},
layoutContainer: {
marginBottom: '1rem'
},
layoutBox: {
backgroundColor: '#FFAD1F',
height: 50
},
boxContainer: {
height: 50
},
box: {
backgroundColor: '#ececec',
padding: 30,
marginVertical: 5,
userSelect: 'none'
},
content: {
backgroundColor: 'white',
padding: 10,
borderWidth: 1,
borderColor: 'black',
borderStyle: 'solid',
userSelect: 'none'
},
orange: {
backgroundColor: 'orange'
},
purple: {
backgroundColor: 'purple'
}
});
const pointerEventsStyles = StyleSheet.create({
auto: {
pointerEvents: 'auto'
},
none: {
pointerEvents: 'none'
},
'box-only': {
pointerEvents: 'box-only'
},
'box-none': {
pointerEvents: 'box-none'
}
});