unicorn-demo-app 7.40.1 → 7.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -260,6 +260,9 @@ module.exports = {
|
|
|
260
260
|
get IncubatorExpandableOverlay() {
|
|
261
261
|
return require('./screens/incubatorScreens/IncubatorExpandableOverlayScreen').default;
|
|
262
262
|
},
|
|
263
|
+
get IncubatorCalendarScreen() {
|
|
264
|
+
return require('./screens/incubatorScreens/IncubatorCalendarScreen').default;
|
|
265
|
+
},
|
|
263
266
|
// realExamples
|
|
264
267
|
get AppleMusic() {
|
|
265
268
|
return require('./screens/realExamples/AppleMusic').default;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
|
+
import {StyleSheet} from 'react-native';
|
|
2
3
|
import React, {Component} from 'react';
|
|
3
|
-
import {Incubator, View, Text} from 'react-native-ui-lib';
|
|
4
|
+
import {Incubator, View, Text, Card, Colors} from 'react-native-ui-lib';
|
|
4
5
|
import MockServer from './MockServer';
|
|
5
6
|
|
|
6
7
|
export default class CalendarScreen extends Component {
|
|
7
8
|
pageIndex = 0;
|
|
9
|
+
loadingEventsPromise?: Promise<any[]>;
|
|
8
10
|
|
|
9
11
|
state = {
|
|
10
|
-
date: new Date().getTime(),
|
|
12
|
+
date: new Date(/* '2025-01-12' */).getTime(),
|
|
11
13
|
events: [] as any[],
|
|
12
14
|
showLoader: false
|
|
13
15
|
};
|
|
@@ -16,17 +18,25 @@ export default class CalendarScreen extends Component {
|
|
|
16
18
|
this.loadEvents(this.state.date);
|
|
17
19
|
}
|
|
18
20
|
|
|
19
|
-
|
|
21
|
+
// Note: we throttle event loading because initially the Agenda reach end and trigger extra event load
|
|
22
|
+
loadEvents = (async (date: number) => {
|
|
23
|
+
|
|
24
|
+
if (this.loadingEventsPromise) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
20
28
|
this.setState({showLoader: true});
|
|
21
29
|
// const {events} = this.state;
|
|
22
|
-
|
|
30
|
+
this.loadingEventsPromise = MockServer.getEvents(date);
|
|
31
|
+
const newEvents = await this.loadingEventsPromise;
|
|
32
|
+
this.loadingEventsPromise = undefined;
|
|
23
33
|
this.pageIndex++;
|
|
24
34
|
// this.setState({events: _.uniqBy([...events, ...newEvents], e => e.id), showLoader: false});
|
|
25
35
|
this.setState({events: newEvents, showLoader: false});
|
|
26
|
-
};
|
|
36
|
+
});
|
|
27
37
|
|
|
28
38
|
onChangeDate = (date: number) => {
|
|
29
|
-
console.log('Date change: ', date);
|
|
39
|
+
/* console.log('Date change: ', date); */
|
|
30
40
|
const {events} = this.state;
|
|
31
41
|
if (date < events[0]?.start || date > _.last(events)?.start) {
|
|
32
42
|
console.log('Load new events');
|
|
@@ -41,28 +51,37 @@ export default class CalendarScreen extends Component {
|
|
|
41
51
|
|
|
42
52
|
// TODO: Fix type once we export them
|
|
43
53
|
renderEvent = (eventItem: any) => {
|
|
54
|
+
const makeEventBigger = new Date(eventItem.start).getDay() % 2 === 0;
|
|
55
|
+
const startTime = new Date(eventItem.start).toLocaleString('en-GB', {
|
|
56
|
+
// month: 'short',
|
|
57
|
+
// day: 'numeric',
|
|
58
|
+
hour12: false,
|
|
59
|
+
hour: '2-digit',
|
|
60
|
+
minute: '2-digit'
|
|
61
|
+
});
|
|
62
|
+
const endTime = new Date(eventItem.end).toLocaleString('en-GB', {
|
|
63
|
+
hour12: false,
|
|
64
|
+
hour: '2-digit',
|
|
65
|
+
minute: '2-digit'
|
|
66
|
+
});
|
|
44
67
|
return (
|
|
45
|
-
<
|
|
46
|
-
<Text>
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
day: 'numeric',
|
|
51
|
-
hour12: false,
|
|
52
|
-
hour: '2-digit',
|
|
53
|
-
minute: '2-digit'
|
|
54
|
-
})}
|
|
55
|
-
-{new Date(eventItem.end).toLocaleString('en-GB', {hour12: false, hour: '2-digit', minute: '2-digit'})}
|
|
68
|
+
<Card marginH-s5 marginB-s4 padding-s4 backgroundColor={Colors.$backgroundGeneralLight}>
|
|
69
|
+
<Text text70>Event Title</Text>
|
|
70
|
+
{makeEventBigger && <Text>Event short description</Text>}
|
|
71
|
+
<Text marginT-s1 text90>
|
|
72
|
+
{startTime}-{endTime}
|
|
56
73
|
</Text>
|
|
57
|
-
</
|
|
74
|
+
</Card>
|
|
58
75
|
);
|
|
59
76
|
};
|
|
60
77
|
|
|
61
78
|
// TODO: Fix type once we export them
|
|
62
79
|
renderHeader = (headerItem: any) => {
|
|
63
80
|
return (
|
|
64
|
-
<View centerV flex
|
|
65
|
-
<Text>
|
|
81
|
+
<View bg-$backgroundDefault paddingH-s5 centerV flex paddingV-s2 style={styles.sectionHeader}>
|
|
82
|
+
<Text text70BO>
|
|
83
|
+
{new Date(headerItem.date).toLocaleString('en-US', {weekday: 'long', day: 'numeric', month: 'short'})}
|
|
84
|
+
</Text>
|
|
66
85
|
</View>
|
|
67
86
|
);
|
|
68
87
|
};
|
|
@@ -71,15 +90,23 @@ export default class CalendarScreen extends Component {
|
|
|
71
90
|
const {date, events, showLoader} = this.state;
|
|
72
91
|
|
|
73
92
|
return (
|
|
74
|
-
<
|
|
75
|
-
<Incubator.Calendar.
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
93
|
+
<View flex>
|
|
94
|
+
<Incubator.Calendar data={events} initialDate={date} onChangeDate={this.onChangeDate} staticHeader>
|
|
95
|
+
<Incubator.Calendar.Agenda
|
|
96
|
+
renderEvent={this.renderEvent}
|
|
97
|
+
renderHeader={this.renderHeader}
|
|
98
|
+
onEndReached={this.onEndReached}
|
|
99
|
+
showLoader={showLoader}
|
|
100
|
+
/>
|
|
101
|
+
</Incubator.Calendar>
|
|
102
|
+
<Incubator.Toast visible={showLoader} message="Loading events..." preset="general"/>
|
|
103
|
+
</View>
|
|
83
104
|
);
|
|
84
105
|
}
|
|
85
106
|
}
|
|
107
|
+
|
|
108
|
+
const styles = StyleSheet.create({
|
|
109
|
+
sectionHeader: {
|
|
110
|
+
opacity: 0.9
|
|
111
|
+
}
|
|
112
|
+
});
|