import { Text, TouchableRipple } from 'react-native-paper'
import { StyleSheet, View } from 'react-native'
import DayRange from './DayRange'
import { daySize } from './dateUtils'
import type { PaperTheme } from '../shared/utils'
import { memo, useCallback } from 'react'
function EmptyDayPure() {
return
}
export const EmptyDay = memo(EmptyDayPure)
function Day(props: {
theme: PaperTheme
textColorOnPrimary: string
day: number
month: number
year: number
selected: boolean
inRange: boolean
leftCrop: boolean
rightCrop: boolean
primaryColor: string
selectColor: string
isToday: boolean
disabled: boolean
onPressDate: (date: Date) => any
}) {
const {
day,
month,
year,
selected,
inRange,
leftCrop,
rightCrop,
onPressDate,
primaryColor,
selectColor,
isToday,
disabled,
theme,
} = props
const borderColor = theme.colors.primary
const onPress = useCallback(() => {
onPressDate(new Date(year, month, day))
}, [onPressDate, year, month, day])
// Determine text colors for M3
let baseTextColor
let finalTextColor
if (selected) {
baseTextColor = theme.colors.onPrimary
} else if (inRange && theme.dark) {
baseTextColor = theme.colors.onPrimaryContainer
} else {
baseTextColor = theme.colors.onSurface
}
if (isToday) {
finalTextColor = selected ? baseTextColor : theme.colors.primary
} else {
finalTextColor = baseTextColor
}
const textFont = theme.fonts.bodySmall
return (
{day}
)
}
const styles = StyleSheet.create({
button: {
width: daySize,
height: daySize,
overflow: 'hidden',
borderRadius: daySize / 2,
},
day: {
flexBasis: 0,
flex: 1,
borderRadius: daySize / 2,
width: daySize,
height: daySize,
justifyContent: 'center',
alignItems: 'center',
borderWidth: 1,
borderColor: 'transparent',
},
disabled: {
opacity: 0.3,
},
empty: {
flex: 1,
flexBasis: 0,
},
root: {
flexBasis: 0,
flex: 1,
justifyContent: 'center',
alignItems: 'center',
position: 'relative',
},
})
export default memo(Day)