Skip to content

Commit a60284b

Browse files
committed
formatting
1 parent e411aeb commit a60284b

File tree

3 files changed

+26
-28
lines changed

3 files changed

+26
-28
lines changed

src/agenda/index.tsx

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ export default class Agenda extends Component<AgendaProps, State> {
158158
if (nextProps.items) {
159159
return {firstReservationLoad: false};
160160
}
161-
162161
return null;
163162
}
164163

@@ -186,10 +185,8 @@ export default class Agenda extends Component<AgendaProps, State> {
186185
};
187186

188187
enableCalendarScrolling(enable = true) {
189-
this.setState({
190-
calendarScrollable: enable
191-
});
192-
188+
this.setState({calendarScrollable: enable});
189+
193190
this.props.onCalendarToggled?.(enable);
194191

195192
// Enlarge calendarOffset here as a workaround on iOS to force repaint.
@@ -205,10 +202,7 @@ export default class Agenda extends Component<AgendaProps, State> {
205202

206203
loadReservations(props: AgendaProps) {
207204
if ((!props.items || !Object.keys(props.items).length) && !this.state.firstReservationLoad) {
208-
this.setState(
209-
{
210-
firstReservationLoad: true
211-
},
205+
this.setState({firstReservationLoad: true},
212206
() => {
213207
this.props.loadItemsForMonth?.(xdateToData(this.state.selectedDay));
214208
}
@@ -231,9 +225,7 @@ export default class Agenda extends Component<AgendaProps, State> {
231225
this.props.onCalendarToggled?.(false);
232226

233227
if (!optimisticScroll) {
234-
this.setState({
235-
topDay: day.clone()
236-
});
228+
this.setState({topDay: day.clone()});
237229
}
238230

239231
this.setScrollPadPosition(this.initialScrollPadPosition(), true);
@@ -389,7 +381,12 @@ export default class Agenda extends Component<AgendaProps, State> {
389381

390382
renderWeekDaysNames = memoize((weekDaysNames: string[]) => {
391383
return weekDaysNames.map((day, index) => (
392-
<Text allowFontScaling={false} key={day + index} style={this.style.weekday} numberOfLines={1}>
384+
<Text
385+
key={day + index}
386+
style={this.style.weekday}
387+
allowFontScaling={false}
388+
numberOfLines={1}
389+
>
393390
{day}
394391
</Text>
395392
));

src/agenda/reservation-list/index.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,12 @@ class ReservationList extends Component<ReservationListProps, State> {
9090
/** If provided, a standard RefreshControl will be added for "Pull to Refresh" functionality. Make sure to also set the refreshing prop correctly */
9191
onRefresh: PropTypes.func
9292
};
93-
93+
9494
static defaultProps = {
9595
refreshing: false,
9696
selectedDay: new XDate(true)
9797
};
98+
9899
private style: {[key: string]: ViewStyle | TextStyle};
99100
private heights: number[];
100101
private selectedDay?: XDate;
@@ -123,10 +124,7 @@ class ReservationList extends Component<ReservationListProps, State> {
123124
componentDidUpdate(prevProps: ReservationListProps) {
124125
if (this.props.topDay && prevProps.topDay && prevProps !== this.props) {
125126
if (!sameDate(prevProps.topDay, this.props.topDay)) {
126-
this.setState(
127-
{
128-
reservations: []
129-
},
127+
this.setState({reservations: []},
130128
() => this.updateReservations(this.props)
131129
);
132130
} else {
@@ -136,14 +134,13 @@ class ReservationList extends Component<ReservationListProps, State> {
136134
}
137135

138136
updateDataSource(reservations: DayAgenda[]) {
139-
this.setState({
140-
reservations
141-
});
137+
this.setState({reservations});
142138
}
143139

144140
updateReservations(props: ReservationListProps) {
145141
const {selectedDay} = props;
146142
const reservations = this.getReservations(props);
143+
147144
if (selectedDay && this.selectedDay)
148145
if (this.list && !sameDate(selectedDay, this.selectedDay)) {
149146
let scrollPosition = 0;
@@ -153,13 +150,15 @@ class ReservationList extends Component<ReservationListProps, State> {
153150
this.scrollOver = false;
154151
this.list?.current?.scrollToOffset({offset: scrollPosition, animated: true});
155152
}
153+
156154
this.selectedDay = selectedDay;
157155
this.updateDataSource(reservations.reservations);
158156
}
159157

160158
getReservationsForDay(iterator: XDate, props: ReservationListProps) {
161159
const day = iterator.clone();
162160
const res = props.items?.[toMarkingFormat(day)];
161+
163162
if (res && res.length) {
164163
return res.map((reservation: AgendaEntry, i: number) => {
165164
return {
@@ -180,6 +179,7 @@ class ReservationList extends Component<ReservationListProps, State> {
180179

181180
getReservations(props: ReservationListProps) {
182181
const {selectedDay, showOnlySelectedDayItems} = props;
182+
183183
if (!props.items || !selectedDay) {
184184
return {reservations: [], scrollPosition: 0};
185185
}
@@ -276,12 +276,12 @@ class ReservationList extends Component<ReservationListProps, State> {
276276

277277
render() {
278278
const {items, selectedDay, theme, style} = this.props;
279+
279280
if (!items || selectedDay && !items[toMarkingFormat(selectedDay)]) {
280281
if (isFunction(this.props.renderEmptyData)) {
281282
return this.props.renderEmptyData?.();
282283
}
283-
284-
return <ActivityIndicator style={this.style.indicator} color={theme?.indicatorColor} />;
284+
return <ActivityIndicator style={this.style.indicator} color={theme?.indicatorColor}/>;
285285
}
286286

287287
return (

src/agenda/reservation-list/reservation.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {Theme, AgendaEntry} from '../../types';
1515
export interface ReservationProps {
1616
date?: XDate;
1717
item?: AgendaEntry;
18-
/** Specify theme properties to override specific styles for reservation parts. Default = {} */
18+
/** Specify theme properties to override specific styles for item's parts. Default = {} */
1919
theme?: Theme;
2020
/** specify your item comparison function for increased performance */
2121
rowHasChanged?: (a: AgendaEntry, b: AgendaEntry) => boolean;
@@ -33,7 +33,7 @@ class Reservation extends Component<ReservationProps> {
3333
static propTypes = {
3434
date: PropTypes.any,
3535
item: PropTypes.any,
36-
/** Specify theme properties to override specific styles for reservation parts. Default = {} */
36+
/** Specify theme properties to override specific styles for item's parts. Default = {} */
3737
theme: PropTypes.object,
3838
/** specify your item comparison function for increased performance */
3939
rowHasChanged: PropTypes.func,
@@ -49,6 +49,7 @@ class Reservation extends Component<ReservationProps> {
4949

5050
constructor(props: ReservationProps) {
5151
super(props);
52+
5253
this.style = styleConstructor(props.theme);
5354
}
5455

@@ -57,8 +58,8 @@ class Reservation extends Component<ReservationProps> {
5758
const d2 = nextProps.date;
5859
const r1 = this.props.item;
5960
const r2 = nextProps.item;
61+
6062
let changed = true;
61-
6263
if (!d1 && !d2) {
6364
changed = false;
6465
} else if (d1 && d2) {
@@ -97,14 +98,14 @@ class Reservation extends Component<ReservationProps> {
9798
</View>
9899
);
99100
} else {
100-
return <View style={this.style.day} />;
101+
return <View style={this.style.day}/>;
101102
}
102103
}
103104

104105
render() {
105106
const {item, date} = this.props;
107+
106108
let content;
107-
108109
if (item) {
109110
const firstItem = date ? true : false;
110111
if (isFunction(this.props.renderItem)) {

0 commit comments

Comments
 (0)