@@ -28,10 +28,10 @@ function getFutureDates(days) {
28
28
}
29
29
30
30
function getPastDate ( days ) {
31
- return new Date ( Date . now ( ) - ( 864e5 * days ) ) . toISOString ( ) . split ( 'T' ) [ 0 ] ; // 864e5 == 86400000 == 24*60*60*1000
31
+ return new Date ( Date . now ( ) - ( 864e5 * days ) ) . toISOString ( ) . split ( 'T' ) [ 0 ] ;
32
32
}
33
33
34
- const items = [
34
+ const ITEMS = [
35
35
{ title : dates [ 0 ] , data : [ { hour : '12am' , duration : '1h' , title : 'Ashtanga Yoga' } ] } ,
36
36
{ title : dates [ 1 ] , data : [ { hour : '4pm' , duration : '1h' , title : 'Pilates ABC' } , { hour : '5pm' , duration : '1h' , title : 'Vinyasa Yoga' } ] } ,
37
37
{ title : dates [ 2 ] , data : [ { hour : '1pm' , duration : '1h' , title : 'Ashtanga Yoga' } , { hour : '2pm' , duration : '1h' , title : 'Deep Streches' } , { hour : '3pm' , duration : '1h' , title : 'Private Yoga' } ] } ,
@@ -46,11 +46,19 @@ const items = [
46
46
] ;
47
47
48
48
export default class ExpandableCalendarScreen extends Component {
49
-
49
+
50
50
onDateChanged = ( /**date, updateSource*/ ) => {
51
51
// console.warn('ExpandableCalendarScreen onDateChanged: ', date, updateSource);
52
52
// fetch and set data for date + week ahead
53
53
}
54
+
55
+ buttonPressed ( ) {
56
+ Alert . alert ( 'show more' ) ;
57
+ }
58
+
59
+ itemPressed ( id ) {
60
+ Alert . alert ( id ) ;
61
+ }
54
62
55
63
renderEmptyItem ( ) {
56
64
return (
@@ -64,36 +72,27 @@ export default class ExpandableCalendarScreen extends Component {
64
72
if ( _ . isEmpty ( item ) ) {
65
73
return this . renderEmptyItem ( ) ;
66
74
}
67
-
68
- const id = item . title ;
69
- const props = {
70
- hour : item . hour ,
71
- duration : item . duration ,
72
- title : item . title ,
73
- button : { label : 'info' , onPress : ( ) => Alert . alert ( 'show more' ) } ,
74
- onPress : ( ) => Alert . alert ( id )
75
- } ;
76
-
75
+
77
76
return (
78
77
< TouchableOpacity
79
- onPress = { props . onPress }
78
+ onPress = { ( ) => this . itemPressed ( item . title ) }
80
79
style = { styles . item }
81
80
>
82
81
< View >
83
- < Text style = { styles . itemHourText } > { props . hour } </ Text >
84
- < Text style = { styles . itemDurationText } > { props . duration } </ Text >
82
+ < Text style = { styles . itemHourText } > { item . hour } </ Text >
83
+ < Text style = { styles . itemDurationText } > { item . duration } </ Text >
85
84
</ View >
86
- < Text style = { styles . itemTitleText } > { props . title } </ Text >
85
+ < Text style = { styles . itemTitleText } > { item . title } </ Text >
87
86
< View style = { styles . itemButtonContainer } >
88
- < Button title = { props . button . label } onPress = { props . button . onPress } />
87
+ < Button title = { 'Info' } onPress = { this . buttonPressed } />
89
88
</ View >
90
89
</ TouchableOpacity >
91
90
) ;
92
91
}
93
92
94
93
getMarkedDates = ( ) => {
95
94
const marked = { } ;
96
- items . forEach ( item => {
95
+ ITEMS . forEach ( item => {
97
96
// only mark dates with data
98
97
if ( item . data && item . data . length > 0 && ! _ . isEmpty ( item . data [ 0 ] ) ) {
99
98
marked [ item . title ] = { marked : true } ;
@@ -146,10 +145,8 @@ export default class ExpandableCalendarScreen extends Component {
146
145
}
147
146
148
147
render ( ) {
149
- const style = { paddingLeft : 20 , paddingRight : 20 } ;
150
-
151
148
return (
152
- < CalendarProvider date = { items [ 0 ] . title } onDateChanged = { this . onDateChanged } theme = { { todayButtonTextColor : '#0059ff' } } showTodayButton >
149
+ < CalendarProvider date = { ITEMS [ 0 ] . title } onDateChanged = { this . onDateChanged } theme = { { todayButtonTextColor : '#0059ff' } } showTodayButton >
153
150
< ExpandableCalendar
154
151
// horizontal={false}
155
152
// hideArrows
@@ -158,24 +155,33 @@ export default class ExpandableCalendarScreen extends Component {
158
155
// initialPosition={'open'} // ExpandableCalendar.positions.OPEN - can't find static positions
159
156
firstDay = { 1 }
160
157
markedDates = { this . getMarkedDates ( ) } // {'2019-06-01': {marked: true}, '2019-06-02': {marked: true}, '2019-06-03': {marked: true} };
161
- calendarStyle = { style }
158
+ calendarStyle = { styles . calendar }
162
159
theme = { this . getTheme ( ) }
163
160
leftArrowImageSource = { require ( '../img/previous.png' ) }
164
161
rightArrowImageSource = { require ( '../img/next.png' ) }
165
- headerStyle = { style }
162
+ headerStyle = { styles . calendar }
166
163
/>
167
164
< AgendaList
168
- data = { items }
169
- sections = { items }
165
+ data = { ITEMS }
166
+ sections = { ITEMS }
167
+ extraData = { this . state }
170
168
renderItem = { this . renderItem }
171
- // sectionStyle={{backgroundColor: '#f0f4f7', color: '#79838a'} }
169
+ // sectionStyle={styles.section }
172
170
/>
173
171
</ CalendarProvider >
174
172
) ;
175
173
}
176
174
}
177
175
178
176
const styles = StyleSheet . create ( {
177
+ calendar : {
178
+ paddingLeft : 20 ,
179
+ paddingRight : 20
180
+ } ,
181
+ section : {
182
+ backgroundColor : '#f0f4f7' ,
183
+ color : '#79838a'
184
+ } ,
179
185
item : {
180
186
padding : 20 ,
181
187
backgroundColor : 'white' ,
0 commit comments