react-native-slideable-calendar
Version:
47 lines (46 loc) • 1.26 kB
JavaScript
import React from 'react';
import { View, Text, Dimensions } from 'react-native';
import { isToday } from 'date-fns';
const width = Dimensions.get('window').width;
const WEEK_en = ['月', '火', '水', '木', '金', '土', '日'];
export default ({ weekStartsOn, selectedDate }) => {
const week_localized = WEEK_en;
const weekStartsOnMinnor = weekStartsOn % 7;
const weekTranformed = [
...week_localized.slice(weekStartsOnMinnor),
...week_localized.slice(0, weekStartsOnMinnor)
];
return (
<View
style={{
width: '92%',
height: 20,
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
}}
>
{weekTranformed.map((day, index) => (
<View
style={{
flex: 1,
height: '100%',
alignItems: 'center',
justifyContent: 'center'
}}
key={day}
>
<Text
style={{
color: selectedDate.getDay() === index + 1 ? '#6666FF' : '#8FA2C0',
fontWeight: selectedDate.getDay() === index + 1 ? 'bold' : 'normal',
fontSize: 12
}}
>
{day}
</Text>
</View>
))}
</View>
);
};