|
1 | | -https://github.com/prolificinteractive/material-calendarview |
| 1 | +# React-native-material-calendarview |
| 2 | + |
| 3 | +A simple material calendar for react native android |
| 4 | + |
| 5 | +## Installation Android |
| 6 | +- `npm install --save ...` |
| 7 | + |
| 8 | +- In `android/settings.gradle` |
| 9 | + |
| 10 | + ```gradle |
| 11 | + ... |
| 12 | + include ':ReactMaterialCalendarView', ':app' |
| 13 | + project(':ReactMaterialCalendarView').projectDir = new File(rootProject.projectDir, '../node_modules/.../app') |
| 14 | + ``` |
| 15 | +
|
| 16 | +- In `android/app/build.gradle` |
| 17 | +
|
| 18 | + ```gradle |
| 19 | + ... |
| 20 | + dependencies { |
| 21 | + ... |
| 22 | + compile project(':ReactMaterialCalendarView') |
| 23 | + } |
| 24 | + ``` |
| 25 | +
|
| 26 | +- Register module (in MainApplication.java) |
| 27 | +
|
| 28 | + ```java |
| 29 | + import com.nucllear.rn_materialcalendarview.ReactMaterialCalendarViewPackage; // <----- import package |
| 30 | +
|
| 31 | + public class MainApplication extends Application implements ReactApplication { |
| 32 | + ... |
| 33 | +
|
| 34 | + @Override |
| 35 | + protected List<ReactPackage> getPackages() { |
| 36 | + return Arrays.<ReactPackage>asList( |
| 37 | + new MainReactPackage(), |
| 38 | + new ReactMaterialCalendarViewPackage() // <------ add package here |
| 39 | + ); |
| 40 | + } |
| 41 | + } |
| 42 | + ``` |
| 43 | +
|
| 44 | +## Usage |
| 45 | +
|
| 46 | +```js |
| 47 | +
|
| 48 | +import Calendar from '...'; |
| 49 | +... |
| 50 | +
|
| 51 | + render() { |
| 52 | + return ( |
| 53 | + <Calendar |
| 54 | + width={(Dimensions.get('window').width)-32} |
| 55 | + height={280} |
| 56 | + tileHeight={35} |
| 57 | + style={{alignSelf: 'center'}} |
| 58 | + topbarVisible={true} |
| 59 | + datesSelection={'single'} |
| 60 | + arrowColor="#DAFACD" |
| 61 | + firstDayOfWeek="monday" |
| 62 | + currentDate={this.state.today} |
| 63 | + selectionColor="#FF3430" |
| 64 | + selectedDates={this.state.dates} |
| 65 | + weekendsDecorator={true} |
| 66 | + eventsDates={["2016/11/20", "2016/11/29"]} |
| 67 | + onDateChange={ |
| 68 | + (data) => { |
| 69 | + this.setState({ |
| 70 | + dates: [data.date] |
| 71 | + }) |
| 72 | + } |
| 73 | + } |
| 74 | + /> |
| 75 | + ) |
| 76 | + } |
| 77 | +``` |
| 78 | + |
| 79 | +## Props |
| 80 | + |
| 81 | +* Size |
| 82 | + - *Integer* **width** (required) |
| 83 | + Provide the width of the calendar. |
| 84 | + |
| 85 | + - *Integer* **height** |
| 86 | + Provide the height. Default will be calculated based on width and ```topbarVisible```. |
| 87 | + |
| 88 | + - *Integer* **tileWidth** |
| 89 | + Provide the width of one day tile. Set width id DP. |
| 90 | + |
| 91 | + - *Integer* **tileHeight** |
| 92 | + Provide the height of one day tile. Set height id DP. |
| 93 | + |
| 94 | + - *Integer* **tileSize** |
| 95 | + Provide the size (width and height) of one day tile. Set size id DP. |
| 96 | + |
| 97 | +* Toolbar options |
| 98 | + - *boolean* **topbarVisible** (default = true) |
| 99 | + Show/hide the top bar which contains the month's title and arrows to go to previous or next months. |
| 100 | + |
| 101 | + - *String* **arrowColor** (format #RRGGBB of #AARRGGBB) |
| 102 | + A string color. It changes color of the top bar's arrows. |
| 103 | + |
| 104 | +* Calendar config |
| 105 | + - *String* **firstDayOfWeek** (default = 'sunday') |
| 106 | + Set the first day of the week. |
| 107 | + Should be one of [ ‘monday’, ‘tuesday’, ‘wednesday’, ‘thursday’, ‘friday’, ‘saturday’, ‘sunday’ ] |
| 108 | + |
| 109 | + - *String* **minimumDate** (format 'yyyy/mm/dd') |
| 110 | + Set minimum date for calendar. |
| 111 | + |
| 112 | + - *String* **maximumDate** (format 'yyyy/mm/dd') |
| 113 | + Set maximum date for calendar. |
| 114 | + |
| 115 | + - *String* **datesSelection** |
| 116 | + Set the selection mode. |
| 117 | + - *none*: you cannot select date |
| 118 | + - *range*: you can select range of dates |
| 119 | + - *single*: you can only select one date at a time |
| 120 | + - *multiple*: you can select multiple dates |
| 121 | + |
| 122 | + - *String* **showOtherDates** (default = 'current') |
| 123 | + Show dates from previous and current months or show dates within current month. |
| 124 | + - *all*: dates from previous and current months |
| 125 | + - *none*: show dates within current month |
| 126 | + |
| 127 | +* Set date |
| 128 | + - *String* **currentDate** (format 'yyyy/mm/dd') |
| 129 | + Set the focus of the calendar. |
| 130 | + |
| 131 | +* Color customizations |
| 132 | + - *String* **selectionColor** (format #RRGGBB of #AARRGGBB) |
| 133 | + Set the color of the selection circle. |
| 134 | + - *String* **weekendsColor** (format #RRGGBB of #AARRGGBB) |
| 135 | + Set the color of the weekend. |
| 136 | + |
| 137 | +## Event |
| 138 | + |
| 139 | +- onDateChange |
| 140 | +Called when user select/deselect a date. The returned data is |
| 141 | +```{ date: 'yyyy/mm/dd', selected: boolean }``` |
| 142 | +- onMonthChanged |
| 143 | +Called when user change a month. The returned data is |
| 144 | +```{month: int}``` |
| 145 | + |
| 146 | +-------------------------------- |
| 147 | +Feel free to [open an issue](https://github.com/NuclleaR/react-native-material-calendarview/issues). |
| 148 | +[Pull requests](https://github.com/NuclleaR/react-native-material-calendarview/pulls) are also welcome |
| 149 | + |
| 150 | +A lot of thanks to @prolificinteractive for their awesome [Material Calendar View](https://github.com/prolificinteractive/material-calendarview) |
0 commit comments