@olea-bps/base 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/components/AppBar/index.js +84 -0
- package/components/AppBar/styles.js +27 -0
- package/components/BookDetail/index.js +268 -0
- package/components/BookDetail/styles.js +124 -0
- package/components/ComponentJobsFilter/index.js +188 -0
- package/components/ComponentJobsFilter/styles.js +12 -0
- package/components/ConnectivityWarning/index.js +65 -0
- package/components/ConnectivityWarning/styles.js +19 -0
- package/components/ContactDetail/index.js +232 -0
- package/components/ContactDetail/styles.js +32 -0
- package/components/CourseDetail/index.js +357 -0
- package/components/CourseDetail/styles.js +59 -0
- package/components/CourseDetailDialog/index.js +169 -0
- package/components/CourseDetailDialog/styles.js +116 -0
- package/components/CourseInfo/index.js +219 -0
- package/components/CourseInfo/styles.js +40 -0
- package/components/DevelopmentDialog/index.js +214 -0
- package/components/DevelopmentDialog/styles.js +10 -0
- package/components/EventCodeInput/index.js +149 -0
- package/components/EventCodeInput/styles.js +108 -0
- package/components/FlexMenuEntry/index.js +84 -0
- package/components/FlexMenuEntry/styles.js +27 -0
- package/components/MainMenuEntry/index.js +88 -0
- package/components/MainMenuEntry/styles.js +28 -0
- package/components/MealItem/index.js +87 -0
- package/components/MealItem/styles.js +84 -0
- package/components/MensaMenu/index.js +305 -0
- package/components/MensaMenu/styles.js +94 -0
- package/components/MensaSlider/index.js +188 -0
- package/components/MensaSlider/styles.js +53 -0
- package/components/Modal/index.js +106 -0
- package/components/Modal/styles.js +8 -0
- package/components/NewsDetail/index.js +377 -0
- package/components/NewsDetail/styles.js +77 -0
- package/components/NewsList/index.js +120 -0
- package/components/NewsList/styles.js +19 -0
- package/components/NewsListItem/index.js +89 -0
- package/components/NewsListItem/styles.js +32 -0
- package/components/OtherCourses/index.js +152 -0
- package/components/OtherCourses/styles.js +10 -0
- package/components/PtsDeparture/index.js +140 -0
- package/components/PtsDeparture/styles.js +7 -0
- package/components/PtsStation/index.js +186 -0
- package/components/PtsStation/styles.js +47 -0
- package/components/QuickLinks/index.js +127 -0
- package/components/QuickLinks/styles.js +45 -0
- package/components/RoomDetail/index.js +281 -0
- package/components/RoomDetail/styles.js +56 -0
- package/components/ScaledImage/index.js +92 -0
- package/components/SearchResults/index.js +362 -0
- package/components/SearchResults/styles.js +59 -0
- package/components/SettingSection/index.js +54 -0
- package/components/SettingSection/styles.js +15 -0
- package/components/SettingsDialog/index.js +52 -0
- package/components/SettingsDialog/styles.js +12 -0
- package/components/SettingsDialogRadio/index.js +66 -0
- package/components/SettingsDialogRadio/styles.js +7 -0
- package/components/SettingsDialogSelect/index.js +73 -0
- package/components/SettingsDialogSelect/styles.js +7 -0
- package/components/TimetableCodeInput/index.js +205 -0
- package/components/TimetableCodeInput/styles.js +28 -0
- package/components/TimetableDay/index.js +252 -0
- package/components/TimetableDay/styles.js +103 -0
- package/components/TimetableEvent/index.js +163 -0
- package/components/TimetableEvent/styles.js +108 -0
- package/components/TimetableList/index.js +180 -0
- package/components/TimetableList/styles.js +106 -0
- package/components/TimetableMonth/index.js +156 -0
- package/components/TimetableMonth/styles.js +29 -0
- package/components/TimetableWeek/index.js +230 -0
- package/components/TimetableWeek/styles.js +58 -0
- package/components/TopNews/index.js +282 -0
- package/components/TopNews/styles.js +125 -0
- package/components/TopNewsHtwk/index.js +279 -0
- package/components/TopNewsHtwk/styles.js +142 -0
- package/components/WebView/index.js +108 -0
- package/components/WebView/styles.js +11 -0
- package/context/context-callmanager/TucCallManager.js +74 -0
- package/context/context-callmanager/index.js +128 -0
- package/context/context-canteen/AsistServerApiProvider.js +126 -0
- package/context/context-canteen/CollektorVersion2ApiProvider.js +100 -0
- package/context/context-canteen/index.js +692 -0
- package/context/context-connectivity/index.js +85 -0
- package/context/context-event/AsistServerClient.js +82 -0
- package/context/context-event/index.js +205 -0
- package/context/context-flex-menu/AsistServerApiProvider.js +0 -0
- package/context/context-flex-menu/CollectorVersion2ApiProvider.js +32 -0
- package/context/context-flex-menu/index.js +160 -0
- package/context/context-info-dialog/CollektorVersion2ApiProvider.js +53 -0
- package/context/context-info-dialog/ProviderErrors.js +22 -0
- package/context/context-info-dialog/index.js +190 -0
- package/context/context-mails/MailService.js +147 -0
- package/context/context-mails/TucUnseenApiProvider.js +65 -0
- package/context/context-mails/index.js +131 -0
- package/context/context-news/CollektorVersion2ApiProvider.js +68 -0
- package/context/context-news/index.js +155 -0
- package/context/context-public-transport-ticket/CollektorVersion2ApiProvider.js +45 -0
- package/context/context-public-transport-ticket/ProviderErrors.js +11 -0
- package/context/context-public-transport-ticket/index.js +175 -0
- package/context/context-timetable/CollectorVersion2ApiProvider.js +102 -0
- package/context/context-timetable/ProviderErrors.js +22 -0
- package/context/context-timetable/TimetableService.js +357 -0
- package/context/context-timetable/index.js +215 -0
- package/context/context-user/index.js +586 -0
- package/index.js +178 -0
- package/libraries/base-api-provider/hooks.js +24 -0
- package/libraries/base-api-provider/http-api-provider.js +168 -0
- package/libraries/base-api-provider/index.js +20 -0
- package/libraries/core/api/canteens.js +88 -0
- package/libraries/core/api/corona.js +45 -0
- package/libraries/core/api/courses.js +54 -0
- package/libraries/core/api/device.js +98 -0
- package/libraries/core/api/feed.js +144 -0
- package/libraries/core/api/feedback.js +123 -0
- package/libraries/core/api/jobs.js +48 -0
- package/libraries/core/api/library.js +67 -0
- package/libraries/core/api/lostfound.js +77 -0
- package/libraries/core/api/occupancy.js +44 -0
- package/libraries/core/api/officehours.js +25 -0
- package/libraries/core/api/poi.js +25 -0
- package/libraries/core/api/pts.js +68 -0
- package/libraries/core/api/rooms.js +31 -0
- package/libraries/core/api/survey.js +121 -0
- package/libraries/core/api/telephone.js +32 -0
- package/libraries/core/api/tucrooms.js +31 -0
- package/libraries/core/constants/actions.js +75 -0
- package/libraries/core/constants/api.js +146 -0
- package/libraries/core/constants/enums.js +5 -0
- package/libraries/core/helper/date.js +9 -0
- package/libraries/core/helper/format.helper.js +2 -0
- package/libraries/core/index.js +60 -0
- package/libraries/core/redux/actions/notifications.js +6 -0
- package/libraries/core/redux/actions/setting.js +75 -0
- package/libraries/core/redux/actions/state.js +74 -0
- package/libraries/core/redux/asyncDispatch.js +27 -0
- package/libraries/core/redux/reducers/api.js +190 -0
- package/libraries/core/redux/reducers/index.js +32 -0
- package/libraries/core/redux/reducers/notifications.js +16 -0
- package/libraries/core/redux/reducers/setting.js +99 -0
- package/libraries/core/redux/reducers/state.js +122 -0
- package/libraries/core/redux/selectors.js +123 -0
- package/libraries/core/redux/store.js +40 -0
- package/libraries/core/services/data.js +96 -0
- package/libraries/core/services/root-navigation.js +36 -0
- package/libraries/core/services/search.js +175 -0
- package/libraries/core-plugins/enums/replaceTypes.js +53 -0
- package/libraries/core-plugins/index.js +21 -0
- package/libraries/core-plugins/redux/actions/plugin.js +13 -0
- package/libraries/core-plugins/redux/reducers/plugin.js +210 -0
- package/libraries/icons-openasist/index.js +143 -0
- package/libraries/notifications/index.js +268 -0
- package/libraries/notifications/services/subscriber.service.js +123 -0
- package/libraries/react-native-webview-autoheight/README.md +47 -0
- package/libraries/react-native-webview-autoheight/index.js +140 -0
- package/libraries/react-native-webview-autoheight/package.json +37 -0
- package/libraries/react-native-webview-autoheight/utils.js +268 -0
- package/libraries/redux-offline/.eslintignore +1 -0
- package/libraries/redux-offline/.github/ISSUE_TEMPLATE/redux-offline-core-issues-template.md +25 -0
- package/libraries/redux-offline/.prettierrc +6 -0
- package/libraries/redux-offline/LICENSE +21 -0
- package/libraries/redux-offline/README.md +133 -0
- package/libraries/redux-offline/flow-typed/npm/redux-logger_vx.x.x.js +109 -0
- package/libraries/redux-offline/flow-typed/npm/redux_v4.x.x.js +100 -0
- package/libraries/redux-offline/lib/actions.js +46 -0
- package/libraries/redux-offline/lib/config.js +15 -0
- package/libraries/redux-offline/lib/constants.js +17 -0
- package/libraries/redux-offline/lib/defaults/defaultCommit.js +11 -0
- package/libraries/redux-offline/lib/defaults/defaultRollback.js +11 -0
- package/libraries/redux-offline/lib/defaults/detectNetwork.js +33 -0
- package/libraries/redux-offline/lib/defaults/detectNetwork.native.js +211 -0
- package/libraries/redux-offline/lib/defaults/discard.js +18 -0
- package/libraries/redux-offline/lib/defaults/effect.js +87 -0
- package/libraries/redux-offline/lib/defaults/index.js +32 -0
- package/libraries/redux-offline/lib/defaults/offlineStateLens.js +24 -0
- package/libraries/redux-offline/lib/defaults/persist.js +9 -0
- package/libraries/redux-offline/lib/defaults/persist.native.js +17 -0
- package/libraries/redux-offline/lib/defaults/persistAutoRehydrate.js +8 -0
- package/libraries/redux-offline/lib/defaults/queue.js +27 -0
- package/libraries/redux-offline/lib/defaults/retry.js +29 -0
- package/libraries/redux-offline/lib/index.js +115 -0
- package/libraries/redux-offline/lib/middleware.js +56 -0
- package/libraries/redux-offline/lib/offlineActionTracker.js +43 -0
- package/libraries/redux-offline/lib/send.js +112 -0
- package/libraries/redux-offline/lib/types.js +3 -0
- package/libraries/redux-offline/lib/updater.js +111 -0
- package/libraries/redux-offline/package.json +69 -0
- package/libraries/redux-offline/src/__tests__/defaults/discard.js +22 -0
- package/libraries/redux-offline/src/__tests__/defaults/effect.js +118 -0
- package/libraries/redux-offline/src/__tests__/index.js +116 -0
- package/libraries/redux-offline/src/__tests__/middleware.js +185 -0
- package/libraries/redux-offline/src/__tests__/offlineActionTracker.js +54 -0
- package/libraries/redux-offline/src/__tests__/send.js +208 -0
- package/libraries/redux-offline/src/actions.js +36 -0
- package/libraries/redux-offline/src/config.js +9 -0
- package/libraries/redux-offline/src/constants.js +18 -0
- package/libraries/redux-offline/src/defaults/defaultCommit.js +7 -0
- package/libraries/redux-offline/src/defaults/defaultRollback.js +7 -0
- package/libraries/redux-offline/src/defaults/detectNetwork.js +16 -0
- package/libraries/redux-offline/src/defaults/detectNetwork.native.js +148 -0
- package/libraries/redux-offline/src/defaults/discard.js +19 -0
- package/libraries/redux-offline/src/defaults/effect.js +86 -0
- package/libraries/redux-offline/src/defaults/index.js +25 -0
- package/libraries/redux-offline/src/defaults/offlineStateLens.js +11 -0
- package/libraries/redux-offline/src/defaults/persist.js +4 -0
- package/libraries/redux-offline/src/defaults/persist.native.js +9 -0
- package/libraries/redux-offline/src/defaults/persistAutoRehydrate.js +4 -0
- package/libraries/redux-offline/src/defaults/queue.js +20 -0
- package/libraries/redux-offline/src/defaults/retry.js +18 -0
- package/libraries/redux-offline/src/index.js +138 -0
- package/libraries/redux-offline/src/middleware.js +52 -0
- package/libraries/redux-offline/src/offlineActionTracker.js +40 -0
- package/libraries/redux-offline/src/send.js +111 -0
- package/libraries/redux-offline/src/types.js +127 -0
- package/libraries/redux-offline/src/updater.js +141 -0
- package/libraries/redux-offline/typings.d.ts +150 -0
- package/libraries/redux-offline/yarn.lock +6460 -0
- package/libraries/stored-state/index.js +155 -0
- package/package.json +68 -0
- package/views/Callmanager/index.js +148 -0
- package/views/Callmanager/styles.js +62 -0
- package/views/Canteens/index.js +383 -0
- package/views/Canteens/styles.js +89 -0
- package/views/Dashboard/index.js +176 -0
- package/views/Dashboard/styles.js +16 -0
- package/views/DashboardHtwk/index.js +197 -0
- package/views/DashboardHtwk/styles.js +24 -0
- package/views/Event/index.js +373 -0
- package/views/Event/styles.js +63 -0
- package/views/FeedList/index.js +165 -0
- package/views/FeedList/styles.js +15 -0
- package/views/FeedNews/index.js +243 -0
- package/views/FeedNews/styles.js +32 -0
- package/views/Flexmenu/index.js +185 -0
- package/views/Flexmenu/styles.js +62 -0
- package/views/FlexmenuWebview/index.js +167 -0
- package/views/FlexmenuWebview/styles.js +16 -0
- package/views/Howhy/index.js +151 -0
- package/views/Howhy/styles.js +11 -0
- package/views/Jobs/index.js +217 -0
- package/views/Jobs/styles.js +41 -0
- package/views/MainMenu/index.js +283 -0
- package/views/MainMenu/styles.js +36 -0
- package/views/NewsTabbar/index.js +164 -0
- package/views/NewsTabbar/styles.js +27 -0
- package/views/Opal/index.js +136 -0
- package/views/Opal/styles.js +11 -0
- package/views/PublicTransportTicket/index.js +173 -0
- package/views/PublicTransportTicket/styles.js +17 -0
- package/views/Search/index.js +186 -0
- package/views/Search/styles.js +67 -0
- package/views/SettingsAccessibility/index.js +148 -0
- package/views/SettingsAccessibility/styles.js +13 -0
- package/views/SettingsAppInfo/index.js +86 -0
- package/views/SettingsAppInfo/styles.js +18 -0
- package/views/SettingsCanteens/index.js +249 -0
- package/views/SettingsCanteens/styles.js +33 -0
- package/views/SettingsGeneral/index.js +173 -0
- package/views/SettingsGeneral/styles.js +28 -0
- package/views/SettingsNotifications/index.js +204 -0
- package/views/SettingsNotifications/styles.js +38 -0
- package/views/SettingsUser/index.js +170 -0
- package/views/SettingsUser/styles.js +17 -0
- package/views/TimetableCalendar/index.js +387 -0
- package/views/TimetableCalendar/styles.js +121 -0
- package/views/TimetableList/index.js +402 -0
- package/views/TimetableList/styles.js +55 -0
- package/views/Webviews/index.js +158 -0
- package/views/Webviews/styles.js +11 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export default function(theme) {
|
|
2
|
+
return {
|
|
3
|
+
selectOption: {
|
|
4
|
+
display: 'flex',
|
|
5
|
+
flexDirection: 'row',
|
|
6
|
+
justifyContent: 'space-between'
|
|
7
|
+
},
|
|
8
|
+
listItemTitle: {
|
|
9
|
+
fontSize: theme.fontSizes.l
|
|
10
|
+
},
|
|
11
|
+
listItemDescription: {
|
|
12
|
+
fontSize: theme.fontSizes.m
|
|
13
|
+
},
|
|
14
|
+
infoBanner: {
|
|
15
|
+
width: '100%'
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,249 @@
|
|
|
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 } from 'react';
|
|
16
|
+
import { SafeAreaView, View, StyleSheet } from 'react-native';
|
|
17
|
+
|
|
18
|
+
import { connect } from 'react-redux';
|
|
19
|
+
import { useTheme } from 'react-native-paper';
|
|
20
|
+
import { useTranslation } from 'react-i18next';
|
|
21
|
+
|
|
22
|
+
import { onSettingCanteenMerge, store } from '../../libraries/core';
|
|
23
|
+
import AppbarComponent from '../../components/AppBar';
|
|
24
|
+
import SettingsDialogSelect from '../../components/SettingsDialogSelect';
|
|
25
|
+
import SettingsDialogRadio from '../../components/SettingsDialogRadio';
|
|
26
|
+
import { useCanteens, useFavoriteCanteens, usePriceGroupCode } from '../../context/context-canteen';
|
|
27
|
+
import SettingSection from '../../components/SettingSection';
|
|
28
|
+
|
|
29
|
+
import componentStyles from './styles';
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Renders the Canteens Settings view.
|
|
33
|
+
*
|
|
34
|
+
* @param {Object} props - The component props.
|
|
35
|
+
* @param {Object} props.settings - The settings object.
|
|
36
|
+
* @returns {React.JSX.Element} The rendered component.
|
|
37
|
+
*/
|
|
38
|
+
function CanteensSettingsView(props) {
|
|
39
|
+
// Get theme from theme context
|
|
40
|
+
const theme = useTheme();
|
|
41
|
+
// Get translation function from translation hook
|
|
42
|
+
const { t } = useTranslation();
|
|
43
|
+
// Get canteens from canteen context
|
|
44
|
+
const [canteens] = useCanteens();
|
|
45
|
+
|
|
46
|
+
// Extract required datas using destructuring
|
|
47
|
+
const { settings } = props;
|
|
48
|
+
const { appSettings: { mealSelections, groupsOfPersons, mealTypes }, themeStyles } = theme;
|
|
49
|
+
|
|
50
|
+
// Get canteen settings from settings property or use default
|
|
51
|
+
const settingsCanteens = settings?.settingsCanteens;
|
|
52
|
+
const favoriteSelection = Array.isArray(settingsCanteens?.favoriteSelection)
|
|
53
|
+
? settingsCanteens.favoriteSelection
|
|
54
|
+
: [];
|
|
55
|
+
const [favoriteCanteens, setFavoriteCanteens] = useFavoriteCanteens();
|
|
56
|
+
|
|
57
|
+
// Eingestellter Mensapreis aus dem Mensa-Kontext holen
|
|
58
|
+
const [favoritePrice, setFavoritePrice] = usePriceGroupCode();
|
|
59
|
+
|
|
60
|
+
const activeMealTypes = Array.isArray(settingsCanteens?.favoriteMealTypes) && settingsCanteens?.favoriteMealTypes?.length
|
|
61
|
+
? settingsCanteens.favoriteMealTypes
|
|
62
|
+
// If no meal type is active, all meal types are active
|
|
63
|
+
// By getting the code auf all avaiables meal types
|
|
64
|
+
: mealTypes?.map?.(mealType => mealType.code) ?? [];
|
|
65
|
+
|
|
66
|
+
// State variables for showing/hiding dialogs
|
|
67
|
+
const [showPriceDialog, setShowPriceDialog] = useState(false);
|
|
68
|
+
const [showSelectionsDialog, setShowSelectionsDialog] = useState(false);
|
|
69
|
+
const [showCanteensDialog, setShowCanteensDialog] = useState(false);
|
|
70
|
+
const [showMealTypesDialog, setShowMealTypesDialog] = useState(false);
|
|
71
|
+
|
|
72
|
+
// Create styles object using useMemo to prevent unnecessary re-renders
|
|
73
|
+
const styles = useMemo(
|
|
74
|
+
() => StyleSheet.create(componentStyles(theme)),
|
|
75
|
+
[theme]
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
// JSX structure and Rendering for the component
|
|
79
|
+
return (
|
|
80
|
+
// SafeAreaView is used to render content within the safe area boundaries of a device.
|
|
81
|
+
<SafeAreaView style={[styles.container, themeStyles.appSafeAreaContainer]}>
|
|
82
|
+
{/* AppbarComponent is a custom component for the app's header bar. */}
|
|
83
|
+
<AppbarComponent {...props} t={t} title={t('settings:canteens.title')} />
|
|
84
|
+
|
|
85
|
+
{/* This View contains the main content of the screen. */}
|
|
86
|
+
<View accessible={false} style={themeStyles.container}>
|
|
87
|
+
{/* List.Section groups related content. */}
|
|
88
|
+
<SettingSection
|
|
89
|
+
title={t('settings:canteens.priceSelection')}
|
|
90
|
+
description={
|
|
91
|
+
favoritePrice
|
|
92
|
+
? t(
|
|
93
|
+
groupsOfPersons
|
|
94
|
+
.find(personGroup => personGroup.code === favoritePrice)
|
|
95
|
+
.labelKey
|
|
96
|
+
)
|
|
97
|
+
: groupsOfPersons
|
|
98
|
+
.map(personGroup => personGroup.labelKey)
|
|
99
|
+
.map(t)
|
|
100
|
+
.join(', ')
|
|
101
|
+
}
|
|
102
|
+
onPress={() => setShowPriceDialog(true)}
|
|
103
|
+
/>
|
|
104
|
+
<SettingsDialogRadio
|
|
105
|
+
title={t('settings:canteens.priceSelection')}
|
|
106
|
+
visible={showPriceDialog}
|
|
107
|
+
selectedOption={favoritePrice}
|
|
108
|
+
options={
|
|
109
|
+
groupsOfPersons
|
|
110
|
+
.map(
|
|
111
|
+
personGroup =>
|
|
112
|
+
({
|
|
113
|
+
key: personGroup.code,
|
|
114
|
+
label: t(personGroup.labelKey),
|
|
115
|
+
})
|
|
116
|
+
)
|
|
117
|
+
}
|
|
118
|
+
onDismiss={() => setShowPriceDialog(false)}
|
|
119
|
+
onOk={() => setShowPriceDialog(false)}
|
|
120
|
+
onChange={setFavoritePrice}
|
|
121
|
+
/>
|
|
122
|
+
|
|
123
|
+
{/* Conditional rendering based on whether mealSelections is an array. */}
|
|
124
|
+
{
|
|
125
|
+
Array.isArray(mealSelections)
|
|
126
|
+
? <>
|
|
127
|
+
<SettingSection
|
|
128
|
+
title={t('settings:canteens.preferredSelections')}
|
|
129
|
+
description={
|
|
130
|
+
mealSelections
|
|
131
|
+
.filter(selection => favoriteSelection.includes(selection.code))
|
|
132
|
+
.map(selection => selection.labelKey)
|
|
133
|
+
.map(selectionLabelKey => t(selectionLabelKey))
|
|
134
|
+
.join(', ')
|
|
135
|
+
}
|
|
136
|
+
onPress={() => setShowSelectionsDialog(true)}
|
|
137
|
+
/>
|
|
138
|
+
<SettingsDialogSelect
|
|
139
|
+
title={t('settings:canteens.preferredSelections')}
|
|
140
|
+
selectedOptions={favoriteSelection}
|
|
141
|
+
visible={showSelectionsDialog}
|
|
142
|
+
options={
|
|
143
|
+
mealSelections.map(
|
|
144
|
+
selection =>
|
|
145
|
+
({
|
|
146
|
+
key: selection.code,
|
|
147
|
+
label: t(selection.labelKey),
|
|
148
|
+
})
|
|
149
|
+
)
|
|
150
|
+
}
|
|
151
|
+
onDismiss={() => { setShowSelectionsDialog(false) }}
|
|
152
|
+
onOk={() => { setShowSelectionsDialog(false) }}
|
|
153
|
+
onChange={
|
|
154
|
+
selectedOptions =>
|
|
155
|
+
store.dispatch(
|
|
156
|
+
onSettingCanteenMerge(
|
|
157
|
+
'canteenSettings',
|
|
158
|
+
{ favoriteSelection: selectedOptions }
|
|
159
|
+
)
|
|
160
|
+
)
|
|
161
|
+
}
|
|
162
|
+
/>
|
|
163
|
+
</>
|
|
164
|
+
: null
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
<SettingSection
|
|
168
|
+
title={t('canteen:favoriteCanteen:title')}
|
|
169
|
+
description={
|
|
170
|
+
Object.entries(canteens)
|
|
171
|
+
.filter(([canteenId, canteenDatas]) => favoriteCanteens.includes(canteenId))
|
|
172
|
+
.map(([canteenId, canteenDatas]) => canteenDatas.title)
|
|
173
|
+
.join(', ')
|
|
174
|
+
}
|
|
175
|
+
onPress={() => setShowCanteensDialog(true)}
|
|
176
|
+
/>
|
|
177
|
+
<SettingsDialogSelect
|
|
178
|
+
title={t('canteen:favoriteCanteen:select')}
|
|
179
|
+
selectedOptions={favoriteCanteens}
|
|
180
|
+
visible={showCanteensDialog}
|
|
181
|
+
options={
|
|
182
|
+
Object.entries(canteens).map(
|
|
183
|
+
([canteenId, canteenDatas]) => ({
|
|
184
|
+
key: canteenId,
|
|
185
|
+
label: canteenDatas.title
|
|
186
|
+
})
|
|
187
|
+
)
|
|
188
|
+
}
|
|
189
|
+
onDismiss={() => setShowCanteensDialog(false)}
|
|
190
|
+
onOk={() => setShowCanteensDialog(false)}
|
|
191
|
+
onChange={setFavoriteCanteens}
|
|
192
|
+
/>
|
|
193
|
+
|
|
194
|
+
{
|
|
195
|
+
Array.isArray(mealTypes)
|
|
196
|
+
? <>
|
|
197
|
+
<SettingSection
|
|
198
|
+
title={t('settings:canteens:activeMealtypes:title')}
|
|
199
|
+
description={
|
|
200
|
+
mealTypes
|
|
201
|
+
.filter(mealType => activeMealTypes.includes(mealType.code))
|
|
202
|
+
.map(mealType => mealType.labelKey)
|
|
203
|
+
.map(mealTypeLabelKey => t(mealTypeLabelKey))
|
|
204
|
+
.join(', ')
|
|
205
|
+
}
|
|
206
|
+
onPress={() => setShowMealTypesDialog(true)}
|
|
207
|
+
/>
|
|
208
|
+
<SettingsDialogSelect
|
|
209
|
+
title={t('settings:canteens:activeMealtypes:dialogTitle')}
|
|
210
|
+
selectedOptions={activeMealTypes}
|
|
211
|
+
visible={showMealTypesDialog}
|
|
212
|
+
options={
|
|
213
|
+
mealTypes.map(
|
|
214
|
+
mealType =>
|
|
215
|
+
({
|
|
216
|
+
key: mealType.code,
|
|
217
|
+
label: t(mealType.labelKey),
|
|
218
|
+
})
|
|
219
|
+
)
|
|
220
|
+
}
|
|
221
|
+
onDismiss={() => setShowMealTypesDialog(false)}
|
|
222
|
+
onOk={() => setShowMealTypesDialog(false)}
|
|
223
|
+
onChange={
|
|
224
|
+
selectedOptions =>
|
|
225
|
+
store.dispatch(
|
|
226
|
+
onSettingCanteenMerge(
|
|
227
|
+
'canteenSettings',
|
|
228
|
+
{ favoriteMealTypes: selectedOptions }
|
|
229
|
+
)
|
|
230
|
+
)
|
|
231
|
+
}
|
|
232
|
+
/>
|
|
233
|
+
</>
|
|
234
|
+
: null
|
|
235
|
+
}
|
|
236
|
+
</View>
|
|
237
|
+
</SafeAreaView>
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
// Map the Redux state to component props
|
|
242
|
+
const mapStateToProps = (state) => {
|
|
243
|
+
return {
|
|
244
|
+
settings: state.settingReducer,
|
|
245
|
+
};
|
|
246
|
+
};
|
|
247
|
+
|
|
248
|
+
// Connect the component to Redux store and apply translation and theme
|
|
249
|
+
export default connect(mapStateToProps)(CanteensSettingsView);
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export default function(theme) {
|
|
2
|
+
return {
|
|
3
|
+
selectOption: {
|
|
4
|
+
display: 'flex',
|
|
5
|
+
flexDirection: 'row',
|
|
6
|
+
justifyContent: 'space-between'
|
|
7
|
+
},
|
|
8
|
+
listItemTitle: {
|
|
9
|
+
fontSize: theme.fontSizes.l
|
|
10
|
+
},
|
|
11
|
+
listItemDescription: {
|
|
12
|
+
fontSize: theme.fontSizes.m,
|
|
13
|
+
color: theme.colors.textLighter
|
|
14
|
+
},
|
|
15
|
+
buttonLabel: {
|
|
16
|
+
fontSize: theme.fontSizes.m,
|
|
17
|
+
color: theme.colors.text,
|
|
18
|
+
},
|
|
19
|
+
dialogTitle: {
|
|
20
|
+
fontSize: theme.fontSizes.l,
|
|
21
|
+
lineHeight: theme.lineHeights.xxl
|
|
22
|
+
},
|
|
23
|
+
dialogContent: {
|
|
24
|
+
fontSize: theme.fontSizes.m,
|
|
25
|
+
color: theme.colors.text,
|
|
26
|
+
},
|
|
27
|
+
listItems: {
|
|
28
|
+
flex: 1,
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
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, View, Text } from 'react-native';
|
|
17
|
+
|
|
18
|
+
import { connect } from 'react-redux'
|
|
19
|
+
import { Button, List, Dialog, Portal, RadioButton, withTheme } from 'react-native-paper';
|
|
20
|
+
import { withTranslation } from 'react-i18next';
|
|
21
|
+
|
|
22
|
+
import merge from 'lodash/merge';
|
|
23
|
+
|
|
24
|
+
import { onSettingGeneralOverride, store } from '../../libraries/core';
|
|
25
|
+
import AppbarComponent from '../../components/AppBar';
|
|
26
|
+
|
|
27
|
+
import componentStyles from './styles';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Settings General
|
|
31
|
+
*
|
|
32
|
+
* Parameters:
|
|
33
|
+
* - none
|
|
34
|
+
*
|
|
35
|
+
* Navigation-Parameters:
|
|
36
|
+
* - none
|
|
37
|
+
*/
|
|
38
|
+
class GeneralSettingsView extends React.Component {
|
|
39
|
+
// Styles of this component
|
|
40
|
+
styles;
|
|
41
|
+
|
|
42
|
+
constructor(props) {
|
|
43
|
+
super(props);
|
|
44
|
+
|
|
45
|
+
// ------------------------------------------------------------------------
|
|
46
|
+
// PLUGIN FUNCTIONALITY
|
|
47
|
+
// ------------------------------------------------------------------------
|
|
48
|
+
|
|
49
|
+
const { pluginStyles, theme } = this.props;
|
|
50
|
+
this.styles = componentStyles(theme);
|
|
51
|
+
|
|
52
|
+
if (pluginStyles) {
|
|
53
|
+
this.styles = merge(this.styles, pluginStyles);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
this.state = {
|
|
57
|
+
language: this.props.settings.settingsGeneral.language,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* update the general settings
|
|
63
|
+
*
|
|
64
|
+
* @private
|
|
65
|
+
*/
|
|
66
|
+
_updateGeneralSettings = () => {
|
|
67
|
+
const generalSettings = {
|
|
68
|
+
language: this.state.language
|
|
69
|
+
};
|
|
70
|
+
this.setState({ isChangeMessageVisible: false });
|
|
71
|
+
store.dispatch(onSettingGeneralOverride('generalSettings', generalSettings));
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
getLanguageByKey = () => {
|
|
75
|
+
const { theme } = this.props;
|
|
76
|
+
const languageCode = this.state.language;
|
|
77
|
+
const languageObject = theme.appSettings.languages.find((language) => language.code === languageCode);
|
|
78
|
+
return languageObject ? languageObject : theme.appSettings.languages[0];
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
_renderLanguages = () => {
|
|
82
|
+
const { theme, t } = this.props;
|
|
83
|
+
const { colors } = theme;
|
|
84
|
+
const languages = theme.appSettings.languages.map(language =>
|
|
85
|
+
<View key={'lanuage-' + language.code} >
|
|
86
|
+
<RadioButton.Item
|
|
87
|
+
value={language.code}
|
|
88
|
+
color={colors.checkboxChecked}
|
|
89
|
+
label={t(language.labelKey)}
|
|
90
|
+
labelStyle={this.styles.dialogContent}
|
|
91
|
+
uncheckedColor={colors.checkboxUnchecked}
|
|
92
|
+
mode={'android'}
|
|
93
|
+
/>
|
|
94
|
+
</View>
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<RadioButton.Group
|
|
99
|
+
onValueChange={value => this.setState({ language: value })}
|
|
100
|
+
value={this.state.language}>
|
|
101
|
+
{languages}
|
|
102
|
+
</RadioButton.Group>
|
|
103
|
+
);
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
_showDialog = () => this.setState({ visible: true });
|
|
107
|
+
|
|
108
|
+
_hideDialog = () => this.setState({ visible: false });
|
|
109
|
+
|
|
110
|
+
render() {
|
|
111
|
+
// ------------------------------------------------------------------------
|
|
112
|
+
// PLUGIN FUNCTIONALITY
|
|
113
|
+
// ------------------------------------------------------------------------
|
|
114
|
+
const PluginComponent = this.props.pluginComponent;
|
|
115
|
+
if (PluginComponent) {
|
|
116
|
+
return <PluginComponent />;
|
|
117
|
+
}
|
|
118
|
+
// ------------------------------------------------------------------------
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
const { theme: { themeStyles, colors }, t } = this.props;
|
|
122
|
+
|
|
123
|
+
return (
|
|
124
|
+
<SafeAreaView style={[this.styles.container, themeStyles.appSafeAreaContainer]}>
|
|
125
|
+
<AppbarComponent {...this.props} title={t('settings:common.title')} />
|
|
126
|
+
<View accessible={false} style={themeStyles.container}>
|
|
127
|
+
<List.Section>
|
|
128
|
+
<List.Item accessible={false} key='language' title={t('settings:common.language')} description={t(this.getLanguageByKey().labelKey)}
|
|
129
|
+
titleStyle={this.styles.listItemTitle} descriptionStyle={this.styles.listItemDescription}
|
|
130
|
+
right={() => <Button accessible={true} labelStyle={this.styles.buttonLabel} onPress={this._showDialog} color={colors.buttonText}>{t('common:changeLabel')}</Button>
|
|
131
|
+
}>
|
|
132
|
+
</List.Item>
|
|
133
|
+
</List.Section>
|
|
134
|
+
<Portal>
|
|
135
|
+
<Dialog visible={this.state.visible}
|
|
136
|
+
onDismiss={this._hideDialog}>
|
|
137
|
+
<Dialog.Title style={this.styles.dialogTitle}>{t('settings:common.language')}</Dialog.Title>
|
|
138
|
+
<Dialog.Content>
|
|
139
|
+
{this._renderLanguages()}
|
|
140
|
+
</Dialog.Content>
|
|
141
|
+
<Dialog.Actions>
|
|
142
|
+
<Button labelStyle={this.styles.dialogContent} onPress={() => { this.setState({ isChangeMessageVisible: true }); this._hideDialog(); }} color={colors.buttonText}>{t('common:okLabel')}</Button>
|
|
143
|
+
</Dialog.Actions>
|
|
144
|
+
</Dialog>
|
|
145
|
+
</Portal>
|
|
146
|
+
<Portal>
|
|
147
|
+
<Dialog visible={this.state.isChangeMessageVisible}
|
|
148
|
+
onDismiss={() => this.setState({ isChangeMessageVisible: false })}>
|
|
149
|
+
<Dialog.Title style={this.styles.dialogTitle}>{t('settings:common.languageChange')}</Dialog.Title>
|
|
150
|
+
<Dialog.Content>
|
|
151
|
+
<Text style={this.styles.dialogContent}>{t('settings:common.languageChangeText')}</Text>
|
|
152
|
+
</Dialog.Content>
|
|
153
|
+
<Dialog.Actions>
|
|
154
|
+
<Button labelStyle={this.styles.dialogContent} onPress={this._updateGeneralSettings} color={colors.buttonText}>{t('settings:common.languageChangeOk')}</Button>
|
|
155
|
+
<Button labelStyle={this.styles.dialogContent} onPress={() => this.setState({ isChangeMessageVisible: false })} color={colors.buttonText}>{t('common:cancelLabel')}</Button>
|
|
156
|
+
</Dialog.Actions>
|
|
157
|
+
</Dialog>
|
|
158
|
+
</Portal>
|
|
159
|
+
</View>
|
|
160
|
+
</SafeAreaView>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
const mapStateToProps = state => {
|
|
166
|
+
return {
|
|
167
|
+
pluginComponent: state.pluginReducer.settingsGeneral.component,
|
|
168
|
+
pluginStyles: state.pluginReducer.settingsGeneral.styles,
|
|
169
|
+
settings: state.settingReducer
|
|
170
|
+
};
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
export default connect(mapStateToProps, null)(withTranslation()(withTheme(GeneralSettingsView)))
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export default function(theme) {
|
|
2
|
+
return {
|
|
3
|
+
selectOption: {
|
|
4
|
+
display: 'flex',
|
|
5
|
+
flexDirection: 'row',
|
|
6
|
+
justifyContent: 'space-between'
|
|
7
|
+
},
|
|
8
|
+
listItemTitle: {
|
|
9
|
+
fontSize: theme.fontSizes.l
|
|
10
|
+
},
|
|
11
|
+
listItemDescription: {
|
|
12
|
+
fontSize: theme.fontSizes.m,
|
|
13
|
+
color: theme.colors.textLighter
|
|
14
|
+
},
|
|
15
|
+
buttonLabel: {
|
|
16
|
+
fontSize: theme.fontSizes.m,
|
|
17
|
+
color: theme.colors.text,
|
|
18
|
+
},
|
|
19
|
+
dialogTitle: {
|
|
20
|
+
fontSize: theme.fontSizes.l,
|
|
21
|
+
lineHeight: theme.lineHeights.xxl
|
|
22
|
+
},
|
|
23
|
+
dialogContent: {
|
|
24
|
+
fontSize: theme.fontSizes.m,
|
|
25
|
+
color: theme.colors.text,
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|