Skip to content

Commit f459370

Browse files
authored
Merge pull request wix#866 from wix/fix/Comments_format
Changing comments format
2 parents ea32254 + 4258218 commit f459370

File tree

17 files changed

+192
-114
lines changed

17 files changed

+192
-114
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,7 @@
3535
## [1.194.0] - 2019-06-30
3636
### Added
3737
- CalendarProvider - 'onMonthChange' event returning date object and updateSource.
38+
39+
## [1.195.0] - 2019-07-04
40+
### Change
41+
- Components' props comment format.

src/agenda/index.js

Lines changed: 72 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
import React, {Component} from 'react';
2-
import {
3-
Text,
4-
View,
5-
Dimensions,
6-
Animated,
7-
ViewPropTypes,
8-
} from 'react-native';
2+
import {Text, View, Dimensions, Animated, ViewPropTypes} from 'react-native';
93
import PropTypes from 'prop-types';
104
import XDate from 'xdate';
115

@@ -14,91 +8,94 @@ import dateutils from '../dateutils';
148
import CalendarList from '../calendar-list';
159
import ReservationsList from './reservation-list';
1610
import styleConstructor from './style';
17-
import { VelocityTracker } from '../input';
11+
import {VelocityTracker} from '../input';
12+
1813

1914
const HEADER_HEIGHT = 104;
2015
const KNOB_HEIGHT = 24;
21-
2216
//Fallback when RN version is < 0.44
2317
const viewPropTypes = ViewPropTypes || View.propTypes;
2418

19+
/**
20+
* @description: Agenda component
21+
* @extends: CalendarList
22+
* @extendslink: docs/CalendarList
23+
* @example: https://github.com/wix/react-native-calendars/blob/master/example/src/screens/agenda.js
24+
* @gif: https://github.com/wix/react-native-calendars/blob/master/demo/agenda.gif
25+
*/
2526
export default class AgendaView extends Component {
27+
static displayName = 'Agenda';
28+
2629
static propTypes = {
27-
// Specify theme properties to override specific styles for calendar parts. Default = {}
30+
/** Specify theme properties to override specific styles for calendar parts. Default = {} */
2831
theme: PropTypes.object,
29-
30-
// agenda container style
32+
/** agenda container style */
3133
style: viewPropTypes.style,
32-
33-
// the list of items that have to be displayed in agenda. If you want to render item as empty date
34-
// the value of date key has to be an empty array []. If there exists no value for date key it is
35-
// considered that the date in question is not yet loaded
34+
/** the list of items that have to be displayed in agenda. If you want to render item as empty date
35+
the value of date key has to be an empty array []. If there exists no value for date key it is
36+
considered that the date in question is not yet loaded */
3637
items: PropTypes.object,
37-
38-
// callback that gets called when items for a certain month should be loaded (month became visible)
38+
/** callback that gets called when items for a certain month should be loaded (month became visible) */
3939
loadItemsForMonth: PropTypes.func,
40-
// callback that fires when the calendar is opened or closed
40+
/** callback that fires when the calendar is opened or closed */
4141
onCalendarToggled: PropTypes.func,
42-
// callback that gets called on day press
42+
/** callback that gets called on day press */
4343
onDayPress: PropTypes.func,
44-
// callback that gets called when day changes while scrolling agenda list
44+
/** callback that gets called when day changes while scrolling agenda list */
4545
onDaychange: PropTypes.func,
46-
// specify how each item should be rendered in agenda
46+
/** specify how each item should be rendered in agenda */
4747
renderItem: PropTypes.func,
48-
// specify how each date should be rendered. day can be undefined if the item is not first in that day.
48+
/** specify how each date should be rendered. day can be undefined if the item is not first in that day. */
4949
renderDay: PropTypes.func,
50-
// specify how agenda knob should look like
50+
/** specify how agenda knob should look like */
5151
renderKnob: PropTypes.func,
52-
// specify how empty date content with no items should be rendered
52+
/** specify how empty date content with no items should be rendered */
5353
renderEmptyDay: PropTypes.func,
54-
// specify what should be rendered instead of ActivityIndicator
54+
/** specify what should be rendered instead of ActivityIndicator */
5555
renderEmptyData: PropTypes.func,
56-
// specify your item comparison function for increased performance
56+
/** specify your item comparison function for increased performance */
5757
rowHasChanged: PropTypes.func,
58-
59-
// Max amount of months allowed to scroll to the past. Default = 50
58+
/** Max amount of months allowed to scroll to the past. Default = 50 */
6059
pastScrollRange: PropTypes.number,
61-
62-
// Max amount of months allowed to scroll to the future. Default = 50
60+
/** Max amount of months allowed to scroll to the future. Default = 50 */
6361
futureScrollRange: PropTypes.number,
64-
65-
// initially selected day
62+
/** initially selected day */
6663
selected: PropTypes.any,
67-
// Minimum date that can be selected, dates before minDate will be grayed out. Default = undefined
64+
/** Minimum date that can be selected, dates before minDate will be grayed out. Default = undefined */
6865
minDate: PropTypes.any,
69-
// Maximum date that can be selected, dates after maxDate will be grayed out. Default = undefined
66+
/** Maximum date that can be selected, dates after maxDate will be grayed out. Default = undefined */
7067
maxDate: PropTypes.any,
71-
72-
// If firstDay=1 week starts from Monday. Note that dayNames and dayNamesShort should still start from Sunday.
68+
/** If firstDay=1 week starts from Monday. Note that dayNames and dayNamesShort should still start from Sunday. */
7369
firstDay: PropTypes.number,
74-
75-
// Collection of dates that have to be marked. Default = items
70+
/** Collection of dates that have to be marked. Default = items */
7671
markedDates: PropTypes.object,
77-
// Optional marking type if custom markedDates are provided
78-
markingType: PropTypes.string,
79-
80-
// Hide knob button. Default = false
72+
/** Optional marking type if custom markedDates are provided */
73+
markingType: PropTypes.string,/*
74+
/** Hide knob button. Default = false */
8175
hideKnob: PropTypes.bool,
82-
// Month format in calendar title. Formatting values: http://arshaw.com/xdate/#Formatting
76+
/** Month format in calendar title. Formatting values: http://arshaw.com/xdate/#Formatting */
8377
monthFormat: PropTypes.string,
84-
// A RefreshControl component, used to provide pull-to-refresh functionality for the ScrollView.
78+
/** A RefreshControl component, used to provide pull-to-refresh functionality for the ScrollView. */
8579
refreshControl: PropTypes.element,
86-
// If provided, a standard RefreshControl will be added for "Pull to Refresh" functionality. Make sure to also set the refreshing prop correctly.
80+
/** If provided, a standard RefreshControl will be added for "Pull to Refresh" functionality. Make sure to also set the refreshing prop correctly. */
8781
onRefresh: PropTypes.func,
88-
// Set this true while waiting for new data from a refresh.
82+
/** Set this true while waiting for new data from a refresh. */
8983
refreshing: PropTypes.bool,
90-
// Display loading indicador. Default = false
91-
displayLoadingIndicator: PropTypes.bool,
84+
/** Display loading indicador. Default = false */
85+
displayLoadingIndicator: PropTypes.bool
9286
};
9387

9488
constructor(props) {
9589
super(props);
90+
9691
this.styles = styleConstructor(props.theme);
92+
9793
const windowSize = Dimensions.get('window');
9894
this.viewHeight = windowSize.height;
9995
this.viewWidth = windowSize.width;
10096
this.scrollTimeout = undefined;
10197
this.headerState = 'idle';
98+
10299
this.state = {
103100
scrollY: new Animated.Value(0),
104101
calendarIsReady: false,
@@ -107,6 +104,7 @@ export default class AgendaView extends Component {
107104
selectedDay: parseDate(this.props.selected) || XDate(true),
108105
topDay: parseDate(this.props.selected) || XDate(true),
109106
};
107+
110108
this.currentMonth = this.state.selectedDay.clone();
111109
this.onLayout = this.onLayout.bind(this);
112110
this.onScrollPadLayout = this.onScrollPadLayout.bind(this);
@@ -149,19 +147,20 @@ export default class AgendaView extends Component {
149147
onTouchStart() {
150148
this.headerState = 'touched';
151149
if (this.knob) {
152-
this.knob.setNativeProps({style: { opacity: 0.5 }});
150+
this.knob.setNativeProps({style: {opacity: 0.5}});
153151
}
154152
}
155153

156154
onTouchEnd() {
157155
if (this.knob) {
158-
this.knob.setNativeProps({style: { opacity: 1 }});
156+
this.knob.setNativeProps({style: {opacity: 1}});
159157
}
160158

161159
if (this.headerState === 'touched') {
162160
this.setScrollPadPosition(0, true);
163161
this.enableCalendarScrolling();
164162
}
163+
165164
this.headerState = 'idle';
166165
}
167166

@@ -179,6 +178,7 @@ export default class AgendaView extends Component {
179178
const maxY = this.initialScrollPadPosition();
180179
const snapY = (projectedY > maxY / 2) ? maxY : 0;
181180
this.setScrollPadPosition(snapY, true);
181+
182182
if (snapY === 0) {
183183
this.enableCalendarScrolling();
184184
}
@@ -230,6 +230,7 @@ export default class AgendaView extends Component {
230230
this.setState({
231231
calendarScrollable: true
232232
});
233+
233234
if (this.props.onCalendarToggled) {
234235
this.props.onCalendarToggled(true);
235236
}
@@ -250,23 +251,29 @@ export default class AgendaView extends Component {
250251

251252
chooseDay(d, optimisticScroll) {
252253
const day = parseDate(d);
254+
253255
this.setState({
254256
calendarScrollable: false,
255257
selectedDay: day.clone()
256258
});
259+
257260
if (this.props.onCalendarToggled) {
258261
this.props.onCalendarToggled(false);
259262
}
263+
260264
if (!optimisticScroll) {
261265
this.setState({
262266
topDay: day.clone()
263267
});
264268
}
269+
265270
this.setScrollPadPosition(this.initialScrollPadPosition(), true);
266271
this.calendar.scrollToDay(day, this.calendarOffset(), true);
272+
267273
if (this.props.loadItemsForMonth) {
268274
this.props.loadItemsForMonth(xdateToData(day));
269275
}
276+
270277
if (this.props.onDayPress) {
271278
this.props.onDayPress(xdateToData(day));
272279
}
@@ -297,6 +304,7 @@ export default class AgendaView extends Component {
297304
onDayChange(day) {
298305
const newDate = parseDate(day);
299306
const withAnimation = dateutils.sameMonth(newDate, this.state.selectedDay);
307+
300308
this.calendar.scrollToDay(day, this.calendarOffset(), withAnimation);
301309
this.setState({
302310
selectedDay: parseDate(day)
@@ -309,6 +317,7 @@ export default class AgendaView extends Component {
309317

310318
generateMarkings() {
311319
let markings = this.props.markedDates;
320+
312321
if (!markings) {
313322
markings = {};
314323
Object.keys(this.props.items || {}).forEach(key => {
@@ -317,41 +326,43 @@ export default class AgendaView extends Component {
317326
}
318327
});
319328
}
329+
320330
const key = this.state.selectedDay.toString('yyyy-MM-dd');
321331
return {...markings, [key]: {...(markings[key] || {}), ...{selected: true}}};
322332
}
323333

324334
render() {
325335
const agendaHeight = Math.max(0, this.viewHeight - HEADER_HEIGHT);
326336
const weekDaysNames = dateutils.weekDayNames(this.props.firstDay);
337+
327338
const weekdaysStyle = [this.styles.weekdays, {
328339
opacity: this.state.scrollY.interpolate({
329340
inputRange: [agendaHeight - HEADER_HEIGHT, agendaHeight],
330341
outputRange: [0, 1],
331-
extrapolate: 'clamp',
342+
extrapolate: 'clamp'
332343
}),
333344
transform: [{ translateY: this.state.scrollY.interpolate({
334345
inputRange: [Math.max(0, agendaHeight - HEADER_HEIGHT), agendaHeight],
335346
outputRange: [-HEADER_HEIGHT, 0],
336-
extrapolate: 'clamp',
347+
extrapolate: 'clamp'
337348
})}]
338349
}];
339350

340351
const headerTranslate = this.state.scrollY.interpolate({
341352
inputRange: [0, agendaHeight],
342353
outputRange: [agendaHeight, 0],
343-
extrapolate: 'clamp',
354+
extrapolate: 'clamp'
344355
});
345356

346357
const contentTranslate = this.state.scrollY.interpolate({
347358
inputRange: [0, agendaHeight],
348359
outputRange: [0, agendaHeight/2],
349-
extrapolate: 'clamp',
360+
extrapolate: 'clamp'
350361
});
351362

352363
const headerStyle = [
353364
this.styles.header,
354-
{ bottom: agendaHeight, transform: [{ translateY: headerTranslate }] },
365+
{bottom: agendaHeight, transform: [{ translateY: headerTranslate }]}
355366
];
356367

357368
if (!this.state.calendarIsReady) {
@@ -369,7 +380,7 @@ export default class AgendaView extends Component {
369380
width: 80,
370381
height: KNOB_HEIGHT,
371382
top: scrollPadPosition,
372-
left: (this.viewWidth - 80) / 2,
383+
left: (this.viewWidth - 80) / 2
373384
};
374385

375386
let knob = (<View style={this.styles.knobContainer}/>);
@@ -389,7 +400,7 @@ export default class AgendaView extends Component {
389400
{this.renderReservations()}
390401
</View>
391402
<Animated.View style={headerStyle}>
392-
<Animated.View style={{flex:1, transform: [{ translateY: contentTranslate }]}}>
403+
<Animated.View style={{flex:1, transform: [{translateY: contentTranslate}]}}>
393404
<CalendarList
394405
onLayout={() => {
395406
this.calendar.scrollToDay(this.state.selectedDay.clone(), this.calendarOffset(), false);
@@ -438,11 +449,11 @@ export default class AgendaView extends Component {
438449
onScrollBeginDrag={this.onStartDrag}
439450
onScrollEndDrag={this.onSnapAfterDrag}
440451
onScroll={Animated.event(
441-
[{ nativeEvent: { contentOffset: { y: this.state.scrollY } } }],
442-
{ useNativeDriver: true },
452+
[{nativeEvent: {contentOffset: {y: this.state.scrollY}}}],
453+
{useNativeDriver: true},
443454
)}
444455
>
445-
<View style={{height: agendaHeight + KNOB_HEIGHT}} onLayout={this.onScrollPadLayout} />
456+
<View style={{height: agendaHeight + KNOB_HEIGHT}} onLayout={this.onScrollPadLayout}/>
446457
</Animated.ScrollView>
447458
</View>
448459
);

src/agenda/reservation-list/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import dateutils from '../../dateutils';
1212
import styleConstructor from './style';
1313

1414
class ReactComp extends Component {
15+
static displayName = 'IGNORE';
16+
1517
static propTypes = {
1618
// specify your item comparison function for increased performance
1719
rowHasChanged: PropTypes.func,

src/agenda/reservation-list/reservation.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ import dateutils from '../../dateutils';
66
import styleConstructor from './style';
77

88
class ReservationListItem extends Component {
9+
static displayName = 'IGNORE';
10+
911
constructor(props) {
1012
super(props);
1113
this.styles = styleConstructor(props.theme);

0 commit comments

Comments
 (0)