Skip to content
This repository has been archived by the owner on Apr 7, 2023. It is now read-only.

Commit

Permalink
file cosmetics
Browse files Browse the repository at this point in the history
  • Loading branch information
Inbal-Tish committed Jan 25, 2020
1 parent 9e937af commit f261d5f
Show file tree
Hide file tree
Showing 18 changed files with 51 additions and 52 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,3 +273,6 @@
## [1.257.0] - 2020-1-23
### Bug fix
- Reservation - secure calls to prop functions to avoid crashes.

## [1.258.0] - 2020-1-23
- file cosmetics
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ An advanced `Agenda` component that can display interactive listings for calenda
```javascript
<Agenda
// The list of items that have to be displayed in agenda. If you want to render item as empty date
// the value of date key kas to be an empty array []. If there exists no value for date key it is
// the value of date key has to be an empty array []. If there exists no value for date key it is
// considered that the date in question is not yet loaded
items={{
'2012-05-22': [{name: 'item 1 - any js object'}],
Expand Down
2 changes: 1 addition & 1 deletion example/.babelrc-IGNORE
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"presets": [
"module:metro-react-native-babel-preset"
]
}
}
2 changes: 1 addition & 1 deletion example/.watchmanconfig
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{}
{}
2 changes: 1 addition & 1 deletion example/app.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "CalendarsExample",
"displayName": "CalendarsExample"
}
}
4 changes: 2 additions & 2 deletions example/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module.exports = {
presets: ['module:metro-react-native-babel-preset'],
};
presets: ['module:metro-react-native-babel-preset']
};
8 changes: 4 additions & 4 deletions example/metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ module.exports = {
getTransformOptions: async () => ({
transform: {
experimentalImportSupport: false,
inlineRequires: false,
},
}),
},
inlineRequires: false
}
})
}
};
23 changes: 13 additions & 10 deletions example/src/screens/agenda.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
import React, {Component} from 'react';
import {
Text,
View,
StyleSheet
} from 'react-native';
import {Alert, StyleSheet, Text, View, TouchableOpacity} from 'react-native';
import {Agenda} from 'react-native-calendars';


export default class AgendaScreen extends Component {
constructor(props) {
super(props);

this.state = {
items: {}
};
Expand Down Expand Up @@ -51,31 +49,36 @@ export default class AgendaScreen extends Component {
const numItems = Math.floor(Math.random() * 5);
for (let j = 0; j < numItems; j++) {
this.state.items[strTime].push({
name: 'Item for ' + strTime,
name: 'Item for ' + strTime + ' #' + j,
height: Math.max(50, Math.floor(Math.random() * 150))
});
}
}
}
//console.log(this.state.items);
const newItems = {};
Object.keys(this.state.items).forEach(key => {newItems[key] = this.state.items[key];});
this.setState({
items: newItems
});
}, 1000);
// console.log(`Load Items for ${day.year}-${day.month}`);
}

renderItem(item) {
return (
<View style={[styles.item, {height: item.height}]}><Text>{item.name}</Text></View>
<TouchableOpacity
style={[styles.item, {height: item.height}]}
onPress={() => Alert.alert(item.name)}
>
<Text>{item.name}</Text>
</TouchableOpacity>
);
}

renderEmptyDate() {
return (
<View style={styles.emptyDate}><Text>This is empty date!</Text></View>
<View style={styles.emptyDate}>
<Text>This is empty date!</Text>
</View>
);
}

Expand Down
4 changes: 2 additions & 2 deletions example/src/screens/calendars.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default class CalendarsScreen extends Component {
render() {
return (
<ScrollView showsVerticalScrollIndicator={false}>
<Text style={styles.text}>Calendar with selectable date and arrows</Text>
<Text style={styles.text}>Calendar with selectable date</Text>
<Calendar
style={styles.calendar}
hideExtraDays
Expand All @@ -42,7 +42,7 @@ export default class CalendarsScreen extends Component {
maxDate={'2012-05-29'}
firstDay={1}
markedDates={{
'2012-05-23': {selected: true, marked: true},
'2012-05-23': {selected: true, marked: true, disableTouchEvent: true},
'2012-05-24': {selected: true, marked: true, dotColor: 'red'},
'2012-05-25': {marked: true, dotColor: 'red'},
'2012-05-26': {marked: true},
Expand Down
5 changes: 1 addition & 4 deletions example/src/screens/calendarsList.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ import {CalendarList} from 'react-native-calendars';


export default class CalendarsList extends Component {
constructor(props) {
super(props);
}


render() {
return (
<CalendarList current={'2012-05-16'} pastScrollRange={24} futureScrollRange={24}/>
Expand Down
6 changes: 3 additions & 3 deletions example/src/screens/menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,16 @@ const styles = StyleSheet.create({
},
image: {
margin: 30,
width: 80,
height: 80
width: 90,
height: 90
},
menu: {
width: 300,
padding: 10,
margin: 10,
// backgroundColor: '#f2F4f5',
alignItems: 'center',
borderRadius: 10,
borderRadius: 20,
borderWidth: 1,
borderColor: '#7a92a5'
},
Expand Down
5 changes: 2 additions & 3 deletions src/agenda/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import CalendarList from '../calendar-list';
import ReservationsList from './reservation-list';
import styleConstructor from './style';
import {VelocityTracker} from '../input';

import {AGENDA_CALENDAR_KNOB} from '../testIDs';


Expand Down Expand Up @@ -83,7 +82,7 @@ export default class AgendaView extends Component {
onRefresh: PropTypes.func,
/** Set this true while waiting for new data from a refresh. */
refreshing: PropTypes.bool,
/** Display loading indicador. Default = false */
/** Display loading indicator. Default = false */
displayLoadingIndicator: PropTypes.bool
};

Expand Down Expand Up @@ -378,7 +377,7 @@ export default class AgendaView extends Component {
}

const shouldAllowDragging = !this.props.hideKnob && !this.state.calendarScrollable;
const scrollPadPosition = (shouldAllowDragging ? HEADER_HEIGHT : 0) - KNOB_HEIGHT;
const scrollPadPosition = (shouldAllowDragging ? HEADER_HEIGHT : 0) - KNOB_HEIGHT;

const scrollPadStyle = {
position: 'absolute',
Expand Down
4 changes: 3 additions & 1 deletion src/calendar-list/item.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class CalendarListItem extends Component {

constructor(props) {
super(props);

this.style = styleConstructor(props.theme);
}

Expand Down Expand Up @@ -74,7 +75,8 @@ class CalendarListItem extends Component {
onPressArrowLeft={this.props.horizontal ? this.onPressArrowLeft : this.props.onPressArrowLeft}
onPressArrowRight={this.props.horizontal ? this.onPressArrowRight : this.props.onPressArrowRight}
headerStyle={this.props.horizontal ? this.props.headerStyle : undefined}
/>);
/>
);
} else {
const text = row.toString();

Expand Down
12 changes: 5 additions & 7 deletions src/calendar/day/basic/index.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
import React, {Component} from 'react';
import {
TouchableOpacity,
Text,
View
} from 'react-native';
import {View, TouchableOpacity, Text} from 'react-native';
import PropTypes from 'prop-types';
import {shouldUpdate} from '../../../component-updater';

import styleConstructor from './style';


class Day extends Component {
static displayName = 'IGNORE';

static propTypes = {
// TODO: disabled props should be removed
state: PropTypes.oneOf(['disabled', 'today', '']),

// Specify theme properties to override specific styles for calendar parts. Default = {}
theme: PropTypes.object,
marking: PropTypes.any,
Expand All @@ -26,7 +22,9 @@ class Day extends Component {

constructor(props) {
super(props);

this.style = styleConstructor(props.theme);

this.onDayPress = this.onDayPress.bind(this);
this.onDayLongPress = this.onDayLongPress.bind(this);
}
Expand All @@ -46,13 +44,13 @@ class Day extends Component {
const containerStyle = [this.style.base];
const textStyle = [this.style.text];
const dotStyle = [this.style.dot];

let marking = this.props.marking || {};
if (marking && marking.constructor === Array && marking.length) {
marking = {
marking: true
};
}

const isDisabled = typeof marking.disabled !== 'undefined' ? marking.disabled : this.props.state === 'disabled';
let dot;
if (marking.marked) {
Expand Down
3 changes: 1 addition & 2 deletions src/calendar/day/custom/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,14 @@ class Day extends Component {
render() {
let containerStyle = [this.style.base];
let textStyle = [this.style.text];

let marking = this.props.marking || {};
if (marking && marking.constructor === Array && marking.length) {
marking = {
marking: true
};
}
const isDisabled = typeof marking.disabled !== 'undefined' ? marking.disabled : this.props.state === 'disabled';

const isDisabled = typeof marking.disabled !== 'undefined' ? marking.disabled : this.props.state === 'disabled';
if (marking.selected) {
containerStyle.push(this.style.selected);
textStyle.push(this.style.selectedText);
Expand Down
12 changes: 5 additions & 7 deletions src/calendar/day/multi-dot/index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import React, {Component} from 'react';
import {
TouchableOpacity,
Text,
View
} from 'react-native';
import {View, TouchableOpacity, Text} from 'react-native';
import PropTypes from 'prop-types';

import {shouldUpdate} from '../../../component-updater';

import styleConstructor from './style';


class Day extends Component {
static displayName = 'IGNORE';

Expand All @@ -27,7 +23,9 @@ class Day extends Component {

constructor(props) {
super(props);

this.style = styleConstructor(props.theme);

this.onDayPress = this.onDayPress.bind(this);
this.onDayLongPress = this.onDayLongPress.bind(this);
}
Expand Down Expand Up @@ -62,7 +60,6 @@ class Day extends Component {
render() {
const containerStyle = [this.style.base];
const textStyle = [this.style.text];

const marking = this.props.marking || {};
const dot = this.renderDots(marking);

Expand All @@ -78,6 +75,7 @@ class Day extends Component {
containerStyle.push(this.style.today);
textStyle.push(this.style.todayText);
}

return (
<TouchableOpacity
testID={this.props.testID}
Expand Down
5 changes: 3 additions & 2 deletions src/calendar/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,17 @@ class Calendar extends Component {
markingType: PropTypes.string,
/** Hide month navigation arrows. Default = false */
hideArrows: PropTypes.bool,
/** Display loading indicador. Default = false */
/** Display loading indicator. Default = false */
displayLoadingIndicator: PropTypes.bool,
/** Do not show days of other months in month page. Default = false */
hideExtraDays: PropTypes.bool,
/** Handler which gets executed on day press. Default = undefined */
onDayPress: PropTypes.func,
/** Handler which gets executed on day long press. Default = undefined */
onDayLongPress: PropTypes.func,
/** Handler which gets executed when visible month changes in calendar. Default = undefined */
/** Handler which gets executed when month changes in calendar. Default = undefined */
onMonthChange: PropTypes.func,
/** Handler which gets executed when visible month changes in calendar. Default = undefined */
onVisibleMonthsChange: PropTypes.func,
/** Replace default arrows with custom ones (direction can be 'left' or 'right') */
renderArrow: PropTypes.func,
Expand Down
1 change: 0 additions & 1 deletion src/calendar/updater.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,5 @@ export default function shouldComponentUpdate(nextProps, nextState) {
field: 'current'
};
}
//console.log(shouldUpdate.field, shouldUpdate.update);
return shouldUpdate.update;
}

0 comments on commit f261d5f

Please sign in to comment.