react-native-weekly-calendar
React Native Weekly Calendar component with customization
Installation
yarn add react-native-weekly-calendar
Usage
;;; { const sampleEvents = 'start': '2020-03-23 09:00:00' 'duration': '00:20:00' 'note': 'Walk my dog' 'start': '2020-03-24 14:00:00' 'duration': '01:00:00' 'note': 'Doctor\'s appointment' 'start': '2020-03-25 08:00:00' 'duration': '00:30:00' 'note': 'Morning exercise' 'start': '2020-03-25 14:00:00' 'duration': '02:00:00' 'note': 'Meeting with client' 'start': '2020-03-25 19:00:00' 'duration': '01:00:00' 'note': 'Dinner with family' 'start': '2020-03-26 09:30:00' 'duration': '01:00:00' 'note': 'Schedule 1' 'start': '2020-03-26 11:00:00' 'duration': '02:00:00' 'note': 'Schedule 2' 'start': '2020-03-26 15:00:00' 'duration': '01:30:00' 'note': 'Schedule 3' 'start': '2020-03-26 18:00:00' 'duration': '02:00:00' 'note': 'Schedule 4' 'start': '2020-03-26 22:00:00' 'duration': '01:00:00' 'note': 'Schedule 5' return <View style=stylescontainer> <WeeklyCalendar events=sampleEvents style= height: 400 /> </View> ;} const styles = StyleSheet;
Select Date
Change Week
Pick Date (iOS & Android)
Properties
All properties are optional.
Prop | Default | PropTypes | Description |
---|---|---|---|
selected | moment() |
string or Date or Moment |
Set initially selected day. Format for string: 'YYYY-MM-DD'. Date and Moment instance are allowed as well. Default provides Moment instance of today |
startWeekday | 7 |
number |
Set which weekday to render first. If firstDay = 1, week starts from Monday. If firstDay = 7, week starts from Sunday. |
titleFormat | undefined |
string |
Set format to display title (e.g. titleFormat='MMM YYYY' displays "Jan 2020") |
weekdayFormat | 'ddd' |
string |
Set format to display weekdays (e.g. weekdayFormat='dd' displays "Mo" and weekdayFormat='ddd' displays "Mon") |
locale | 'en' |
string |
Set locale (e.g. Korean='ko', English='en', Chinese(Mandarin)='zh-cn', etc.) |
events | [] |
array |
Set list of events you want to display below weekly calendar. Default is empty array []. |
renderEvent | undefined |
func |
Specify how each event should be rendered below weekly calendar. Event & index are given as parameters. |
renderFirstEvent | undefined |
func |
Specify how first event should be rendered below weekly calendar. Event & index are given as parameters. |
renderLastEvent | undefined |
func |
Specify how last event should be rendered below weekly calendar. Event & index are given as parameters. |
renderDay | undefined |
func |
Specify how day should be rendered below weekly calendar. Event Views, day (Moment object), index are given as parameters. |
renderFirstDay | undefined |
func |
Specify how first day should be rendered below weekly calendar. Event Views, day (Moment object), index are given as parameters. |
renderLastDay | undefined |
func |
Specify how last day should be rendered below weekly calendar. Event Views, day (Moment object), index are given as parameters. |
onDayPress | undefined |
func |
Handler which gets executed on day press. Default = undefined |
themeColor | '#46c3ad' |
string |
Set theme color. Either color code or color name that is registered in RN StyleSheet works. |
style | {} |
object |
Set style of WeeklyCalendar component |
titleStyle | {} |
object |
Set text style of calendar title |
dayLabelStyle | {} |
object |
Set text style of weekday labels |
Customization
<View style=stylescontainer> <WeeklyCalendar events=sampleEvents selected='2020-03-23' startWeekday=7 weekdayFormat='ddd' locale='ko' renderEvent= { let startTime = let duration = eventduration let seconds = * 3600 + * 60 + let endTime = return <View key=j> <View style=stylesevent> <View style=styleseventDuration> <View style=stylesdurationContainer> <View style=stylesdurationDot /> <Text style=stylesdurationText>startTime</Text> </View> <View style= paddingTop: 10 /> <View style=stylesdurationContainer> <View style=stylesdurationDot /> <Text style=stylesdurationText>endTime</Text> </View> <View style=stylesdurationDotConnector /> </View> <View style=styleseventNote> <Text style=styleseventText>eventnote</Text> </View> </View> <View style=styleslineSeparator /> </View> } renderLastEvent= { let startTime = let duration = eventduration let seconds = * 3600 + * 60 + let endTime = return <View key=j> <View style=stylesevent> <View style=styleseventDuration> <View style=stylesdurationContainer> <View style=stylesdurationDot /> <Text style=stylesdurationText>startTime</Text> </View> <View style= paddingTop: 10 /> <View style=stylesdurationContainer> <View style=stylesdurationDot /> <Text style=stylesdurationText>endTime</Text> </View> <View style=stylesdurationDotConnector /> </View> <View style=styleseventNote> <Text style=styleseventText>eventnote</Text> </View> </View> </View> } renderDay= <View key=i style=stylesday> <View style=stylesdayLabel> <Text style=stylesmonthDateText color: 'pink' >weekdayToAdd</Text> <Text style=stylesdayText color: 'pink' >weekdayToAdd</Text> </View> <View style=stylesallEvents eventViewslength === 0 ? width: '100%' backgroundColor: 'pink' : {}> eventViews </View> </View> onDayPress= { console } themeColor='pink' style= height: 400 titleStyle= color: 'blue' dayLabelStyle= color: 'green' /></View>