@olea-bps/views 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.
Files changed (52) hide show
  1. package/Callmanager/index.js +148 -0
  2. package/Callmanager/styles.js +62 -0
  3. package/Canteens/index.js +383 -0
  4. package/Canteens/styles.js +89 -0
  5. package/Dashboard/index.js +176 -0
  6. package/Dashboard/styles.js +16 -0
  7. package/DashboardHtwk/index.js +197 -0
  8. package/DashboardHtwk/styles.js +24 -0
  9. package/Event/index.js +369 -0
  10. package/Event/styles.js +63 -0
  11. package/FeedList/index.js +165 -0
  12. package/FeedList/styles.js +15 -0
  13. package/FeedNews/index.js +243 -0
  14. package/FeedNews/styles.js +32 -0
  15. package/Flexmenu/index.js +185 -0
  16. package/Flexmenu/styles.js +62 -0
  17. package/FlexmenuWebview/index.js +167 -0
  18. package/FlexmenuWebview/styles.js +16 -0
  19. package/Howhy/index.js +151 -0
  20. package/Howhy/styles.js +11 -0
  21. package/Jobs/index.js +217 -0
  22. package/Jobs/styles.js +41 -0
  23. package/MainMenu/index.js +329 -0
  24. package/MainMenu/styles.js +36 -0
  25. package/NewsTabbar/index.js +164 -0
  26. package/NewsTabbar/styles.js +27 -0
  27. package/Opal/index.js +136 -0
  28. package/Opal/styles.js +11 -0
  29. package/PublicTransportTicket/index.js +173 -0
  30. package/PublicTransportTicket/styles.js +17 -0
  31. package/Search/index.js +186 -0
  32. package/Search/styles.js +67 -0
  33. package/SettingsAccessibility/index.js +148 -0
  34. package/SettingsAccessibility/styles.js +13 -0
  35. package/SettingsAppInfo/index.js +86 -0
  36. package/SettingsAppInfo/styles.js +18 -0
  37. package/SettingsCanteens/index.js +249 -0
  38. package/SettingsCanteens/styles.js +33 -0
  39. package/SettingsGeneral/index.js +173 -0
  40. package/SettingsGeneral/styles.js +28 -0
  41. package/SettingsNotifications/index.js +204 -0
  42. package/SettingsNotifications/styles.js +38 -0
  43. package/SettingsUser/index.js +170 -0
  44. package/SettingsUser/styles.js +17 -0
  45. package/TimetableCalendar/index.js +322 -0
  46. package/TimetableCalendar/styles.js +117 -0
  47. package/TimetableList/index.js +397 -0
  48. package/TimetableList/styles.js +55 -0
  49. package/Webviews/index.js +158 -0
  50. package/Webviews/styles.js +11 -0
  51. package/index.js +25 -0
  52. package/package.json +41 -0
@@ -0,0 +1,16 @@
1
+ export default function(theme) {
2
+ return {
3
+ container: {
4
+ flex: 1,
5
+ backgroundColor: theme.colors.background,
6
+ },
7
+ contentContainer: {
8
+ paddingTop: 0
9
+ },
10
+ titleStyle: {
11
+ ...theme.fonts.medium,
12
+ fontSize: theme.fontSizes.xxl,
13
+ alignSelf: "center"
14
+ }
15
+ }
16
+ };
package/Howhy/index.js ADDED
@@ -0,0 +1,151 @@
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 from 'react';
16
+ import { SafeAreaView, StyleSheet, ActivityIndicator, View, Platform } from 'react-native';
17
+ import {Appbar, withTheme} from "react-native-paper";
18
+ import { WebView } from 'react-native-webview';
19
+ import {withTranslation} from "react-i18next";
20
+ import merge from 'lodash/merge';
21
+
22
+ import componentStyles from "./styles";
23
+ import { AppBar as AppbarComponent } from '@olea-bps/components';
24
+ import IconsOpenasist from "@olea-bps/icons-openasist";
25
+
26
+ /**
27
+ * Howy View
28
+ *
29
+ * Shows the howy site in a webview
30
+ *
31
+ * Parameters:
32
+ * - none
33
+ *
34
+ * Navigation-Parameters:
35
+ * - none
36
+ */
37
+ class HowyView extends React.Component {
38
+ static navigationOptions = {
39
+ header: null
40
+ };
41
+
42
+
43
+ state = {
44
+ refreshing: false,
45
+ };
46
+
47
+ // Styles of this component
48
+ styles;
49
+
50
+ webView = {
51
+ canGoBack: false,
52
+ ref: null,
53
+ };
54
+
55
+ constructor(props) {
56
+ super(props);
57
+
58
+ // ------------------------------------------------------------------------
59
+ // PLUGIN FUNCTIONALITY
60
+ // ------------------------------------------------------------------------
61
+
62
+ const {pluginStyles, theme} = this.props;
63
+ this.styles = componentStyles(theme);
64
+
65
+ if (pluginStyles) {
66
+ this.styles = merge(this.styles, pluginStyles);
67
+ }
68
+
69
+ this.styles = StyleSheet.create(this.styles);
70
+
71
+ // ------------------------------------------------------------------------
72
+ }
73
+
74
+
75
+ render() {
76
+ // ------------------------------------------------------------------------
77
+ // PLUGIN FUNCTIONALITY
78
+ // ------------------------------------------------------------------------
79
+ const PluginComponent = this.props.pluginComponent;
80
+ if (PluginComponent) {
81
+ return <PluginComponent />;
82
+ }
83
+ // ------------------------------------------------------------------------
84
+
85
+ const {theme:{colors, themeStyles, customScript}, t } = this.props;
86
+ /**
87
+ * Webview Note:
88
+ * - Android only - Use allowsFullscreenVideo={true} to allow fullscreen video via icon in video player
89
+ * - iOS only - Use allowsInlineMediaPlayback={true} to allow inline video and prevent fullscreen autoplay at start
90
+ */
91
+ return (
92
+ <SafeAreaView style={[this.styles.container, themeStyles.appSafeAreaContainer]}>
93
+ <View style={{zIndex: 100, position: 'relative'}}>
94
+ <AppbarComponent {...this.props}
95
+ title={t('howhy:title')}
96
+ leftAction={
97
+ <Appbar.Action
98
+ icon={props => <IconsOpenasist {...props} icon={'back'} color={colors.primaryText} /> }
99
+ onPress={() => {
100
+ if (this.webView.canGoBack) {
101
+ this.webView.ref.goBack();
102
+ } else {
103
+ this.props.navigation.goBack(null);
104
+ }
105
+ }}
106
+ accessible={true}
107
+ accessibilityLabel={(this.webView.canGoBack) ? t('accessibility:appbar.navigateBack') : t('accessibility:appbar.back')}
108
+ />
109
+ }
110
+ rightAction={
111
+ <Appbar.Action
112
+ icon="refresh"
113
+ onPress={() => this.webView.ref.reload()}
114
+ accessible={true}
115
+ accessibilityLabel={t('accessibility:appbar.reload')}
116
+ />
117
+ }/>
118
+ </View>
119
+ <WebView
120
+ ref={ref => this.webView.ref = ref}
121
+ source={{uri: t('howhy:url')}}
122
+ startInLoadingState={true}
123
+ allowsFullscreenVideo={true}
124
+ allowsInlineMediaPlayback={true}
125
+ setSupportMultipleWindows={false}
126
+ injectedJavaScript={customScript}
127
+ renderLoading={() => <ActivityIndicator style={this.styles.activity} size="large" color={colors.loadingIndicator} />}
128
+ onNavigationStateChange={(navState) => {
129
+ if(Platform.OS !== 'android') {
130
+ this.webView.canGoBack = navState.canGoBack; /* iOS only */
131
+ }
132
+ }}
133
+ onLoadProgress={({nativeEvent}) => {
134
+ if(Platform.OS === 'android') {
135
+ this.webView.canGoBack = nativeEvent.canGoBack; /* Android only */
136
+ }
137
+ }}
138
+ onContentProcessDidTerminate={(syntheticEvent) => {
139
+ // this should prevent white screen issues on ios
140
+ const { nativeEvent } = syntheticEvent;
141
+ console.warn('Content process terminated, reloading', nativeEvent);
142
+ this.refs.webview.reload();
143
+ }}
144
+ />
145
+ </SafeAreaView>
146
+ );
147
+ }
148
+ }
149
+
150
+
151
+ export default (withTranslation()(withTheme(HowyView)))
@@ -0,0 +1,11 @@
1
+ export default function(theme) {
2
+ return {
3
+ container: {
4
+ flex: 1,
5
+ backgroundColor: theme.colors.background,
6
+ },
7
+ activity: {
8
+ padding: 20
9
+ }
10
+ }
11
+ };
package/Jobs/index.js ADDED
@@ -0,0 +1,217 @@
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, useEffect, useMemo, useCallback } from 'react';
16
+ import {
17
+ FlatList,
18
+ Text,
19
+ SafeAreaView,
20
+ TouchableOpacity,
21
+ Linking,
22
+ StyleSheet,
23
+ View,
24
+ ActivityIndicator,
25
+ } from 'react-native';
26
+
27
+ import { Appbar, Button, useTheme } from 'react-native-paper';
28
+ import { useTranslation } from 'react-i18next';
29
+ import { useNavigation, useRoute } from '@react-navigation/native';
30
+
31
+ import { DateTime } from 'luxon';
32
+
33
+ import { AppBar as AppbarComponent } from '@olea-bps/components';
34
+ import IconsOpenasist from '@olea-bps/icons-openasist';
35
+ import { useLanguage, useStagingServer } from '@olea-bps/core';
36
+
37
+ import componentStyles from './styles';
38
+
39
+ /**
40
+ * Job Portal View
41
+ *
42
+ * Shows the Job Portal
43
+ *
44
+ * Parameters:
45
+ * - none
46
+ *
47
+ * Navigation-Parameters:
48
+ * - none
49
+ */
50
+ export default function JobPortalView(props) {
51
+ const navigation = useNavigation();
52
+ const route = useRoute();
53
+ const selectedCategorieIds = route?.params?.selectedIds ?? [];
54
+ const checked = route?.params?.checked ?? [];
55
+ const theme = useTheme();
56
+ const { colors, themeStyles } = theme;
57
+ const { t } = useTranslation();
58
+ const language = useLanguage();
59
+ const isStagingServerActive = useStagingServer();
60
+ const apiUrl = isStagingServerActive
61
+ ? theme.appSettings?.modules?.job?.api?.staging?.url
62
+ : theme.appSettings?.modules?.job?.api?.production?.url;
63
+
64
+ const [jobs, setJobs] = useState([]);
65
+ const [categories, setCategories] = useState(null);
66
+ const [jobsRequestInProgress, setJobsRequestInProgress] = useState(false);
67
+ const [categoriesRequestInProgress, setCategoriesRequestInProgress] = useState(false);
68
+
69
+ const styles = useMemo(
70
+ () => StyleSheet.create(componentStyles(theme)),
71
+ [theme, componentStyles]
72
+ )
73
+
74
+ const refreshJobs = useCallback(
75
+ () => {
76
+ const getJobsUrl = new URL('jobs/', apiUrl);
77
+
78
+ setJobsRequestInProgress(true);
79
+
80
+ fetch(getJobsUrl)
81
+ .then(response => response.json())
82
+ .then(setJobs)
83
+ .finally(() => setJobsRequestInProgress(false));
84
+ },
85
+ [apiUrl, setJobs, setJobsRequestInProgress]
86
+ )
87
+
88
+ const refreshCategories = useCallback(
89
+ () => {
90
+ const getJobsUrl = new URL('jobs/categories/', apiUrl);
91
+
92
+ setCategoriesRequestInProgress(true);
93
+
94
+ fetch(getJobsUrl)
95
+ .then(response => response.json())
96
+ .then(setCategories)
97
+ .finally(() => setCategoriesRequestInProgress(false));
98
+ },
99
+ [apiUrl, setCategories, setCategoriesRequestInProgress]
100
+ )
101
+
102
+
103
+ useEffect(
104
+ refreshJobs,
105
+ [refreshJobs]
106
+ )
107
+
108
+ useEffect(
109
+ refreshCategories,
110
+ [refreshCategories]
111
+ )
112
+
113
+ const filteredJobs = useMemo(
114
+ () => {
115
+ if (Array.isArray(jobs) && jobs.length > 0) {
116
+ if (Array.isArray(selectedCategorieIds) && selectedCategorieIds.length > 0)
117
+ return jobs.filter(job => selectedCategorieIds.includes(job.catID));
118
+ else {
119
+ return jobs;
120
+ }
121
+ } else {
122
+ return null;
123
+ }
124
+ },
125
+ [jobs, selectedCategorieIds]
126
+ )
127
+
128
+ return (
129
+ <SafeAreaView style={[styles.container, themeStyles.appSafeAreaContainer]}>
130
+ <View>
131
+ <AppbarComponent {...props}
132
+ title={t('menu:titles.job')}
133
+ leftAction={
134
+ <Appbar.Action
135
+ icon={props => <IconsOpenasist {...props} icon={'back'} color={colors.primaryText} />}
136
+ onPress={
137
+ () => navigation.goBack(null)
138
+ }
139
+ />
140
+ }
141
+ rightAction={
142
+ <Appbar.Action icon="filter" onPress={
143
+ () =>
144
+ navigation.navigate(
145
+ 'JobFilter',
146
+ {
147
+ checked: checked,
148
+ selectedIds: selectedCategorieIds,
149
+ catData: categories,
150
+ }
151
+ )
152
+ } />
153
+ } />
154
+ </View>
155
+ <View style={themeStyles.container}>
156
+ {
157
+ filteredJobs?.length
158
+ ? <FlatList
159
+ data={filteredJobs}
160
+ initialNumToRender={6}
161
+ keyExtractor={
162
+ (item, index) => item?.url ?? 'job_' + index
163
+ }
164
+ refreshing={jobsRequestInProgress || categoriesRequestInProgress}
165
+ onRefresh={
166
+ () => {
167
+ refreshCategories();
168
+ refreshJobs();
169
+ }
170
+ }
171
+ renderItem={
172
+ ({ item }) =>
173
+ <TouchableOpacity
174
+ style={themeStyles.card}
175
+ onPress={() => { Linking.openURL(item.url) }}
176
+ accessible={true}
177
+ accessibilityLabel={t(item.company ? 'accessibility:jobs.descriptionWithCompany' : 'accessibility:jobs.descriptionWithoutCompany', item)
178
+ }
179
+ >
180
+ <View style={[themeStyles.cardContent]}>
181
+ <Text style={[styles.title, themeStyles.cardTitle]}>
182
+ {item.title}
183
+ </Text>
184
+ <Text style={[themeStyles.cardSubTitle, styles.companyCity]}>
185
+ {item.company ? item.company + " - " : null}{item.place}
186
+ </Text>
187
+ <Text style={[themeStyles.cardSubTitle, styles.date]}>
188
+ {item.category} - {DateTime.fromISO(item.dateFrom).setLocale(language).toLocaleString()}
189
+ </Text>
190
+ </View>
191
+ </TouchableOpacity>
192
+ }
193
+ />
194
+ : jobsRequestInProgress || categoriesRequestInProgress
195
+ ? <View style={styles.innerContainer}>
196
+ <ActivityIndicator style={styles.activity} size="large" color={colors.loadingIndicator} />
197
+ </View>
198
+ : <View style={[styles.containerInner, styles.containerErrorMsg]}>
199
+ <Text style={styles.titleNoJobs}>{t('jobs:noJobsTitle')}</Text>
200
+ <Button
201
+ onPress={
202
+ () => {
203
+ refreshJobs();
204
+ refreshCategories();
205
+ }
206
+ }
207
+ color={colors.buttonText}
208
+ mode={'outlined'}
209
+ >
210
+ {t('common:reload')}
211
+ </Button>
212
+ </View>
213
+ }
214
+ </View>
215
+ </SafeAreaView>
216
+ );
217
+ }
package/Jobs/styles.js ADDED
@@ -0,0 +1,41 @@
1
+ export default function(theme) {
2
+ return {
3
+ container: {
4
+ flex: 1,
5
+ backgroundColor: theme.colors.background,
6
+ },
7
+ title:{
8
+ fontSize: theme.fontSizes.xxl,
9
+ color: theme.colors.jobsTitleColor
10
+ },
11
+ titleNoJobs:{
12
+ fontSize: theme.fontSizes.xxl,
13
+ color: theme.colors.jobsTitleColor,
14
+ textAlign: 'center',
15
+ marginBottom: theme.paddings.default
16
+ },
17
+ companyCity:{
18
+ fontSize: theme.fontSizes.s,
19
+ paddingTop: theme.paddings.xsmall,
20
+ color: theme.colors.secondaryText
21
+ },
22
+ date:{
23
+ fontSize: theme.fontSizes.s,
24
+ paddingTop: theme.paddings.xsmall
25
+ },
26
+ activity: {
27
+ padding: 20
28
+ },
29
+ innerContainer: {
30
+ padding: 40,
31
+ marginTop: 200
32
+ },
33
+ containerErrorMsg: {
34
+ flex: 1,
35
+ justifyContent: 'center',
36
+ alignContent: 'center',
37
+ alignItems: 'center',
38
+ margin: theme.paddings.default,
39
+ },
40
+ }
41
+ };