@olea-bps/components 1.0.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/AppBar/index.js +83 -0
- package/AppBar/styles.js +27 -0
- package/BookDetail/index.js +268 -0
- package/BookDetail/styles.js +124 -0
- package/Component/342/200/216JobsFilter/index.js +188 -0
- package/Component/342/200/216JobsFilter/styles.js +12 -0
- package/ConnectivityWarning/index.js +65 -0
- package/ConnectivityWarning/styles.js +19 -0
- package/ContactDetail/index.js +232 -0
- package/ContactDetail/styles.js +32 -0
- package/CourseDetail/index.js +357 -0
- package/CourseDetail/styles.js +59 -0
- package/CourseDetailDialog/index.js +169 -0
- package/CourseDetailDialog/styles.js +116 -0
- package/CourseInfo/index.js +219 -0
- package/CourseInfo/styles.js +40 -0
- package/DevelopmentDialog/index.js +208 -0
- package/DevelopmentDialog/styles.js +10 -0
- package/EventCodeInput/index.js +146 -0
- package/EventCodeInput/styles.js +108 -0
- package/FlexMenuEntry/index.js +84 -0
- package/FlexMenuEntry/styles.js +27 -0
- package/MainMenuEntry/index.js +88 -0
- package/MainMenuEntry/styles.js +28 -0
- package/MealItem/index.js +87 -0
- package/MealItem/styles.js +73 -0
- package/MensaMenu/index.js +307 -0
- package/MensaMenu/styles.js +94 -0
- package/MensaSlider/index.js +184 -0
- package/MensaSlider/styles.js +53 -0
- package/Modal/index.js +106 -0
- package/Modal/styles.js +8 -0
- package/NewsDetail/index.js +377 -0
- package/NewsDetail/styles.js +77 -0
- package/NewsList/index.js +120 -0
- package/NewsList/styles.js +19 -0
- package/NewsListItem/index.js +89 -0
- package/NewsListItem/styles.js +32 -0
- package/OtherCourses/index.js +152 -0
- package/OtherCourses/styles.js +10 -0
- package/PtsDeparture/index.js +140 -0
- package/PtsDeparture/styles.js +7 -0
- package/PtsStation/index.js +183 -0
- package/PtsStation/styles.js +47 -0
- package/QuickLinks/index.js +127 -0
- package/QuickLinks/styles.js +45 -0
- package/RoomDetail/index.js +281 -0
- package/RoomDetail/styles.js +56 -0
- package/ScaledImage/index.js +92 -0
- package/SearchResults/index.js +362 -0
- package/SearchResults/styles.js +59 -0
- package/SettingSection/index.js +54 -0
- package/SettingSection/styles.js +15 -0
- package/SettingsDialog/index.js +52 -0
- package/SettingsDialog/styles.js +12 -0
- package/SettingsDialogRadio/index.js +66 -0
- package/SettingsDialogRadio/styles.js +7 -0
- package/SettingsDialogSelect/index.js +73 -0
- package/SettingsDialogSelect/styles.js +7 -0
- package/TimetableCodeInput/index.js +201 -0
- package/TimetableCodeInput/styles.js +28 -0
- package/TimetableDay/index.js +266 -0
- package/TimetableDay/styles.js +103 -0
- package/TimetableEvent/index.js +163 -0
- package/TimetableEvent/styles.js +108 -0
- package/TimetableList/index.js +116 -0
- package/TimetableList/styles.js +109 -0
- package/TimetableMonth/index.js +156 -0
- package/TimetableMonth/styles.js +29 -0
- package/TimetableWeek/index.js +245 -0
- package/TimetableWeek/styles.js +58 -0
- package/TopNews/index.js +282 -0
- package/TopNews/styles.js +125 -0
- package/TopNewsHtwk/index.js +279 -0
- package/TopNewsHtwk/styles.js +142 -0
- package/WebView/index.js +108 -0
- package/WebView/styles.js +11 -0
- package/index.js +39 -0
- package/package.json +37 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
* you may not use this file except in compliance with the License.
|
|
4
|
+
* You may obtain a copy of the License at
|
|
5
|
+
*
|
|
6
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
*
|
|
8
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
* See the License for the specific language governing permissions and
|
|
12
|
+
* limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { useState, useMemo } from 'react';
|
|
16
|
+
import {
|
|
17
|
+
StyleSheet,
|
|
18
|
+
View,
|
|
19
|
+
TouchableOpacity,
|
|
20
|
+
Pressable,
|
|
21
|
+
Linking,
|
|
22
|
+
} from 'react-native';
|
|
23
|
+
|
|
24
|
+
import { connect } from 'react-redux'
|
|
25
|
+
import {
|
|
26
|
+
withTheme,
|
|
27
|
+
Text
|
|
28
|
+
} from 'react-native-paper';
|
|
29
|
+
import { withTranslation } from 'react-i18next';
|
|
30
|
+
|
|
31
|
+
import { onUpdateRefreshing } from '@olea-bps/core';
|
|
32
|
+
import IconsOpenasist from '@olea-bps/icons-openasist';
|
|
33
|
+
|
|
34
|
+
import componentStyles from './styles';
|
|
35
|
+
|
|
36
|
+
function TimetableEventComponent(props) {
|
|
37
|
+
const componentName = TimetableEventComponent.name;
|
|
38
|
+
|
|
39
|
+
const {
|
|
40
|
+
theme,
|
|
41
|
+
t,
|
|
42
|
+
settings,
|
|
43
|
+
times,
|
|
44
|
+
type,
|
|
45
|
+
title,
|
|
46
|
+
location,
|
|
47
|
+
locationUrl,
|
|
48
|
+
description,
|
|
49
|
+
starrable,
|
|
50
|
+
onSelectionChange
|
|
51
|
+
} = props;
|
|
52
|
+
|
|
53
|
+
const isBigFont = settings?.settingsAccessibility?.increaseFontSize ?? false;
|
|
54
|
+
const [isSelected, setIsSelected] = useState(false);
|
|
55
|
+
|
|
56
|
+
const styles = useMemo(
|
|
57
|
+
() => StyleSheet.create(componentStyles(theme)),
|
|
58
|
+
[theme]
|
|
59
|
+
)
|
|
60
|
+
|
|
61
|
+
const handleSelectionChange = () => {
|
|
62
|
+
setIsSelected(isSelected => !isSelected);
|
|
63
|
+
|
|
64
|
+
onSelectionChange?.(!isSelected)
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const accessibilityStartTime = t('accessibility:timetable:startTime') + times?.start.slice(0, 2) + ' ' + t('accessibility:pts:speechTime') + ' ' + (times?.start.slice(3, 5) !== '00' ? times?.start.slice(3, 5) : '') + ',';
|
|
68
|
+
const accessibilityEndTime = t('accessibility:timetable:endTime') + times?.end.slice(0, 2) + ' ' + t('accessibility:pts:speechTime') + ' ' + (times?.end.slice(3, 5) !== '00' ? times?.end.slice(3, 5) : '') + ',';
|
|
69
|
+
const courseContainerBigFont = isBigFont ? styles.courseContainerBigFont : null;
|
|
70
|
+
const titleStyle = isBigFont ? styles.titleBigFont : styles.title;
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<View style={[isBigFont ? [styles.card, styles.courseCard] : styles.card, { backgroundColor: 'rgba(0, 95, 80, 0.25)', elevation: 0 }]} onPress={() => { console.log("Clicking is currently not working. Don't try it!") }}>
|
|
74
|
+
{
|
|
75
|
+
//times
|
|
76
|
+
// ? <View style={[isBigFont ? [styles.courseTimeContainer, styles.courseTimeContainerBigFont] : styles.courseTimeContainer, { backgroundColor: 'rgba(0, 95, 80, 0)' }]}>
|
|
77
|
+
// <Text accessibilityLabel={accessibilityStartTime} style={isBigFont ? [styles.timeText, styles.timeTextBig] : styles.timeText}>{times?.start || ''}</Text>
|
|
78
|
+
// <View style={styles.verticalSeperatorSmall} />
|
|
79
|
+
// <Text accessibilityLabel={accessibilityEndTime} style={isBigFont ? [styles.timeText, styles.timeTextBig] : styles.timeText}>{times?.end || ''}</Text>
|
|
80
|
+
// </View>
|
|
81
|
+
// : null
|
|
82
|
+
}
|
|
83
|
+
{
|
|
84
|
+
//times ? <View style={styles.verticalSeperator} /> : null
|
|
85
|
+
}
|
|
86
|
+
<View style={[styles.otherCourseContainer, { backgroundColor: 'rgba(0, 95, 80, 0)' }]}>
|
|
87
|
+
{
|
|
88
|
+
type || times
|
|
89
|
+
? <Text style={styles.type}>
|
|
90
|
+
{
|
|
91
|
+
type
|
|
92
|
+
? <Text style={{ fontWeight: 'bold' }}>
|
|
93
|
+
{type}
|
|
94
|
+
</Text>
|
|
95
|
+
: null
|
|
96
|
+
}
|
|
97
|
+
{
|
|
98
|
+
type && times
|
|
99
|
+
? ' | '
|
|
100
|
+
: null
|
|
101
|
+
}
|
|
102
|
+
{
|
|
103
|
+
times
|
|
104
|
+
? `${times?.start} - ${times?.end} `
|
|
105
|
+
: null
|
|
106
|
+
}
|
|
107
|
+
</Text>
|
|
108
|
+
: null
|
|
109
|
+
}
|
|
110
|
+
{title ? <Text style={styles.title}>{title}</Text> : null}
|
|
111
|
+
{
|
|
112
|
+
description
|
|
113
|
+
? <Text style={styles.professorText}>
|
|
114
|
+
<Text style={styles.professorName}>{description}</Text>
|
|
115
|
+
</Text>
|
|
116
|
+
: null
|
|
117
|
+
}
|
|
118
|
+
{
|
|
119
|
+
location
|
|
120
|
+
? <Pressable
|
|
121
|
+
onPress={
|
|
122
|
+
locationUrl
|
|
123
|
+
? () => Linking.openURL(locationUrl)
|
|
124
|
+
.catch(
|
|
125
|
+
reason => {
|
|
126
|
+
console.debug(componentName, ':', 'can`t open link', ':', reason);
|
|
127
|
+
alert('Link konnte nicht geöffnet werden.');
|
|
128
|
+
}
|
|
129
|
+
)
|
|
130
|
+
: null
|
|
131
|
+
}
|
|
132
|
+
>
|
|
133
|
+
<Text
|
|
134
|
+
style={[styles.location, locationUrl ? styles.locationLink : null]}
|
|
135
|
+
>
|
|
136
|
+
{location}
|
|
137
|
+
</Text>
|
|
138
|
+
</Pressable>
|
|
139
|
+
: null
|
|
140
|
+
}
|
|
141
|
+
</View>
|
|
142
|
+
{
|
|
143
|
+
starrable
|
|
144
|
+
? <View style={styles.starPosition}>
|
|
145
|
+
<TouchableOpacity onPress={handleSelectionChange}>
|
|
146
|
+
<IconsOpenasist icon={isSelected ? 'star-selected' : 'star'} size={25} color='#005F50' />
|
|
147
|
+
</TouchableOpacity>
|
|
148
|
+
</View>
|
|
149
|
+
: null
|
|
150
|
+
}
|
|
151
|
+
</View>
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const mapStateToProps = state => {
|
|
156
|
+
return {
|
|
157
|
+
pluginComponent: state.pluginReducer.timetable.component,
|
|
158
|
+
pluginStyles: state.pluginReducer.timetable.styles,
|
|
159
|
+
settings: state.settingReducer
|
|
160
|
+
};
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
export default connect(mapStateToProps, { onUpdateRefreshing })(withTranslation()(withTheme(TimetableEventComponent)))
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
export default function(theme) {
|
|
2
|
+
return {
|
|
3
|
+
card: {
|
|
4
|
+
marginLeft: theme.paddings.default,
|
|
5
|
+
marginRight: theme.paddings.default,
|
|
6
|
+
marginTop: 10,
|
|
7
|
+
marginBottom: 10,
|
|
8
|
+
backgroundColor: theme.colors.background,
|
|
9
|
+
paddingVertical: theme.paddings.small,
|
|
10
|
+
paddingHorizontal: theme.paddings.default,
|
|
11
|
+
flex: 1,
|
|
12
|
+
flexDirection: 'row',
|
|
13
|
+
shadowColor: theme.colors.shadow,
|
|
14
|
+
shadowOffset: {
|
|
15
|
+
width: 0,
|
|
16
|
+
height: 1,
|
|
17
|
+
},
|
|
18
|
+
shadowOpacity: 0.15,
|
|
19
|
+
shadowRadius: 0.32,
|
|
20
|
+
elevation: 3
|
|
21
|
+
},
|
|
22
|
+
courseCard: {
|
|
23
|
+
paddingLeft: 5,
|
|
24
|
+
},
|
|
25
|
+
verticalSeperator: {
|
|
26
|
+
height: "100%",
|
|
27
|
+
marginLeft: theme.paddings.small,
|
|
28
|
+
width: 1,
|
|
29
|
+
backgroundColor: theme.colors.listSeperator2,
|
|
30
|
+
},
|
|
31
|
+
verticalSeperatorSmall: {
|
|
32
|
+
height: "15%",
|
|
33
|
+
width: 1,
|
|
34
|
+
backgroundColor: theme.colors.listSeperator2,
|
|
35
|
+
|
|
36
|
+
},
|
|
37
|
+
courseTimeContainer: {
|
|
38
|
+
width:"15%",
|
|
39
|
+
alignItems: "center",
|
|
40
|
+
justifyContent: "center",
|
|
41
|
+
backgroundColor:theme.colors.background
|
|
42
|
+
},
|
|
43
|
+
courseTimeContainerBigFont: {
|
|
44
|
+
width: "25%",
|
|
45
|
+
},
|
|
46
|
+
timeText: {
|
|
47
|
+
fontSize: theme.fontSizes.subtitle,
|
|
48
|
+
paddingTop: theme.paddings.small,
|
|
49
|
+
paddingBottom: theme.paddings.small
|
|
50
|
+
},
|
|
51
|
+
timeTextBig: {
|
|
52
|
+
fontSize: theme.fontSizes.m
|
|
53
|
+
},
|
|
54
|
+
courseContainer: {
|
|
55
|
+
paddingLeft: theme.paddings.small,
|
|
56
|
+
width:"100%",
|
|
57
|
+
backgroundColor:theme.colors.background,
|
|
58
|
+
paddingTop: theme.paddings.xsmall,
|
|
59
|
+
paddingBottom: theme.paddings.xsmall
|
|
60
|
+
},
|
|
61
|
+
courseContainerBigFont: {
|
|
62
|
+
width: "75%",
|
|
63
|
+
},
|
|
64
|
+
type: {
|
|
65
|
+
fontSize: theme.fontSizes.l,
|
|
66
|
+
color: theme.colors.lecturerNameText
|
|
67
|
+
},
|
|
68
|
+
title: {
|
|
69
|
+
fontSize: theme.fontSizes.xl,
|
|
70
|
+
paddingTop: theme.paddings.xsmall,
|
|
71
|
+
},
|
|
72
|
+
titleBigFont: {
|
|
73
|
+
fontSize: theme.fontSizes.xl,
|
|
74
|
+
paddingTop: theme.paddings.xsmall,
|
|
75
|
+
},
|
|
76
|
+
location: {
|
|
77
|
+
fontSize: theme.fontSizes.subtitle,
|
|
78
|
+
paddingTop: theme.paddings.xsmall,
|
|
79
|
+
color: theme.colors.secondaryText,
|
|
80
|
+
},
|
|
81
|
+
locationLink: {
|
|
82
|
+
textDecorationLine: 'underline',
|
|
83
|
+
color: 'blue'
|
|
84
|
+
},
|
|
85
|
+
addLeftRightPadding: {
|
|
86
|
+
paddingLeft: theme.paddings.xsmall,
|
|
87
|
+
paddingRight: theme.paddings.xsmall,
|
|
88
|
+
},
|
|
89
|
+
professorText: {
|
|
90
|
+
fontSize: theme.fontSizes.m,
|
|
91
|
+
paddingTop: theme.paddings.xsmall,
|
|
92
|
+
color: theme.colors.subtitle
|
|
93
|
+
},
|
|
94
|
+
professorName: {
|
|
95
|
+
color: theme.colors.lecturerNameText
|
|
96
|
+
},
|
|
97
|
+
otherCourseContainer:{
|
|
98
|
+
padding: theme.paddings.xsmall,
|
|
99
|
+
width: "100%",
|
|
100
|
+
backgroundColor: theme.colors.background
|
|
101
|
+
},
|
|
102
|
+
starPosition:{
|
|
103
|
+
position: 'absolute',
|
|
104
|
+
top: 10,
|
|
105
|
+
right: 10,
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
};
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
* you may not use this file except in compliance with the License.
|
|
4
|
+
* You may obtain a copy of the License at
|
|
5
|
+
*
|
|
6
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
*
|
|
8
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
* See the License for the specific language governing permissions and
|
|
12
|
+
* limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import { useMemo } from 'react';
|
|
16
|
+
import {
|
|
17
|
+
StyleSheet,
|
|
18
|
+
View,
|
|
19
|
+
} from 'react-native';
|
|
20
|
+
|
|
21
|
+
import { connect } from 'react-redux'
|
|
22
|
+
import { useTheme, Text, Button } from "react-native-paper";
|
|
23
|
+
import { useTranslation } from "react-i18next";
|
|
24
|
+
|
|
25
|
+
import { onUpdateRefreshing } from "@olea-bps/core";
|
|
26
|
+
|
|
27
|
+
import IconsOpenasist from "@olea-bps/icons-openasist";
|
|
28
|
+
|
|
29
|
+
import componentStyles from "./styles";
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Timetable List Component
|
|
35
|
+
*
|
|
36
|
+
* Displays the list for timetable,
|
|
37
|
+
*
|
|
38
|
+
* Parameters:
|
|
39
|
+
* - none
|
|
40
|
+
*
|
|
41
|
+
* Navigation-Parameters:
|
|
42
|
+
* - none
|
|
43
|
+
*
|
|
44
|
+
* @param {object} props
|
|
45
|
+
* @param {(course: object) => void} [props.onCourseSelected]
|
|
46
|
+
*/
|
|
47
|
+
function TimetableListComponent({ course, times, settings, onCourseSelected }) {
|
|
48
|
+
const { t } = useTranslation();
|
|
49
|
+
const theme = useTheme();
|
|
50
|
+
const { colors, themeStyles, appSettings } = theme;
|
|
51
|
+
|
|
52
|
+
const accessibilityStartTime = t('accessibility:timetable:startTime') + times?.start.slice(0, 2) + ' ' + t('accessibility:pts:speechTime') + ' ' + (times?.start.slice(3, 5) !== '00' ? times?.start.slice(3, 5) : '') + ',';
|
|
53
|
+
const accessibilityEndTime = t('accessibility:timetable:endTime') + times?.end.slice(0, 2) + ' ' + t('accessibility:pts:speechTime') + ' ' + (times?.end.slice(3, 5) !== '00' ? times?.end.slice(3, 5) : '') + ',';
|
|
54
|
+
|
|
55
|
+
const isBigFont = settings.settingsAccessibility.increaseFontSize;
|
|
56
|
+
const showDetails = appSettings?.modules?.timetable?.showDetails;
|
|
57
|
+
|
|
58
|
+
const styles = useMemo(
|
|
59
|
+
() => StyleSheet.create(componentStyles(theme)),
|
|
60
|
+
[theme]
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
const renderTimeSlot = (
|
|
64
|
+
<View style={isBigFont ? [styles.courseTimeContainer, styles.courseTimeContainerBigFont] : styles.courseTimeContainer}>
|
|
65
|
+
<Text accessibilityLabel={accessibilityStartTime} style={isBigFont ? [styles.timeText, styles.timeTextBig] : styles.timeText}>{times?.start || ''}</Text>
|
|
66
|
+
<View style={styles.verticalSeperatorSmall} />
|
|
67
|
+
<Text accessibilityLabel={accessibilityEndTime} style={isBigFont ? [styles.timeText, styles.timeTextBig] : styles.timeText}>{times?.end || ''}</Text>
|
|
68
|
+
</View>
|
|
69
|
+
);
|
|
70
|
+
var renderVerticalSeperator = (
|
|
71
|
+
<View
|
|
72
|
+
style={styles.verticalSeperator}
|
|
73
|
+
/>
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
const { type, title, room, lecturer, info, url } = course;
|
|
77
|
+
|
|
78
|
+
const courseContainerBigFont = isBigFont ? styles.courseContainerBigFont : null;
|
|
79
|
+
const titleStyle = isBigFont ? styles.titleBigFont : styles.title;
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
|
|
84
|
+
<View style={isBigFont ? [themeStyles.card, styles.courseCard] : themeStyles.card}>
|
|
85
|
+
{times ? renderTimeSlot : null}
|
|
86
|
+
{times ? renderVerticalSeperator : null}
|
|
87
|
+
<View style={times ? [styles.courseContainer, courseContainerBigFont] : styles.otherCourseContainer}>
|
|
88
|
+
{(type && type.data) ? <Text style={times ? [styles.type, styles.addLeftRightPadding] : styles.type} >{type.data}</Text> : null}
|
|
89
|
+
{(title && title.data) ? <Text style={times ? [titleStyle, styles.addLeftRightPadding] : styles.title}>{title.data}</Text> : null}
|
|
90
|
+
{(room && room.data) ? <Text style={times ? [styles.room, styles.addLeftRightPadding] : styles.room} >{room.data}</Text> : null}
|
|
91
|
+
{(lecturer && lecturer[0] && lecturer[0].data) ?
|
|
92
|
+
<Text style={times ? [styles.professorText, styles.addLeftRightPadding] : styles.professorText}>
|
|
93
|
+
Tutor: <Text style={styles.professorName}>{lecturer.map(lecturer => lecturer.data).join(',') || ''}</Text>
|
|
94
|
+
</Text> : null
|
|
95
|
+
}
|
|
96
|
+
</View>
|
|
97
|
+
{showDetails && (room?.data || info?.data || url?.data) ?
|
|
98
|
+
<View style={styles.btnPosition}>
|
|
99
|
+
<Button style={styles.btnAddionals} onPress={() => onCourseSelected?.(course)}>
|
|
100
|
+
<IconsOpenasist icon={"info"} color={colors.secondaryText} size={22} />
|
|
101
|
+
</Button>
|
|
102
|
+
</View>
|
|
103
|
+
: null}
|
|
104
|
+
</View>
|
|
105
|
+
);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const mapStateTo = state => {
|
|
109
|
+
return {
|
|
110
|
+
pluginComponent: state.pluginReducer.timetable.component,
|
|
111
|
+
pluginStyles: state.pluginReducer.timetable.styles,
|
|
112
|
+
settings: state.settingReducer
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
export default connect(mapStateTo, { onUpdateRefreshing })(TimetableListComponent)
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
export default function (theme) {
|
|
2
|
+
return {
|
|
3
|
+
courseCard: {
|
|
4
|
+
paddingLeft: 5,
|
|
5
|
+
},
|
|
6
|
+
verticalSeperator: {
|
|
7
|
+
height: "100%",
|
|
8
|
+
marginLeft: theme.paddings.small,
|
|
9
|
+
width: 1,
|
|
10
|
+
backgroundColor: theme.colors.listSeperator
|
|
11
|
+
},
|
|
12
|
+
verticalSeperatorSmall: {
|
|
13
|
+
height: "15%",
|
|
14
|
+
width: 1,
|
|
15
|
+
backgroundColor: theme.colors.listSeperator,
|
|
16
|
+
|
|
17
|
+
},
|
|
18
|
+
courseTimeContainer: {
|
|
19
|
+
width: "15%",
|
|
20
|
+
alignItems: "center",
|
|
21
|
+
justifyContent: "center",
|
|
22
|
+
backgroundColor: theme.colors.background
|
|
23
|
+
},
|
|
24
|
+
courseTimeContainerBigFont: {
|
|
25
|
+
width: "25%",
|
|
26
|
+
},
|
|
27
|
+
timeText: {
|
|
28
|
+
fontSize: theme.fontSizes.subtitle,
|
|
29
|
+
paddingTop: theme.paddings.small,
|
|
30
|
+
paddingBottom: theme.paddings.small
|
|
31
|
+
},
|
|
32
|
+
timeTextBig: {
|
|
33
|
+
fontSize: theme.fontSizes.m
|
|
34
|
+
},
|
|
35
|
+
courseContainer: {
|
|
36
|
+
flex: 1,
|
|
37
|
+
flexDirection: "column",
|
|
38
|
+
paddingLeft: theme.paddings.small,
|
|
39
|
+
width: "85%",
|
|
40
|
+
backgroundColor: theme.colors.background,
|
|
41
|
+
paddingTop: theme.paddings.xsmall,
|
|
42
|
+
paddingBottom: theme.paddings.xsmall
|
|
43
|
+
},
|
|
44
|
+
courseContainerBigFont: {
|
|
45
|
+
width: "75%",
|
|
46
|
+
},
|
|
47
|
+
type: {
|
|
48
|
+
fontSize: theme.fontSizes.subtitle,
|
|
49
|
+
color: theme.colors.subtitle
|
|
50
|
+
},
|
|
51
|
+
title: {
|
|
52
|
+
fontSize: theme.fontSizes.xl,
|
|
53
|
+
paddingTop: theme.paddings.xsmall,
|
|
54
|
+
},
|
|
55
|
+
titleBigFont: {
|
|
56
|
+
fontSize: theme.fontSizes.xl,
|
|
57
|
+
paddingTop: theme.paddings.xsmall,
|
|
58
|
+
},
|
|
59
|
+
room: {
|
|
60
|
+
fontSize: theme.fontSizes.l,
|
|
61
|
+
paddingTop: theme.paddings.xsmall,
|
|
62
|
+
fontWeight: "bold",
|
|
63
|
+
},
|
|
64
|
+
addLeftRightPadding: {
|
|
65
|
+
paddingLeft: theme.paddings.xsmall,
|
|
66
|
+
paddingRight: theme.paddings.xsmall,
|
|
67
|
+
},
|
|
68
|
+
professorText: {
|
|
69
|
+
fontSize: theme.fontSizes.l,
|
|
70
|
+
paddingTop: theme.paddings.xsmall,
|
|
71
|
+
color: theme.colors.subtitle
|
|
72
|
+
},
|
|
73
|
+
professorName: {
|
|
74
|
+
color: theme.colors.lecturerNameText
|
|
75
|
+
},
|
|
76
|
+
otherCourseContainer: {
|
|
77
|
+
padding: theme.paddings.xsmall,
|
|
78
|
+
width: "100%",
|
|
79
|
+
backgroundColor: theme.colors.background
|
|
80
|
+
},
|
|
81
|
+
btnPosition: {
|
|
82
|
+
position: 'absolute',
|
|
83
|
+
bottom: 7,
|
|
84
|
+
right: 7
|
|
85
|
+
},
|
|
86
|
+
textDetail: {
|
|
87
|
+
fontSize: theme.fontSizes.l,
|
|
88
|
+
paddingTop: theme.paddings.small,
|
|
89
|
+
},
|
|
90
|
+
textDetailBigFont: {
|
|
91
|
+
fontSize: theme.fontSizes.xl,
|
|
92
|
+
paddingTop: theme.paddings.small,
|
|
93
|
+
},
|
|
94
|
+
indentedText: {
|
|
95
|
+
marginLeft: 10,
|
|
96
|
+
},
|
|
97
|
+
detailContainer: {
|
|
98
|
+
flexDirection: 'row',
|
|
99
|
+
alignItems: 'center',
|
|
100
|
+
},
|
|
101
|
+
detailLabel: {
|
|
102
|
+
width: '25%',
|
|
103
|
+
},
|
|
104
|
+
detailValue: {
|
|
105
|
+
flexShrink: 1,
|
|
106
|
+
width: '70%',
|
|
107
|
+
},
|
|
108
|
+
}
|
|
109
|
+
};
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
3
|
+
* you may not use this file except in compliance with the License.
|
|
4
|
+
* You may obtain a copy of the License at
|
|
5
|
+
*
|
|
6
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7
|
+
*
|
|
8
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
9
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
10
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
11
|
+
* See the License for the specific language governing permissions and
|
|
12
|
+
* limitations under the License.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import React, { useState, useMemo, useEffect, useRef, useCallback } from 'react';
|
|
16
|
+
import { Text, TouchableOpacity, StyleSheet, View } from 'react-native';
|
|
17
|
+
import { connect } from 'react-redux';
|
|
18
|
+
import { withTheme } from 'react-native-paper';
|
|
19
|
+
import { withTranslation } from 'react-i18next';
|
|
20
|
+
import { onUpdateRefreshing } from '@olea-bps/core';
|
|
21
|
+
import componentStyles from "./styles";
|
|
22
|
+
import { Calendar } from 'react-native-big-calendar';
|
|
23
|
+
import { useCourses } from '@olea-bps/context-timetable';
|
|
24
|
+
import CourseDetailDialog from '../component-course-detail-dialog';
|
|
25
|
+
import CalendarStrip from 'react-native-calendar-strip';
|
|
26
|
+
import { DateTime } from 'luxon';
|
|
27
|
+
|
|
28
|
+
function CalendarMonth(props) {
|
|
29
|
+
const { theme, setMonth, today, locale, onMonthChanged } = props;
|
|
30
|
+
const styles = useMemo(
|
|
31
|
+
() => StyleSheet.create(componentStyles(theme)),
|
|
32
|
+
[theme]
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
const [courses, refreshCourses] = useCourses();
|
|
36
|
+
const selectedDate = useRef(new Date());
|
|
37
|
+
const [selectedDateState, setSelectedDateState] = useState(selectedDate.current);
|
|
38
|
+
const [dialogVisible, setDialogVisible] = useState(false);
|
|
39
|
+
const [selectedEvent, setSelectedEvent] = useState(null);
|
|
40
|
+
|
|
41
|
+
const selectedDateStartISO = DateTime.fromISO(JSON.stringify(selectedDate.current).slice(1, -1)).startOf('month').toISODate();
|
|
42
|
+
const selectedDateEndISO = DateTime.fromISO(JSON.stringify(selectedDate.current).slice(1, -1)).endOf('month').toISODate();
|
|
43
|
+
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
refreshCourses(selectedDateStartISO, selectedDateEndISO);
|
|
46
|
+
}, [selectedDateStartISO, selectedDateEndISO]);
|
|
47
|
+
|
|
48
|
+
const handleDateChange = (date) => {
|
|
49
|
+
selectedDate.current = date;
|
|
50
|
+
setSelectedDateState(date);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const monthCourses = useMemo(() => {
|
|
54
|
+
const startDate = DateTime.fromISO(selectedDateStartISO);
|
|
55
|
+
const daysInMonth = startDate.daysInMonth;
|
|
56
|
+
const daysArray = Array.from({ length: daysInMonth }, (_, index) => startDate.plus({ days: index }).toISODate());
|
|
57
|
+
return daysArray.reduce((acc, date) => acc.concat(courses?.[date] ?? []), []);
|
|
58
|
+
}, [selectedDateStartISO, courses]);
|
|
59
|
+
|
|
60
|
+
const monthEvents = useMemo(() => {
|
|
61
|
+
try {
|
|
62
|
+
return monthCourses
|
|
63
|
+
.map(course => {
|
|
64
|
+
return {
|
|
65
|
+
title: course.title.data,
|
|
66
|
+
start: course.startDateTime,
|
|
67
|
+
end: course.endDateTime,
|
|
68
|
+
color: '#a3f2c5',
|
|
69
|
+
type: course.type?.data,
|
|
70
|
+
professor: course.lecturer[0]?.data,
|
|
71
|
+
room: course.room.data
|
|
72
|
+
};
|
|
73
|
+
});
|
|
74
|
+
} catch (error) {
|
|
75
|
+
console.error('Error in useMemo for monthEvents:', error);
|
|
76
|
+
return [];
|
|
77
|
+
}
|
|
78
|
+
}, [monthCourses]);
|
|
79
|
+
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
handleDateChange(today);
|
|
82
|
+
setMonth(today.getMonth());
|
|
83
|
+
}, [today, setMonth]);
|
|
84
|
+
|
|
85
|
+
const renderEvent = useCallback((event, touchableOpacityProps) => {
|
|
86
|
+
const { style, ...restTouchableOpacityProps } = touchableOpacityProps;
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<TouchableOpacity {...restTouchableOpacityProps}
|
|
90
|
+
style={[style, styles.event]}
|
|
91
|
+
>
|
|
92
|
+
<Text style={styles.eventTitle} numberOfLines={1}>
|
|
93
|
+
{event.title}
|
|
94
|
+
</Text>
|
|
95
|
+
</TouchableOpacity>
|
|
96
|
+
);
|
|
97
|
+
}, [styles]);
|
|
98
|
+
|
|
99
|
+
const renderHeader = useCallback(() => (
|
|
100
|
+
<View pointerEvents="none">
|
|
101
|
+
<CalendarStrip
|
|
102
|
+
style={styles.strip}
|
|
103
|
+
locale={locale}
|
|
104
|
+
selectedDate={today}
|
|
105
|
+
showDayNumber={false}
|
|
106
|
+
dateNameStyle={{ fontWeight: 'bold', fontSize: 14 }}
|
|
107
|
+
highlightDateNameStyle={{ fontWeight: 'bold', fontSize: 14 }}
|
|
108
|
+
highlightDateContainerStyle={styles.highlightDateContainer}
|
|
109
|
+
iconStyle={{ display: 'none' }}
|
|
110
|
+
showMonth={false}
|
|
111
|
+
startingDate={selectedDate.current}
|
|
112
|
+
/>
|
|
113
|
+
|
|
114
|
+
</View>
|
|
115
|
+
), [selectedDate]);
|
|
116
|
+
|
|
117
|
+
return (
|
|
118
|
+
<>
|
|
119
|
+
<Calendar
|
|
120
|
+
events={monthEvents}
|
|
121
|
+
renderEvent={renderEvent}
|
|
122
|
+
renderHeaderForMonthView={renderHeader}
|
|
123
|
+
date={selectedDate.current}
|
|
124
|
+
height={800}
|
|
125
|
+
mode={'month'}
|
|
126
|
+
headerContentStyle={{ backgroundColor: 'transparent' }}
|
|
127
|
+
weekStartsOn={1}
|
|
128
|
+
onSwipeEnd={(date) => {
|
|
129
|
+
handleDateChange(date);
|
|
130
|
+
setMonth(new Date(date).getMonth());
|
|
131
|
+
}}
|
|
132
|
+
onPressEvent={(event) => {
|
|
133
|
+
setDialogVisible(true);
|
|
134
|
+
setSelectedEvent(event);
|
|
135
|
+
}}
|
|
136
|
+
/>
|
|
137
|
+
{dialogVisible && selectedEvent && (
|
|
138
|
+
<CourseDetailDialog
|
|
139
|
+
visible={dialogVisible}
|
|
140
|
+
hideDialog={() => setDialogVisible(false)}
|
|
141
|
+
course={selectedEvent}
|
|
142
|
+
styles={styles}
|
|
143
|
+
{...props}
|
|
144
|
+
/>
|
|
145
|
+
)}
|
|
146
|
+
</>
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const mapStateToProps = (state) => {
|
|
151
|
+
return {
|
|
152
|
+
settings: state.settingReducer,
|
|
153
|
+
};
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
export default connect(mapStateToProps, { onUpdateRefreshing })(withTranslation()(withTheme(CalendarMonth)));
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export default function (theme) {
|
|
2
|
+
return {
|
|
3
|
+
event: {
|
|
4
|
+
padding: 4,
|
|
5
|
+
borderRadius: 4,
|
|
6
|
+
backgroundColor: '#a3f2c5',
|
|
7
|
+
margin: 2,
|
|
8
|
+
overflow: 'hidden',
|
|
9
|
+
},
|
|
10
|
+
eventTitle: {
|
|
11
|
+
color: '#000000',
|
|
12
|
+
fontSize: 12,
|
|
13
|
+
},
|
|
14
|
+
strip: {
|
|
15
|
+
height: 65,
|
|
16
|
+
paddingTop: 5,
|
|
17
|
+
paddingBottom: 5,
|
|
18
|
+
backgroundColor: '#fff',
|
|
19
|
+
elevation: 4,
|
|
20
|
+
},
|
|
21
|
+
highlightDateContainer: {
|
|
22
|
+
borderRadius: 100,
|
|
23
|
+
borderWidth: 3,
|
|
24
|
+
borderColor: 'red',
|
|
25
|
+
height: 48,
|
|
26
|
+
width: 48,
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|