1+ import groupBy from 'lodash/groupBy' ;
2+ import filter from 'lodash/filter' ;
3+ import find from 'lodash/find' ;
4+
15import React , { Component } from 'react' ;
26import { Alert } from 'react-native' ;
37import {
@@ -8,132 +12,16 @@ import {
812 TimelineProps ,
913 CalendarUtils
1014} from 'react-native-calendars' ;
11- import _ from 'lodash' ;
1215
13- const INITIAL_TIME = { hour : 9 , minutes : 0 } ;
14- const today = new Date ( ) ;
15- const getDate = ( offset = 0 ) => CalendarUtils . getCalendarDateString ( new Date ( ) . setDate ( today . getDate ( ) + offset ) ) ;
16- const EVENT_COLOR = '#e6add8' ;
17- const EVENTS : TimelineEventProps [ ] = [
18- {
19- start : `${ getDate ( - 1 ) } 09:20:00` ,
20- end : `${ getDate ( - 1 ) } 12:00:00` ,
21- title : 'Merge Request to React Native Calendars' ,
22- summary : 'Merge Timeline Calendar to React Native Calendars'
23- } ,
24- {
25- start : `${ getDate ( ) } 01:15:00` ,
26- end : `${ getDate ( ) } 02:30:00` ,
27- title : 'Meeting A' ,
28- summary : 'Summary for meeting A' ,
29- color : EVENT_COLOR
30- } ,
31- {
32- start : `${ getDate ( ) } 01:30:00` ,
33- end : `${ getDate ( ) } 02:30:00` ,
34- title : 'Meeting B' ,
35- summary : 'Summary for meeting B' ,
36- color : EVENT_COLOR
37- } ,
38- {
39- start : `${ getDate ( ) } 01:45:00` ,
40- end : `${ getDate ( ) } 02:45:00` ,
41- title : 'Meeting C' ,
42- summary : 'Summary for meeting C' ,
43- color : EVENT_COLOR
44- } ,
45- {
46- start : `${ getDate ( ) } 02:40:00` ,
47- end : `${ getDate ( ) } 03:10:00` ,
48- title : 'Meeting D' ,
49- summary : 'Summary for meeting D' ,
50- color : EVENT_COLOR
51- } ,
52- {
53- start : `${ getDate ( ) } 02:50:00` ,
54- end : `${ getDate ( ) } 03:20:00` ,
55- title : 'Meeting E' ,
56- summary : 'Summary for meeting E' ,
57- color : EVENT_COLOR
58- } ,
59- {
60- start : `${ getDate ( ) } 04:30:00` ,
61- end : `${ getDate ( ) } 05:30:00` ,
62- title : 'Meeting F' ,
63- summary : 'Summary for meeting F' ,
64- color : EVENT_COLOR
65- } ,
66- {
67- start : `${ getDate ( 1 ) } 00:30:00` ,
68- end : `${ getDate ( 1 ) } 01:30:00` ,
69- title : 'Visit Grand Mother' ,
70- summary : 'Visit Grand Mother and bring some fruits.' ,
71- color : 'lightblue'
72- } ,
73- {
74- start : `${ getDate ( 1 ) } 02:30:00` ,
75- end : `${ getDate ( 1 ) } 03:20:00` ,
76- title : 'Meeting with Prof. Behjet Zuhaira' ,
77- summary : 'Meeting with Prof. Behjet at 130 in her office.' ,
78- color : EVENT_COLOR
79- } ,
80- {
81- start : `${ getDate ( 1 ) } 04:10:00` ,
82- end : `${ getDate ( 1 ) } 04:40:00` ,
83- title : 'Tea Time with Dr. Hasan' ,
84- summary : 'Tea Time with Dr. Hasan, Talk about Project'
85- } ,
86- {
87- start : `${ getDate ( 1 ) } 01:05:00` ,
88- end : `${ getDate ( 1 ) } 01:35:00` ,
89- title : 'Dr. Mariana Joseph' ,
90- summary : '3412 Piedmont Rd NE, GA 3032'
91- } ,
92- {
93- start : `${ getDate ( 1 ) } 14:30:00` ,
94- end : `${ getDate ( 1 ) } 16:30:00` ,
95- title : 'Meeting Some Friends in ARMED' ,
96- summary : 'Arsalan, Hasnaat, Talha, Waleed, Bilal' ,
97- color : 'pink'
98- } ,
99- {
100- start : `${ getDate ( 2 ) } 01:40:00` ,
101- end : `${ getDate ( 2 ) } 02:25:00` ,
102- title : 'Meet Sir Khurram Iqbal' ,
103- summary : 'Computer Science Dept. Comsats Islamabad' ,
104- color : 'orange'
105- } ,
106- {
107- start : `${ getDate ( 2 ) } 04:10:00` ,
108- end : `${ getDate ( 2 ) } 04:40:00` ,
109- title : 'Tea Time with Colleagues' ,
110- summary : 'WeRplay'
111- } ,
112- {
113- start : `${ getDate ( 2 ) } 00:45:00` ,
114- end : `${ getDate ( 2 ) } 01:45:00` ,
115- title : 'Lets Play Apex Legends' ,
116- summary : 'with Boys at Work'
117- } ,
118- {
119- start : `${ getDate ( 2 ) } 11:30:00` ,
120- end : `${ getDate ( 2 ) } 12:30:00` ,
121- title : 'Dr. Mariana Joseph' ,
122- summary : '3412 Piedmont Rd NE, GA 3032'
123- } ,
124- {
125- start : `${ getDate ( 4 ) } 12:10:00` ,
126- end : `${ getDate ( 4 ) } 13:45:00` ,
127- title : 'Merge Request to React Native Calendars' ,
128- summary : 'Merge Timeline Calendar to React Native Calendars'
129- }
130- ] ;
16+ import { timelineEvents , getDate } from '../mocks/timelineEvents' ;
13117
18+ const INITIAL_TIME = { hour : 9 , minutes : 0 } ;
19+ const EVENTS : TimelineEventProps [ ] = timelineEvents ;
13220export default class TimelineCalendarScreen extends Component {
13321 state = {
13422 currentDate : getDate ( ) ,
13523 events : EVENTS ,
136- eventsByDate : _ . groupBy ( EVENTS , e => CalendarUtils . getCalendarDateString ( e . start ) ) as {
24+ eventsByDate : groupBy ( EVENTS , e => CalendarUtils . getCalendarDateString ( e . start ) ) as {
13725 [ key : string ] : TimelineEventProps [ ] ;
13826 }
13927 } ;
@@ -147,13 +35,11 @@ export default class TimelineCalendarScreen extends Component {
14735 } ;
14836
14937 onDateChanged = ( date : string ) => {
150- // console.warn('TimelineCalendarScreen onDateChanged: ', date, updateSource);
151- // fetch and set data for date + week ahead
15238 this . setState ( { currentDate : date } ) ;
15339 } ;
15440
155- onMonthChange = ( /* month, updateSource */ ) => {
156- // console.warn ('TimelineCalendarScreen onMonthChange: ', month, updateSource);
41+ onMonthChange = ( month : any , updateSource : any ) => {
42+ console . log ( 'TimelineCalendarScreen onMonthChange: ' , month , updateSource ) ;
15743 } ;
15844
15945 createNewEvent : TimelineProps [ 'onBackgroundLongPress' ] = ( timeString , timeObject ) => {
@@ -188,7 +74,7 @@ export default class TimelineCalendarScreen extends Component {
18874 text : 'Cancel' ,
18975 onPress : ( ) => {
19076 if ( timeObject . date ) {
191- eventsByDate [ timeObject . date ] = _ . filter ( eventsByDate [ timeObject . date ] , e => e . id !== 'draft' ) ;
77+ eventsByDate [ timeObject . date ] = filter ( eventsByDate [ timeObject . date ] , e => e . id !== 'draft' ) ;
19278
19379 this . setState ( {
19480 eventsByDate
@@ -200,7 +86,7 @@ export default class TimelineCalendarScreen extends Component {
20086 text : 'Create' ,
20187 onPress : eventTitle => {
20288 if ( timeObject . date ) {
203- const draftEvent = _ . find ( eventsByDate [ timeObject . date ] , { id : 'draft' } ) ;
89+ const draftEvent = find ( eventsByDate [ timeObject . date ] , { id : 'draft' } ) ;
20490 if ( draftEvent ) {
20591 draftEvent . id = undefined ;
20692 draftEvent . title = eventTitle ?? 'New Event' ;
0 commit comments