Skip to content

Commit a2738d9

Browse files
committed
edit menu screen
1 parent 4233dd1 commit a2738d9

File tree

2 files changed

+25
-70
lines changed

2 files changed

+25
-70
lines changed

example/src/screens/menu.tsx

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

@@ -11,52 +11,30 @@ interface Props {
1111
}
1212

1313
export default class MenuScreen extends Component<Props> {
14+
renderEntry(testID: string, title: string, screen: string, options?: any) {
15+
return (
16+
<TouchableOpacity
17+
testID={testID}
18+
style={styles.menu}
19+
onPress={() => this.openScreen(screen, options)}
20+
>
21+
<Text style={styles.menuText}>{title}</Text>
22+
</TouchableOpacity>
23+
);
24+
}
25+
1426
render() {
1527
return (
1628
<ScrollView>
1729
<View style={styles.container} testID={testIDs.menu.CONTAINER}>
18-
<Image source={appIcon} style={styles.image} />
19-
<TouchableOpacity
20-
testID={testIDs.menu.CALENDARS}
21-
style={styles.menu}
22-
onPress={this.onCalendarsPress.bind(this)}
23-
>
24-
<Text style={styles.menuText}>Calendars</Text>
25-
</TouchableOpacity>
26-
<TouchableOpacity
27-
testID={testIDs.menu.CALENDAR_LIST}
28-
style={styles.menu}
29-
onPress={this.onCalendarListPress.bind(this)}
30-
>
31-
<Text style={styles.menuText}>Calendar List</Text>
32-
</TouchableOpacity>
33-
<TouchableOpacity
34-
testID={testIDs.menu.HORIZONTAL_LIST}
35-
style={styles.menu}
36-
onPress={this.onHorizontalCalendarListPress.bind(this)}
37-
>
38-
<Text style={styles.menuText}>Horizontal Calendar List</Text>
39-
</TouchableOpacity>
40-
<TouchableOpacity testID={testIDs.menu.AGENDA} style={styles.menu} onPress={this.onAgendaPress.bind(this)}>
41-
<Text style={styles.menuText}>Agenda</Text>
42-
</TouchableOpacity>
43-
<TouchableOpacity
44-
testID={testIDs.menu.EXPANDABLE_CALENDAR}
45-
style={styles.menu}
46-
onPress={this.onExpandablePress.bind(this)}
47-
>
48-
<Text style={styles.menuText}>Expandable Calendar</Text>
49-
</TouchableOpacity>
50-
<TouchableOpacity style={styles.menu} onPress={this.onTimelinePress.bind(this)}>
51-
<Text style={styles.menuText}>Timeline Calendar</Text>
52-
</TouchableOpacity>
53-
<TouchableOpacity
54-
testID={testIDs.menu.WEEK_CALENDAR}
55-
style={styles.menu}
56-
onPress={this.onWeekPress.bind(this)}
57-
>
58-
<Text style={styles.menuText}>Week Calendar</Text>
59-
</TouchableOpacity>
30+
<Image source={appIcon} style={styles.image}/>
31+
{this.renderEntry(testIDs.menu.CALENDARS, 'Calendars', 'Calendars')}
32+
{this.renderEntry(testIDs.menu.CALENDAR_LIST, 'Calendar List', 'CalendarsList')}
33+
{this.renderEntry(testIDs.menu.HORIZONTAL_LIST, 'Horizontal Calendar List', 'HorizontalCalendarList')}
34+
{this.renderEntry(testIDs.menu.AGENDA, 'Agenda', 'Agenda')}
35+
{this.renderEntry(testIDs.menu.EXPANDABLE_CALENDAR, 'Expandable Calendar', 'ExpandableCalendar')}
36+
{this.renderEntry(testIDs.menu.TIMELINE_CALENDAR, 'Timeline Calendar', 'TimelineCalendar')}
37+
{this.renderEntry(testIDs.menu.WEEK_CALENDAR, 'Week Calendar', 'ExpandableCalendar', {weekView: true})}
6038
</View>
6139
</ScrollView>
6240
);
@@ -83,32 +61,8 @@ export default class MenuScreen extends Component<Props> {
8361
});
8462
}
8563

86-
onCalendarsPress() {
87-
this.pushScreen('Calendars');
88-
}
89-
90-
onCalendarListPress() {
91-
this.pushScreen('CalendarsList');
92-
}
93-
94-
onHorizontalCalendarListPress() {
95-
this.pushScreen('HorizontalCalendarList');
96-
}
97-
98-
onAgendaPress() {
99-
this.pushScreen('Agenda');
100-
}
101-
102-
onExpandablePress() {
103-
this.pushScreen('ExpandableCalendar');
104-
}
105-
106-
onTimelinePress() {
107-
this.pushScreen('TimelineCalendar');
108-
}
109-
110-
onWeekPress() {
111-
this.pushScreen('ExpandableCalendar', {weekView: true});
64+
openScreen = (screen: string, options: any) => {
65+
this.pushScreen(screen, options);
11266
}
11367
}
11468

example/src/testIDs.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ export default {
66
HORIZONTAL_LIST: 'horizontal_list_btn',
77
AGENDA: 'agenda_btn',
88
EXPANDABLE_CALENDAR: 'expandable_calendar_btn',
9-
WEEK_CALENDAR: 'week_calendar_btn'
9+
WEEK_CALENDAR: 'week_calendar_btn',
10+
TIMELINE_CALENDAR: 'timeline_calendar_btn'
1011
},
1112
calendars: {
1213
CONTAINER: 'calendars',

0 commit comments

Comments
 (0)