11import 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' ;
33import { Navigation } from 'react-native-navigation' ;
44import testIDs from '../testIDs' ;
55
@@ -11,52 +11,30 @@ interface Props {
1111}
1212
1313export 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
0 commit comments