react-native-week-schedule-1
Version:
50 lines (49 loc) • 1.17 kB
JavaScript
;
import { memo, useMemo } from "react";
import { Pressable, View } from "react-native";
import { getStyles } from "./styles.js";
import { grid } from "../../utils/grid.js";
import { jsx as _jsx } from "react/jsx-runtime";
const WEEK = [0, 1, 2, 3, 4, 5, 6];
;
;
export const GridRow = /*#__PURE__*/memo(({
index,
onPress
}) => {
const styles = useMemo(() => getStyles(), []);
return /*#__PURE__*/_jsx(View, {
style: styles.container,
children: WEEK.map(item => /*#__PURE__*/_jsx(GridItem, {
item: item,
disabled: !onPress,
index: index,
onPress: onPress
}, item))
});
});
const GridItem = ({
item,
index,
disabled,
onPress
}) => {
const styles = useMemo(() => getStyles(), []);
const handleOnPress = () => {
onPress?.({
day: item,
time: grid.hours[index] || ''
});
};
return /*#__PURE__*/_jsx(Pressable, {
disabled: disabled,
style: ({
pressed
}) => [styles.cell, {
borderBottomWidth: index === 23 ? 1 : 0,
backgroundColor: pressed ? grid.colors.primary : undefined
}],
onPress: handleOnPress
});
};
//# sourceMappingURL=index.js.map