UNPKG

react-native-plain-calendar

Version:
25 lines (24 loc) 1.23 kB
import * as dateFns from 'date-fns'; import * as React from 'react'; import { Text, View, } from 'react-native'; import { HeaderButton, } from './HeaderButton'; import { s } from './styles'; function Header({ onPrevMonth, currentMonth, onNextMonth, headerDateFormat, headerContainerStyle, headerTitleStyle, headerButtonStyle, HeaderComponent, HeaderButtonComponent, }) { const month = dateFns.format(currentMonth, headerDateFormat); if (HeaderComponent) { return (<HeaderComponent onPrevMonth={onPrevMonth} currentMonth={month} onNextMonth={onNextMonth}/>); } return (<View style={[s.header, headerContainerStyle]}> <HeaderButton type="prev" onPress={onPrevMonth} headerButtonStyle={headerButtonStyle} HeaderButtonComponent={HeaderButtonComponent}> Previous </HeaderButton> <View style={[s.headerContainers, s.headerTitleContainer]}> <Text style={[s.headerTitle, headerTitleStyle]}>{month}</Text> </View> <HeaderButton type="next" onPress={onNextMonth} headerButtonStyle={headerButtonStyle} HeaderButtonComponent={HeaderButtonComponent}> Next </HeaderButton> </View>); } const HeaderMemo = React.memo(Header); export { HeaderMemo as Header };