Skip to content

Commit 396b90c

Browse files
committed
removing HorizontalCalendarListScreen file
1 parent 5948ac6 commit 396b90c

File tree

5 files changed

+56
-90
lines changed

5 files changed

+56
-90
lines changed

example/src/screens/calendarListScreen.tsx

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,17 @@
1-
import React, {useState, useMemo} from 'react';
1+
import React, {useState, useMemo, useCallback} from 'react';
22
import {StyleSheet, Text, View, TextStyle} from 'react-native';
33
import {CalendarList, DateData} from 'react-native-calendars';
44
import testIDs from '../testIDs';
55

66
const RANGE = 24;
77
const initialDate = '2022-07-05';
88

9-
const CalendarListScreen = () => {
9+
interface Props {
10+
horizontalView?: boolean;
11+
}
12+
13+
const CalendarListScreen = (props: Props) => {
14+
const {horizontalView} = props;
1015
const [selected, setSelected] = useState(initialDate);
1116
const marked = useMemo(() => {
1217
return {
@@ -19,20 +24,23 @@ const CalendarListScreen = () => {
1924
};
2025
}, [selected]);
2126

22-
const onDayPress = (day: DateData) => {
27+
const onDayPress = useCallback((day: DateData) => {
2328
setSelected(day.dateString);
24-
};
29+
}, []);
2530

2631
return (
2732
<CalendarList
2833
testID={testIDs.calendarList.CONTAINER}
2934
current={initialDate}
3035
pastScrollRange={RANGE}
3136
futureScrollRange={RANGE}
32-
renderHeader={renderCustomHeader}
33-
theme={theme}
3437
onDayPress={onDayPress}
3538
markedDates={marked}
39+
renderHeader={!horizontalView ? renderCustomHeader : undefined}
40+
theme={!horizontalView ? theme : undefined}
41+
horizontal={horizontalView}
42+
pagingEnabled={horizontalView}
43+
staticHeader={horizontalView}
3644
/>
3745
);
3846
};

example/src/screens/horizontalCalendarListScreen.tsx

Lines changed: 0 additions & 38 deletions
This file was deleted.

example/src/screens/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import MenuScreen from './menuScreen';
44
import CalendarScreen from './calendarScreen';
55
import AgendaScreen from './agendaScreen';
66
import CalendarsListScreen from './calendarListScreen';
7-
import HorizontalCalendarListScreen from './horizontalCalendarListScreen';
87
import NewCalendarsListScreen from './newCalendarListScreen';
98
import ExpandableCalendarScreen from './expandableCalendarScreen';
109
import TimelineCalendarScreen from './timelineCalendarScreen';
@@ -14,7 +13,6 @@ export function registerScreens() {
1413
Navigation.registerComponent('CalendarScreen', () => CalendarScreen);
1514
Navigation.registerComponent('AgendaScreen', () => AgendaScreen);
1615
Navigation.registerComponent('CalendarListScreen', () => CalendarsListScreen);
17-
Navigation.registerComponent('HorizontalCalendarListScreen', () => HorizontalCalendarListScreen);
1816
Navigation.registerComponent('NewCalendarListScreen', () => NewCalendarsListScreen);
1917
Navigation.registerComponent('ExpandableCalendarScreen', () => ExpandableCalendarScreen);
2018
Navigation.registerComponent('TimelineCalendarScreen', () => TimelineCalendarScreen);

example/src/screens/menuScreen.tsx

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import React, {Component} from 'react';
2-
import {Platform, StyleSheet, View, ScrollView, TouchableOpacity, Text, Image, I18nManager, Switch} from 'react-native';
1+
import React, {useState} from 'react';
2+
import {Platform, StyleSheet, I18nManager, View, ScrollView, TouchableOpacity, Text, Image, Switch} from 'react-native';
33
import {Navigation} from 'react-native-navigation';
44
import testIDs from '../testIDs';
55

@@ -8,54 +8,32 @@ const appIcon = require('../img/logo.png');
88
interface Props {
99
componentId?: string;
1010
weekView?: boolean;
11+
horizontalView?: boolean;
1112
}
1213

13-
export default class MenuScreen extends Component<Props> {
14-
state = {
15-
forceRTL: false
16-
}
17-
18-
toggleRTL = (value) => {
14+
const MenuScreen = (props: Props) => {
15+
const {componentId} = props;
16+
const [forceRTL, setForceRTL] = useState(false);
17+
18+
const toggleRTL = (value) => {
1919
I18nManager.forceRTL(value);
20-
this.setState({forceRTL: value});
21-
}
20+
setForceRTL(value);
21+
};
2222

23-
renderEntry(testID: string, title: string, screen: string, options?: any) {
23+
const renderEntry = (testID: string, title: string, screen: string, options?: any) => {
2424
return (
2525
<TouchableOpacity
2626
testID={testID}
2727
style={styles.menu}
28-
onPress={() => this.openScreen(screen, options)}
28+
onPress={() => openScreen(screen, options)}
2929
>
3030
<Text style={styles.menuText}>{title}</Text>
3131
</TouchableOpacity>
3232
);
33-
}
33+
};
3434

35-
render() {
36-
return (
37-
<ScrollView>
38-
<View style={styles.container} testID={testIDs.menu.CONTAINER}>
39-
<Image source={appIcon} style={styles.image}/>
40-
{this.renderEntry(testIDs.menu.CALENDARS, 'Calendar', 'CalendarScreen')}
41-
{this.renderEntry(testIDs.menu.CALENDAR_LIST, 'Calendar List', 'CalendarListScreen')}
42-
{this.renderEntry(testIDs.menu.HORIZONTAL_LIST, 'Horizontal Calendar List', 'HorizontalCalendarListScreen')}
43-
{this.renderEntry(testIDs.menu.HORIZONTAL_LIST, 'NEW Calendar List', 'NewCalendarListScreen')}
44-
{this.renderEntry(testIDs.menu.AGENDA, 'Agenda', 'AgendaScreen')}
45-
{this.renderEntry(testIDs.menu.EXPANDABLE_CALENDAR, 'Expandable Calendar', 'ExpandableCalendarScreen')}
46-
{this.renderEntry(testIDs.menu.TIMELINE_CALENDAR, 'Timeline Calendar', 'TimelineCalendarScreen')}
47-
{this.renderEntry(testIDs.menu.WEEK_CALENDAR, 'Week Calendar', 'ExpandableCalendarScreen', {weekView: true})}
48-
<View style={styles.switchContainer}>
49-
<Text>Force RTL</Text>
50-
<Switch value={this.state.forceRTL} onValueChange={this.toggleRTL}/>
51-
</View>
52-
</View>
53-
</ScrollView>
54-
);
55-
}
56-
57-
pushScreen(screen: string, props?: Props) {
58-
Navigation.push(this.props.componentId, {
35+
const pushScreen = (screen: string, props?: Props) => {
36+
Navigation.push(componentId, {
5937
component: {
6038
name: screen,
6139
passProps: props,
@@ -73,12 +51,34 @@ export default class MenuScreen extends Component<Props> {
7351
}
7452
}
7553
});
76-
}
54+
};
7755

78-
openScreen = (screen: string, options: any) => {
79-
this.pushScreen(screen, options);
80-
}
81-
}
56+
const openScreen = (screen: string, options: any) => {
57+
pushScreen(screen, options);
58+
};
59+
60+
return (
61+
<ScrollView>
62+
<View style={styles.container} testID={testIDs.menu.CONTAINER}>
63+
<Image source={appIcon} style={styles.image}/>
64+
{renderEntry(testIDs.menu.CALENDARS, 'Calendar', 'CalendarScreen')}
65+
{renderEntry(testIDs.menu.CALENDAR_LIST, 'Calendar List', 'CalendarListScreen')}
66+
{renderEntry(testIDs.menu.HORIZONTAL_LIST, 'Horizontal Calendar List', 'CalendarListScreen', {horizontalView: true})}
67+
{renderEntry(testIDs.menu.HORIZONTAL_LIST, 'NEW Calendar List', 'NewCalendarListScreen')}
68+
{renderEntry(testIDs.menu.AGENDA, 'Agenda', 'AgendaScreen')}
69+
{renderEntry(testIDs.menu.EXPANDABLE_CALENDAR, 'Expandable Calendar', 'ExpandableCalendarScreen')}
70+
{renderEntry(testIDs.menu.TIMELINE_CALENDAR, 'Timeline Calendar', 'TimelineCalendarScreen')}
71+
{renderEntry(testIDs.menu.WEEK_CALENDAR, 'Week Calendar', 'ExpandableCalendarScreen', {weekView: true})}
72+
<View style={styles.switchContainer}>
73+
<Text>Force RTL</Text>
74+
<Switch value={forceRTL} onValueChange={toggleRTL}/>
75+
</View>
76+
</View>
77+
</ScrollView>
78+
);
79+
};
80+
81+
export default MenuScreen;
8282

8383
const styles = StyleSheet.create({
8484
container: {
@@ -94,7 +94,6 @@ const styles = StyleSheet.create({
9494
width: 300,
9595
padding: 10,
9696
margin: 10,
97-
// backgroundColor: '#f2F4f5',
9897
alignItems: 'center',
9998
borderRadius: 20,
10099
borderWidth: 1,

tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
"example/src/screens/expandableCalendarScreen.tsx",
3030
"example/src/screens/agendaScreen.tsx",
3131
"example/src/screens/timelineCalendarScreen.tsx",
32-
"example/src/screens/horizontalCalendarListScreen.tsx",
3332
"example/src/screens/calendarListScreen.tsx",
3433
"example/src/screens/newCalendarListScreen.tsx"
3534
],

0 commit comments

Comments
 (0)