react-native-booking-calendar
Version:
calendar component for booking app
72 lines (66 loc) • 1.99 kB
JavaScript
import React from 'react';
import { Dimensions, StyleSheet, TouchableWithoutFeedback, View } from 'react-native';
const {
width: windowWidth
} = Dimensions.get('window');
const Row = ({
dateTimeObj,
defaultRow,
date,
timeString,
borderColor
}) => {
if (dateTimeObj && dateTimeObj[date.toFormat('kkkk-L-dd')] && dateTimeObj[date.toFormat('kkkk-L-dd')][timeString]) {
const onPress = () => {
const dateTime = date.plus({
hours: Number(timeString.substr(0, 2)),
minutes: Number(timeString.substr(3, 2))
});
dateTimeObj[date.toFormat('kkkk-L-dd')][timeString].onPress(dateTime);
};
return /*#__PURE__*/React.createElement(TouchableWithoutFeedback, {
onPress: onPress
}, /*#__PURE__*/React.createElement(View, {
style: [RowStyles.rowWrapper, {
borderColor: borderColor
}]
}, /*#__PURE__*/React.createElement(React.Fragment, null, dateTimeObj[date.toFormat('kkkk-L-dd')][timeString].row)));
}
if (defaultRow) {
const onPress = () => {
const dateTime = date.plus({
hours: Number(timeString.substr(0, 2)),
minutes: Number(timeString.substr(3, 2))
});
defaultRow.onPress(dateTime);
};
return /*#__PURE__*/React.createElement(TouchableWithoutFeedback, {
onPress: onPress
}, /*#__PURE__*/React.createElement(View, {
style: [RowStyles.rowWrapper, {
borderColor: borderColor
}]
}, /*#__PURE__*/React.createElement(React.Fragment, null, defaultRow.row)));
}
return /*#__PURE__*/React.createElement(View, {
style: [RowStyles.rowWrapper, {
borderColor: borderColor
}]
});
};
const RowStyles = StyleSheet.create({
rowWrapper: {
justifyContent: 'center',
alignItems: 'center',
borderRightWidth: 1,
// borderBottomWidth: 1,
borderTopWidth: 1,
height: 50,
width: windowWidth * 0.127
},
rowMark: {
fontSize: 20
}
});
export default Row;
//# sourceMappingURL=Row.js.map