@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,148 @@
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
+ SafeAreaView,
18
+ StyleSheet,
19
+ View,
20
+ Switch,
21
+ Alert,
22
+ RefreshControl,
23
+ } from 'react-native';
24
+
25
+ import { connect } from 'react-redux'
26
+ import { useTheme, Text, Button } from 'react-native-paper';
27
+ import { useTranslation } from 'react-i18next';
28
+
29
+ import { useParallelCalls } from '@olea-bps/context-callmanager';
30
+ import { useUser } from '@olea-bps/context-user';
31
+ import { AppBar as AppbarComponent } from '@olea-bps/components';
32
+
33
+ import componentStyles from './styles';
34
+
35
+ export default function CallManagerView(props) {
36
+ const componentName = CallManagerView.name;
37
+ const theme = useTheme();
38
+ const themeStyles = theme?.themeStyles;
39
+
40
+ const { t } = useTranslation();
41
+
42
+
43
+ const styles = useMemo(
44
+ () => StyleSheet.create(componentStyles(theme)),
45
+ [theme]
46
+ )
47
+
48
+ const [user, login, logout] = useUser();
49
+ const [parallelCalls, refreshParallelCalls, changeParallelCall] = useParallelCalls();
50
+
51
+ const [remoteDestinationProfilesRefreshing, setRemoteDestinationProfilesRefreshing] = useState(false);
52
+
53
+ return (
54
+ <SafeAreaView style={themeStyles.appSafeAreaContainer}>
55
+ <AppbarComponent {...props}
56
+ title={t('menu:titles.callmanager')}
57
+ />
58
+ <View style={themeStyles.container}>
59
+ {
60
+ // Wenn ein Nutzer in der App angemeldet ist, werden dessen Parralelrufe angezeigt. Ansonsten wird der Nutzer zum Loggin aufgefordert.
61
+ user
62
+ ? <RefreshControl
63
+ refreshing={remoteDestinationProfilesRefreshing}
64
+ onRefresh={() => {
65
+ setRemoteDestinationProfilesRefreshing(true);
66
+ refreshParallelCalls()
67
+ .finally(() => setRemoteDestinationProfilesRefreshing(false));
68
+ }}
69
+ >
70
+ <Text>
71
+ {t('callmanager:userInfo', { userName: user.name, userPhoneNumber: user.phone_number })}
72
+ </Text>
73
+ {
74
+ parallelCalls?.map?.(
75
+ parallelCall => {
76
+ const isActive = parallelCall?.enableMobileConnect;
77
+
78
+ return (
79
+ <View
80
+ key={parallelCall?.destination}
81
+ >
82
+ <Text>
83
+ {parallelCall?.destination ?? t('callmanager:numberNotDisplayable')}
84
+ </Text>
85
+ <Switch
86
+ value={isActive}
87
+ onValueChange={
88
+ value =>
89
+ changeParallelCall(parallelCall?.destination, { enableMobileConnect: value })
90
+ .then(() => refreshParallelCalls())
91
+ }
92
+ />
93
+ </View >
94
+ )
95
+ }
96
+ )
97
+ }
98
+ <Button
99
+ onPress={() => Alert.alert(
100
+ t('callmanager:logout'),
101
+ t('callmanager:logoutConfirmation'),
102
+ [
103
+ {
104
+ text: t('callmanager:logoutOkButton'),
105
+ onPress: () => logout?.(),
106
+ },
107
+ {
108
+ text: t('callmanager:logoutNoButton'),
109
+ isPreferred: true,
110
+ }
111
+ ]
112
+ )}
113
+ >
114
+ {t('callmanager:logout')}
115
+ </Button>
116
+ </RefreshControl>
117
+ : <>
118
+ <Text>
119
+ {t('callmanager:notLoggedIn')}
120
+ </Text>
121
+ <Button
122
+ onPress={
123
+ () =>
124
+ login
125
+ ? login()
126
+ .catch(
127
+ reason => {
128
+ Alert.alert(
129
+ t('callmanager:loginFailed'),
130
+ t('callmanager:tryLoginAgain'),
131
+ );
132
+ console.debug(componentName, ':', 'login failed', ':', reason);
133
+ }
134
+ )
135
+ : Alert.alert(
136
+ t('callmanager:connectionError'),
137
+ t('callmanager:connectionErrorTryLoginAgain'),
138
+ )
139
+ }
140
+ >
141
+ {t('callmanager:logginButton')}
142
+ </Button>
143
+ </>
144
+ }
145
+ </View>
146
+ </SafeAreaView >
147
+ )
148
+ }
@@ -0,0 +1,62 @@
1
+ export default function(theme) {
2
+ return {
3
+ activity: {
4
+ padding: 20
5
+ },
6
+ arrowIcon: {
7
+ marginStart: 'auto',
8
+ marginEnd: 10,
9
+ },
10
+ companyCity:{
11
+ fontSize: theme.fontSizes.s,
12
+ paddingTop: theme.paddings.xsmall,
13
+ color: theme.colors.secondaryText
14
+ },
15
+ container: {
16
+ flex: 1,
17
+ backgroundColor: theme.colors.background,
18
+ },
19
+ containerErrorMsg: {
20
+ flex: 1,
21
+ justifyContent: 'center',
22
+ alignContent: 'center',
23
+ alignItems: 'center',
24
+ margin: theme.paddings.default,
25
+ },
26
+ content: {
27
+ backgroundColor: theme.colors.background,
28
+ flex: 1
29
+ },
30
+ date:{
31
+ fontSize: theme.fontSizes.s,
32
+ paddingTop: theme.paddings.xsmall
33
+ },
34
+ header: {
35
+ backgroundColor: theme.colors.background,
36
+ padding: 10,
37
+ flexDirection: "row",
38
+ justifyContent: 'flex-start',
39
+ alignItems: 'center',
40
+ },
41
+ headerText: {
42
+ fontSize: theme.fontSizes.l,
43
+ ...theme.fonts.light,
44
+ marginTop: 10,
45
+ marginBottom: 10
46
+ },
47
+ innerContainer: {
48
+ padding: 40,
49
+ marginTop: 200
50
+ },
51
+ title:{
52
+ fontSize: theme.fontSizes.xxl,
53
+ color: theme.colors.jobsTitleColor
54
+ },
55
+ titleNoJobs:{
56
+ fontSize: theme.fontSizes.xxl,
57
+ color: theme.colors.jobsTitleColor,
58
+ textAlign: 'center',
59
+ marginBottom: theme.paddings.default
60
+ },
61
+ }
62
+ };
@@ -0,0 +1,383 @@
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 } from 'react';
16
+ import {
17
+ View,
18
+ ActivityIndicator,
19
+ SafeAreaView,
20
+ StyleSheet,
21
+ Text
22
+ } from 'react-native';
23
+
24
+ import { useTheme } from 'react-native-paper';
25
+ import { AccordionList } from 'accordion-collapse-react-native';
26
+ import { TabView, TabBar, TabBarItem } from 'react-native-tab-view';
27
+ import { useTranslation } from 'react-i18next';
28
+ import { CommonActions, useNavigation, useRoute } from '@react-navigation/native';
29
+
30
+ import { DateTime, Duration } from 'luxon';
31
+
32
+ import moment from 'moment';
33
+ import 'moment/locale/de';
34
+
35
+ import { AppBar as AppbarComponent } from '@olea-bps/components';
36
+ import IconsOpenasist from '@olea-bps/icons-openasist';
37
+ import { MensaMenu } from '@olea-bps/components';
38
+ import { useCanteen, useCanteens, useFilteredMenu } from '@olea-bps/context-canteen';
39
+ import { useLanguage } from '@olea-bps/core';
40
+
41
+ import componentStyles from './styles';
42
+
43
+ /**
44
+ * Generiert die Tabs/Routen für die Mensa-Tabview
45
+ *
46
+ * @param {DateTime} begin Tag mit dem die Generierung der Tabs/Routen beginnen soll
47
+ * @param {Number} daysToRender Anzahl der Tage, die gerendert werden sollen
48
+ * @param {string} language Sprache, welche für die Datumsformatierung der Tabs verwendet werden soll
49
+ * @param {Number[]} disabledWeekdays Liste an Wochentagen welche nicht mit in die Tabs aufgenommen werden sollen im ISO Wochentagsnummer-Format
50
+ * @returns
51
+ */
52
+ function generateDayRoutes(begin, daysToRender, language, disabledWeekdays = []) {
53
+ return Array?.from(
54
+ { length: daysToRender },
55
+ (_, index) => {
56
+ const currentDay = begin.setLocale(language).plus({ days: index }).startOf('day');
57
+ const isoDayDate = currentDay?.toISODate();
58
+ return {
59
+ key: isoDayDate,
60
+ date: currentDay,
61
+ }
62
+ }
63
+ )?.filter(dayRoute => !disabledWeekdays?.includes(dayRoute?.date?.weekday));
64
+ }
65
+
66
+ function CanteensAccordionHeader({ canteenId, menuDate, isExpanded, styles }) {
67
+ const { t } = useTranslation();
68
+ const [canteen] = useCanteen(canteenId);
69
+ const [, refreshMenu, mealAmount, filteredMealAmount, activeSelections] = useFilteredMenu(canteenId, menuDate);
70
+ const { themeStyles, colors } = useTheme();
71
+
72
+ useEffect(
73
+ () => {
74
+ refreshMenu();
75
+ },
76
+ [canteenId, menuDate]
77
+ )
78
+
79
+ return (
80
+ <View style={styles.header}>
81
+ <View style={[themeStyles.cardLeftIcon, { marginStart: 5 }]}>
82
+ {
83
+ canteen?.type
84
+ ? <IconsOpenasist icon={((canteen.type === 'cafeteria') ? 'coffee' : 'mensa')} size={25} color={colors.icon} />
85
+ : null
86
+ }
87
+ </View>
88
+ <View>
89
+ <Text style={styles.headerText}>{canteen?.title ?? `Fehler: Mensa mit ID ${canteenId} kann nicht angezeigt werden. Bitte melden!`}</Text>
90
+ {
91
+ Array.isArray(activeSelections) && activeSelections.length > 0
92
+ ? <Text>
93
+ {
94
+ t(
95
+ 'canteen:amountOfFilteredMeals',
96
+ { filteredMealAmount, mealAmount, filters: activeSelections.map(favoriteSelection => t(favoriteSelection.labelKey)) }
97
+ )
98
+ }
99
+ </Text>
100
+ : null
101
+ }
102
+ </View>
103
+ <View style={styles.arrowIcon}>
104
+ <IconsOpenasist icon={isExpanded ? 'up' : 'down'} size={20} color={colors.grayLight5} />
105
+ </View>
106
+ </View>
107
+ );
108
+ }
109
+
110
+ /**
111
+ * Akkordion, welches die Mensen einer Universität anzeigt.
112
+ * Es werden automatisch die Mensen aus dem Mensa-Kontext geladen.
113
+ *
114
+ * @component
115
+ * @param {Object} props
116
+ * @param {string} props.menuDate - Datum des Essensangebotes, welches als String im ISO 8601 Format zu übergeben ist.
117
+ * @param {string} [props.expandedCanteenId] - ID der Mensa, dessen Akkordion-Element geöffent sein soll.
118
+ * @param {JSX.Element} [props.CanteensEmptyComponent] - JSX, welches angezeigt werden soll, wenn keine Mensen angezeigt werden können.
119
+ * @param {(expandedCanteenId: string) => void} [props.onCanteenSelect] - Event welches ausgelöst wird, wenn der Nutzer ein Akkordion-Element öffnet oder schließt.
120
+ * @returns {JSX.Element}
121
+ *
122
+ * @example
123
+ * const [activeCanteen, setActiveCanteen] = useState(null);
124
+ *
125
+ * return (
126
+ * <CanteensAccordion
127
+ * menuDate={'01-12-2020'}
128
+ * expandedCanteenId={activeCanteen}
129
+ * onCanteenSelect={
130
+ * expandedCanteenId => setActiveCanteen(expandedCanteenId)
131
+ * }
132
+ * CanteensEmptyComponent={
133
+ * <Text>Keine Mensa gefunden</Text>
134
+ * }
135
+ * />
136
+ * )
137
+ */
138
+ function CanteensAccordion({ expandedCanteenId, menuDate, onCanteenSelect, CanteensEmptyComponent }) {
139
+
140
+ const [canteens] = useCanteens();
141
+ const canteensIds = useMemo(
142
+ () => Object.keys(canteens),
143
+ [canteens]
144
+ )
145
+ const theme = useTheme();
146
+
147
+ const styles = useMemo(
148
+ () => StyleSheet.create(componentStyles(theme)),
149
+ [theme]
150
+ );
151
+
152
+ return (
153
+ <AccordionList
154
+ list={canteensIds}
155
+ expandedKey={expandedCanteenId}
156
+ onToggle={
157
+ // Wenn eine Mensa-Akkordion-Element vim Nutzer angeklickt wird, soll dessen ID bzw. Key an die onCanteenSelect-Funktion gegeben werden.
158
+ // Wird das Akkordion-Element geschlossen, wird null übergeben.
159
+ // Somit kann eine Eltern-Komponente die Kontrolle über die geöffenten Akkordion-Elemente übernehmen (siehe expandedCanteenId).
160
+ (key, index, isExpanded) => onCanteenSelect?.(
161
+ // Wenn isExpanded == false, wurde die Mensa gerade geschlossen, ansonsten wurde die Mensa vom Nutzer geöffnet.
162
+ isExpanded
163
+ // Mensa-Akkordion-Element wurde geöffnet. Es wird der Mensa-Key zurückgeben.
164
+ ? key
165
+ // Mensa-Akkordion-Element wurde geschlossen. Es wird kein Mensa-Key zurückgeben.
166
+ : null
167
+ )
168
+ }
169
+ keyExtractor={(canteenId, index) => canteenId}
170
+ header={
171
+ (canteenId, index, isExpanded) =>
172
+ <CanteensAccordionHeader
173
+ canteenId={canteenId}
174
+ menuDate={menuDate}
175
+ isExpanded={isExpanded}
176
+ styles={styles}
177
+ />
178
+ }
179
+ body={
180
+ canteenId =>
181
+ < View style={styles.content} >
182
+ <MensaMenu
183
+ canteenId={canteenId}
184
+ menuDate={menuDate}
185
+ />
186
+ </View >
187
+ }
188
+ ListEmptyComponent={CanteensEmptyComponent}
189
+ />
190
+ )
191
+ }
192
+
193
+ /**
194
+ * Canteens View
195
+ *
196
+ * In this view the tabbar and the scenes for the different canteens for each day are rendered
197
+ *
198
+ * Parameters:
199
+ * - none
200
+ *
201
+ * Navigation-Parameters:
202
+ * - none
203
+ */
204
+
205
+
206
+ //TODO:
207
+ // - remove unused dependencies
208
+ // - add comments
209
+ // - recheck code
210
+ // - rename to view-canteens?
211
+
212
+ export default function CanteensView(props) {
213
+ const language = useLanguage();
214
+ const route = useRoute();
215
+
216
+ const { style } = props;
217
+
218
+ const theme = useTheme();
219
+ const { themeStyles, colors } = theme;
220
+ const { t } = useTranslation();
221
+ const navigation = useNavigation();
222
+
223
+ const styles = useMemo(
224
+ () => StyleSheet.create(componentStyles(theme)),
225
+ [theme]
226
+ );
227
+
228
+ const disabledWeekdays = theme?.appSettings?.modules?.canteen?.disabledWeekdays ?? [];
229
+ const weeksToRender = theme?.appSettings?.modules?.canteen?.weeksToRender ?? 1;
230
+ const daysToRender = Duration.fromDurationLike({ week: weeksToRender }).as('days');
231
+ const now = DateTime.now();
232
+ const begin = now.startOf('week');
233
+ const daysTabViewRoutes = generateDayRoutes(begin, daysToRender, language, disabledWeekdays);
234
+
235
+ // Derzeitiger Tag
236
+ const today = now.startOf('day');
237
+ // Suche nach dem Index des heutigen Tages oder den Tag danach. Kann kein Index gefunden werden, wird -1 genommen.
238
+ let initialDayTabIndex = daysTabViewRoutes.findIndex(dayTab => dayTab.date >= today);
239
+ // Wenn kein Index gefunden werden konnte, wird der letzte Tab genommen
240
+ // Wenn nur eine Woche gerendert wird und die Wochenendtagen ausgeschalten wird, wird kein folgetag gefunden.
241
+ initialDayTabIndex = initialDayTabIndex === -1 ? daysTabViewRoutes.length - 1 : initialDayTabIndex;
242
+
243
+ // Dieser State wird an alle Mensa-Akkordions in jedem Tages-Tab weitergeben, damit jedes Mensa-Akkordion die selbe Mensa öffen hat.
244
+ // Ein null-Wert, heißt dass alle Mensa-Akkordion-Elemente geschlossen sind.
245
+ const [activeCanteen, setActiveCanteen] = useState(null);
246
+
247
+ const [index, setIndex] = useState(initialDayTabIndex);
248
+
249
+ useEffect(() => {
250
+ const unsubscribeFocusListener = navigation.addListener('focus', () => {
251
+ _setActiveCanteenFromRoute();
252
+ _setTabViewIndexFromRoute();
253
+ });
254
+
255
+ // Cleanup function
256
+ return () => {
257
+ unsubscribeFocusListener();
258
+ };
259
+ }, [route.params?.canteenId]);
260
+
261
+ // Generieren der Tagestabs
262
+ const routes = useMemo(
263
+ () => generateDayRoutes(begin, daysToRender, language, disabledWeekdays),
264
+ [begin.toISODate(), daysToRender, language, disabledWeekdays]
265
+ )
266
+
267
+ /*
268
+ When a user presses a component meal item in dashboard she is taken to the Canteen Tab View.
269
+ To automatically expand the canteen with the pressed meal in the accordion, the canteen id is passed as a route param.
270
+ This method is responsible for setting the component state from the route param values which in turn controls the tab view.
271
+ (active canteen = the canteen which is expanded in accordion)
272
+ */
273
+ const _setActiveCanteenFromRoute = () => {
274
+ const canteenId = route?.params?.canteenId;
275
+ if (canteenId) {
276
+ setActiveCanteen(canteenId);
277
+
278
+ /*
279
+ After setting the active canteen state, the passedCanteenId needs to get set as undefined.
280
+ so the lastly collapsed canteen will stay collapsed after navigating through the main tab navigation
281
+ and not the canteen with the lastly passed id
282
+ */
283
+ navigation.dispatch(CommonActions.setParams({ canteenId: undefined }));
284
+ }
285
+ };
286
+
287
+ const _setTabViewIndexFromRoute = () => {
288
+ const menuDate = route.params?.menuDate;
289
+
290
+ if (!menuDate) return;
291
+
292
+ const menuDateIndex = routes.findIndex(route => route.date.toISODate() === menuDate);
293
+ setIndex(menuDateIndex);
294
+ navigation.dispatch(CommonActions.setParams({ menuDate: undefined }));
295
+ };
296
+
297
+ const _renderTabBar = props => {
298
+ return (
299
+ <TabBar
300
+ {...props}
301
+ scrollEnabled
302
+ style={themeStyles.tabs}
303
+ activeColor={themeStyles.tabs.activeColor}
304
+ inactiveColor={themeStyles.tabs.inactiveColor}
305
+ indicatorStyle={themeStyles.tabIndicator}
306
+ tabStyle={{ width: 'auto', paddingHorizontal: 20 }}
307
+ renderTabBarItem={({ route, navigationState, ...rest}) =>
308
+ <TabBarItem
309
+ {...rest}
310
+ key={route.key}
311
+ route={route}
312
+ navigationState={navigationState}
313
+ labelStyle={themeStyles.tab}
314
+ activeColor={themeStyles.tabs.activeColor}
315
+ inactiveColor={themeStyles.tabs.inactiveColor}
316
+ // Die einbindung von moment.js zum Anzeigen des Wochentages sollte langfristig entfernt werden.
317
+ // Funktioniert die Luxon funktionalität der Wochenanzeige nicht unter iOS datetime.toFormat('ccc')
318
+ labelText={`${moment.unix(route.date.toUnixInteger()).locale(language).format('dd')}, ${route.date.toFormat('dd.LL.')}`}
319
+ accessibilityLabel={route.date.toFormat('DDDD')}
320
+ />
321
+ }
322
+ />
323
+ );
324
+ };
325
+
326
+ return (
327
+ <SafeAreaView style={[styles.container, themeStyles.appSafeAreaContainer]}>
328
+ <AppbarComponent
329
+ title={t('canteen:title')} {...props}
330
+ />
331
+ <View style={themeStyles.container}>
332
+ <TabView
333
+ style={style}
334
+ navigationState={{
335
+ index,
336
+ routes,
337
+
338
+ // aktive Canteene wird mit übergeben, damit alle Tabs die selbe Mensa öffnen.
339
+ activeCanteen,
340
+ }}
341
+ renderTabBar={_renderTabBar}
342
+ onIndexChange={setIndex}
343
+ renderScene={
344
+ ({ route }) => {
345
+
346
+ const menuDate = route?.key;
347
+
348
+ return (
349
+ <CanteensAccordion
350
+ menuDate={menuDate}
351
+ expandedCanteenId={activeCanteen}
352
+ onCanteenSelect={
353
+ // Wenn dieses Akkordion eine Mensa öffnet oder schließt, wird der activeCanteen statte mit der ID der Mensa aktualisiert.
354
+ // Falls der Nutzer die Mensa schließt und damit keine Mensa im Akkordion öffen ist, wird null in den State geschrieben.
355
+ expandedCanteenId => setActiveCanteen(expandedCanteenId)
356
+ }
357
+ CanteensEmptyComponent={
358
+ <View>
359
+ <Text>{t('canteen:notAvailable')}</Text>
360
+ <ActivityIndicator style={styles.activity} size='large' color={colors.loadingIndicator} />
361
+ </View>
362
+ }
363
+ />
364
+ )
365
+ }
366
+ }
367
+ lazy
368
+ lazyPreloadDistance={2}
369
+ renderLazyPlaceholder={(route) =>
370
+ <View style={styles.centerContainer}>
371
+ <ActivityIndicator
372
+ style={styles.activity}
373
+ size={'large'}
374
+ color={theme.colors.loadingIndicator}
375
+ />
376
+ </View>
377
+ }
378
+ />
379
+ </View>
380
+
381
+ </SafeAreaView>
382
+ );
383
+ }
@@ -0,0 +1,89 @@
1
+ export default function(theme) {
2
+ return {
3
+ container: {
4
+ flex: 1
5
+ },
6
+ centerContainer: {
7
+ flex: 1,
8
+ justifyContent: 'center',
9
+ alignContent: 'center',
10
+ },
11
+ optionTextContainer: {
12
+ flex: 1,
13
+ justifyContent: 'center',
14
+ alignItems: 'center'
15
+ },
16
+ optionsTitleText: {
17
+ fontSize: theme.fontSizes.l,
18
+ marginLeft: 15,
19
+ marginTop: 0,
20
+ marginBottom: 0,
21
+ textAlign: 'left'
22
+ },
23
+ optionIconContainer: {
24
+ marginRight: 9,
25
+ },
26
+ option: {
27
+ backgroundColor: theme.colors.background,
28
+ paddingHorizontal: 0,
29
+ paddingVertical: 0,
30
+ borderBottomWidth: 0.4,
31
+ borderBottomColor: theme.colors.accent,
32
+ },
33
+ optionText: {
34
+ fontSize: theme.fontSizes.m,
35
+ marginTop: 1,
36
+ },
37
+ cardTitle: {
38
+ justifyContent: 'center',
39
+ alignItems: 'flex-start',
40
+ marginBottom: 0
41
+ },
42
+ cardContent: {
43
+ justifyContent: 'center',
44
+ alignItems: 'flex-start',
45
+ paddingTop: theme.paddings.small
46
+ },
47
+ favorite: {
48
+ backgroundColor: theme.colors.secondary
49
+ },
50
+ header: {
51
+ backgroundColor: theme.colors.background,
52
+ padding: 10,
53
+ flexDirection: "row",
54
+ justifyContent: 'flex-start',
55
+ alignItems: 'center',
56
+ },
57
+ content: {
58
+ backgroundColor: theme.colors.background,
59
+ flex: 1
60
+ },
61
+ headerText: {
62
+ fontSize: theme.fontSizes.l,
63
+ ...theme.fonts.light,
64
+ marginTop: 10,
65
+ marginBottom: 10
66
+ },
67
+ accordian: {
68
+ borderBottomColor: theme.colors.accent,
69
+ borderBottomWidth: 1
70
+ },
71
+ arrowIcon: {
72
+ marginStart: 'auto',
73
+ marginEnd: 10,
74
+ },
75
+ tabItem: {
76
+ paddingHorizontal: 16
77
+ },
78
+ tabDay: {
79
+ textAlign: "center",
80
+ fontSize: theme.fontSizes.xxl,
81
+ color: theme.colors.primary
82
+ },
83
+ tabDate: {
84
+ ...theme.fonts.medium,
85
+ textAlign: "center",
86
+ color: theme.colors.primary,
87
+ }
88
+ }
89
+ };