import React from "react"; import {Animated, StyleSheet, Text, View} from "react-native"; import {HoursProps} from "../types"; const HourNumbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24]; function Hours({ offsetX, columnDays, columnWidth, linesTopOffset, linesLeftOffset, fromHour, toHour, hourHeight, timeWidth, is12Hour, timeStyle, timeContainerStyle, linesStyle, renderHour, }: HoursProps) { const timeFontSize = timeStyle?.fontSize || 14; const renderTime = (hour: number) => { if (is12Hour) { switch (hour) { case 0: case 24: return '12 am'; case 12: return '12 pm'; default: return (hour > 12 ? (hour - 12 + ' pm') : hour + ' am'); } } return (hour > 9 ? '' : '0') + (hour === 24 ? '00' : hour) + ':00'; }; return ( {HourNumbers.map((hour, rowIndex) => hour >= fromHour && hour <= toHour && ( {!!renderHour && renderHour(hour)} {!renderHour && ( {renderTime(hour)} )} {/* Day columns / hour lines */} {columnDays.map((day, columnIndex) => ( ))} ))} ); } const styles = StyleSheet.create({ row: { flexDirection: 'row', }, timeContainer: { position: 'absolute', zIndex: 3, top: 9, justifyContent: 'center', alignItems: 'center', paddingHorizontal: 1, backgroundColor: 'white', }, }); export default Hours;