f-react-native-schedule
Version:
Flexible scheduling library with more built-in features and enhanced customization options
54 lines (51 loc) • 1.64 kB
JavaScript
function _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); }
import React, { useContext } from 'react';
import { TouchableOpacity, StyleSheet, View } from 'react-native';
import { defaultCellSettings } from '../constants';
import ScheduleContext from '../ScheduleContext';
const Cell = _ref => {
let {
date,
style: styleProp,
...props
} = _ref;
const {
cellSettings,
onCellPress,
onCellLongPress
} = useContext(ScheduleContext);
const {
render,
style
} = cellSettings;
const touchableOpacityProps = { ...(typeof onCellPress === 'function' && {
onPress: event => onCellPress(date, event)
}),
...(typeof onCellLongPress === 'function' && {
onLongPress: event => onCellLongPress(date, event)
})
};
return /*#__PURE__*/React.createElement(TouchableOpacity, _extends({
style: [styles.container, styleProp]
}, props, touchableOpacityProps), /*#__PURE__*/React.createElement(View, {
style: [styles.content, style]
}, render && render(date)));
};
const styles = StyleSheet.create({
container: {
position: 'absolute',
alignItems: 'center',
justifyContent: 'center',
height: 80,
width: 100,
borderWidth: 1,
borderBottomWidth: 0,
borderLeftWidth: 0,
...defaultCellSettings.style
},
content: {
flex: 1
}
});
export default Cell;
//# sourceMappingURL=Cell.js.map