Skip to content

Commit d9aad53

Browse files
author
Abdalla Mohamed Elabd
committed
Merge remote-tracking branch 'wix/master'
2 parents d1ae754 + e5b5e69 commit d9aad53

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1868
-765
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ node_modules
33
npm-debug.log
44
.idea
55
yarn.lock
6+
.vscode

README.md

Lines changed: 110 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -92,16 +92,22 @@ LocaleConfig.defaultLocale = 'fr';
9292
renderArrow={(direction) => (<Arrow />)}
9393
// Do not show days of other months in month page. Default = false
9494
hideExtraDays={true}
95-
// If hideArrows=false and hideExtraDays=false do not swich month when tapping on greyed out
95+
// If hideArrows=false and hideExtraDays=false do not switch month when tapping on greyed out
9696
// day from another month that is visible in calendar page. Default = false
9797
disableMonthChange={true}
9898
// If firstDay=1 week starts from Monday. Note that dayNames and dayNamesShort should still start from Sunday.
9999
firstDay={1}
100+
// Hide day names. Default = false
101+
hideDayNames={true}
102+
// Show week numbers to the left. Default = false
103+
showWeekNumbers={true}
100104
/>
101105
```
102106

103107
#### Date marking
104108

109+
**!Disclaimer!** Make sure that `markedDates` param is immutable. If you change `markedDates` object content but the reference to it does not change calendar update will not be triggered.
110+
105111
Dot marking
106112

107113
<kbd>
@@ -114,12 +120,37 @@ Dot marking
114120
markedDates={{
115121
'2012-05-16': {selected: true, marked: true},
116122
'2012-05-17': {marked: true},
117-
'2012-05-18': {disabled: true}
123+
'2012-05-18': {marked: true, dotColor: 'red'},
124+
'2012-05-19': {disabled: true}
118125
}}
119126
/>
120127
```
121128

122-
Interval marking
129+
You can customise a dot color for each day independently.
130+
131+
Multi-Dot marking
132+
133+
<kbd>
134+
<img height=50 src="https://github.com/wix-private/wix-react-native-calendar/blob/master/demo/marking4.png?raw=true">
135+
</kbd>
136+
137+
Use markingType = 'multi-dot' if you want to display more than one dot. Both the Calendar and CalendarList control support multiple dots by using 'dots' array in markedDates. The properties 'key' and 'color' are mandatory while 'selectedColor' is optional. If selectedColor is omitted then 'color' will be used for selected dates.
138+
```javascript
139+
const vacation = {key:'vacation', color: 'red', selectedColor: 'blue'};
140+
const massage = {key:'massage', color: 'blue', selectedColor: 'blue'};
141+
const workout = {key:'workout', color: 'green'};
142+
143+
<Calendar
144+
markedDates={{
145+
'2017-10-25': {dots: [vacation, massage, workout], selected: true},
146+
'2017-10-26': {dots: [massage, workout], disabled: true},
147+
}},
148+
markingType={'multi-dot'}
149+
/>
150+
```
151+
152+
153+
Period marking
123154

124155
<kbd>
125156
<img height=50 src="https://github.com/wix-private/wix-react-native-calendar/blob/master/demo/marking2.png?raw=true">
@@ -133,13 +164,13 @@ Interval marking
133164
<Calendar
134165
// Collection of dates that have to be colored in a special way. Default = {}
135166
markedDates={
136-
{'2012-05-20': [{textColor: 'green'}],
137-
'2012-05-22': [{startingDay: true, color: 'green'}],
138-
'2012-05-23': [{endingDay: true, color: 'green', textColor: 'gray'}],
139-
'2012-05-04': [{startingDay: true, color: 'green'}, {endingDay: true, color: 'green'}]
167+
{'2012-05-20': {textColor: 'green'},
168+
'2012-05-22': {startingDay: true, color: 'green'},
169+
'2012-05-23': {selected: true, endingDay: true, color: 'green', textColor: 'gray'},
170+
'2012-05-04': {disabled: true, startingDay: true, color: 'green', endingDay: true}
140171
}}
141-
// Date marking style [simple/interactive]. Default = 'simple'
142-
markingType={'interactive'}
172+
// Date marking style [simple/period/multi-dot]. Default = 'simple'
173+
markingType={'period'}
143174
/>
144175
```
145176

@@ -165,6 +196,7 @@ The loading indicator next to month name will be displayed if `<Calendar />` has
165196
}}
166197
// Specify theme properties to override specific styles for calendar parts. Default = {}
167198
theme={{
199+
backgroundColor: '#ffffff',
168200
calendarBackground: '#ffffff',
169201
textSectionTitleColor: '#b6c1cd',
170202
selectedDayBackgroundColor: '#00adf5',
@@ -186,6 +218,55 @@ The loading indicator next to month name will be displayed if `<Calendar />` has
186218
/>
187219
```
188220

221+
#### Advanced styling
222+
223+
If you want to have complete control over calendar styles you can do it by overriding default style.js files. For example, if you want to override calendar header style first you have to find stylesheet id for this file:
224+
225+
https://github.com/wix/react-native-calendars/blob/master/src/calendar/header/style.js#L4
226+
227+
In this case it is 'stylesheet.calendar.header'. Next you can add overriding stylesheet to your theme with this id.
228+
229+
https://github.com/wix/react-native-calendars/blob/master/example/src/screens/calendars.js#L56
230+
231+
```javascript
232+
theme={{
233+
arrowColor: 'white',
234+
'stylesheet.calendar.header': {
235+
week: {
236+
marginTop: 5,
237+
flexDirection: 'row',
238+
justifyContent: 'space-between'
239+
}
240+
}
241+
}}
242+
```
243+
244+
**Disclaimer**: issues that arise because something breaks after using stylesheet override will not be supported. Use this option at your own risk.
245+
246+
#### Overriding day component
247+
248+
If you need custom functionality not supported by current day component implementations you can pass your own custom day
249+
component to the calendar.
250+
251+
```javascript
252+
<Calendar
253+
style={[styles.calendar, {height: 300}]}
254+
dayComponent={({date, state}) => {
255+
return (<View style={{flex: 1}}><Text style={{textAlign: 'center', color: state === 'disabled' ? 'gray' : 'black'}}>{date.day}</Text></View>);
256+
}}
257+
/>
258+
```
259+
260+
The dayComponent prop has to receive a RN component or function that receive props. The day component will receive such props:
261+
262+
* state - disabled if the day should be disabled (this is decided by base calendar component)
263+
* marking - markedDates value for this day
264+
* date - the date object representing this day
265+
266+
**Tip:** Don't forget to implement shouldComponentUpdate for your custom day component to make calendar perform better
267+
268+
If you implement an awesome day component please make a PR so that other people could use it :)
269+
189270
### CalendarList
190271

191272
<kbd>
@@ -204,6 +285,8 @@ The loading indicator next to month name will be displayed if `<Calendar />` has
204285
futureScrollRange={50}
205286
// Enable or disable scrolling of calendar list
206287
scrollEnabled={true}
288+
// Enable or disable vertical scroll indicator. Default = false
289+
showScrollIndicator={true}
207290
...calendarParams
208291
/>
209292
```
@@ -228,6 +311,8 @@ An advanced agenda component that can display interactive listings for calendar
228311
}}
229312
// callback that gets called when items for a certain month should be loaded (month became visible)
230313
loadItemsForMonth={(month) => {console.log('trigger items loading')}}
314+
// callback that fires when the calendar is opened or closed
315+
onCalendarToggled={(calendarOpened) => {console.log(calendarOpened)}}
231316
// callback that gets called on day press
232317
onDayPress={(day)=>{console.log('day pressed')}}
233318
// callback that gets called when day changes while scrolling agenda list
@@ -238,22 +323,37 @@ An advanced agenda component that can display interactive listings for calendar
238323
minDate={'2012-05-10'}
239324
// Maximum date that can be selected, dates after maxDate will be grayed out. Default = undefined
240325
maxDate={'2012-05-30'}
326+
// Max amount of months allowed to scroll to the past. Default = 50
327+
pastScrollRange={50}
328+
// Max amount of months allowed to scroll to the future. Default = 50
329+
futureScrollRange={50}
241330
// specify how each item should be rendered in agenda
242331
renderItem={(item, firstItemInDay) => {return (<View />);}}
243332
// specify how each date should be rendered. day can be undefined if the item is not first in that day.
244333
renderDay={(day, item) => {return (<View />);}}
245334
// specify how empty date content with no items should be rendered
246335
renderEmptyDate={() => {return (<View />);}}
336+
// specify how agenda knob should look like
337+
renderKnob={() => {return (<View />);}}
338+
// specify what should be rendered instead of ActivityIndicator
339+
renderEmptyData = {() => {return (<View />);}}
247340
// specify your item comparison function for increased performance
248341
rowHasChanged={(r1, r2) => {return r1.text !== r2.text}}
249342
// Hide knob button. Default = false
250343
hideKnob={true}
344+
// By default, agenda dates are marked if they have at least one item, but you can override this if needed
345+
markedDates={{
346+
'2012-05-16': {selected: true, marked: true},
347+
'2012-05-17': {marked: true},
348+
'2012-05-18': {disabled: true}
349+
}}
251350
// agenda theme
252351
theme={{
253352
...calendarTheme,
254353
agendaDayTextColor: 'yellow',
255354
agendaDayNumColor: 'green',
256-
agendaTodayColor: 'red'
355+
agendaTodayColor: 'red',
356+
agendaKnobColor: 'blue'
257357
}}
258358
// agenda container style
259359
style={{}}

demo/marking4.png

5.96 KB
Loading

example/.babelrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"presets": ["react-native"]
3-
}
2+
"presets": ["react-native"]
3+
}

example/.flowconfig

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,18 @@
11
[ignore]
2-
3-
# We fork some components by platform.
2+
; We fork some components by platform
43
.*/*[.]android.js
54

6-
# Ignore templates with `@flow` in header
7-
.*/local-cli/generator.*
8-
9-
# Ignore malformed json
10-
.*/node_modules/y18n/test/.*\.json
11-
12-
# Ignore the website subdir
13-
<PROJECT_ROOT>/website/.*
14-
15-
# Ignore BUCK generated dirs
5+
; Ignore "BUCK" generated dirs
166
<PROJECT_ROOT>/\.buckd/
177

18-
# Ignore unexpected extra @providesModule
19-
.*/node_modules/commoner/test/source/widget/share.js
8+
; Ignore unexpected extra "@providesModule"
9+
.*/node_modules/.*/node_modules/fbjs/.*
2010

21-
# Ignore duplicate module providers
22-
# For RN Apps installed via npm, "Libraries" folder is inside node_modules/react-native but in the source repo it is in the root
11+
; Ignore duplicate module providers
12+
; For RN Apps installed via npm, "Libraries" folder is inside
13+
; "node_modules/react-native" but in the source repo it is in the root
2314
.*/Libraries/react-native/React.js
2415
.*/Libraries/react-native/ReactNative.js
25-
.*/node_modules/jest-runtime/build/__tests__/.*
2616

2717
[include]
2818

@@ -32,27 +22,24 @@ node_modules/react-native/flow
3222
flow/
3323

3424
[options]
35-
module.system=haste
36-
37-
esproposal.class_static_fields=enable
38-
esproposal.class_instance_fields=enable
25+
emoji=true
3926

40-
experimental.strict_type_args=true
27+
module.system=haste
4128

4229
munge_underscores=true
4330

44-
module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub'
4531
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'
4632

4733
suppress_type=$FlowIssue
4834
suppress_type=$FlowFixMe
4935
suppress_type=$FixMe
5036

51-
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-3]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
52-
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-3]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
37+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(4[0-9]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
38+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(4[0-9]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
5339
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
40+
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
5441

5542
unsafe.enable_getters_and_setters=true
5643

5744
[version]
58-
^0.33.0
45+
^0.49.1

example/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pbxproj -text

example/.gitignore

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,32 @@ DerivedData
2222
*.xcuserstate
2323
project.xcworkspace
2424

25-
# Android/IJ
25+
# Android/IntelliJ
2626
#
27-
*.iml
27+
build/
2828
.idea
2929
.gradle
3030
local.properties
31+
*.iml
3132

3233
# node.js
3334
#
3435
node_modules/
3536
npm-debug.log
37+
yarn-error.log
3638

3739
# BUCK
3840
buck-out/
3941
\.buckd/
40-
android/app/libs
41-
android/keystores/debug.keystore
42-
yarn.lock
42+
*.keystore
43+
44+
# fastlane
45+
#
46+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
47+
# screenshots whenever they are needed.
48+
# For more information about the recommended setup visit:
49+
# https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
50+
51+
fastlane/report.xml
52+
fastlane/Preview.html
53+
fastlane/screenshots

0 commit comments

Comments
 (0)