@olea-bps/base 1.0.4 → 1.1.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/MealItem/styles.js +1 -12
- package/components/MensaMenu/index.js +14 -11
- package/context/context-callmanager/index.js +1 -1
- package/context/context-canteen/index.js +2 -2
- package/context/context-flex-menu/index.js +1 -1
- package/context/context-news/index.js +1 -1
- package/libraries/core/helper/color.js +8 -0
- package/libraries/icons-openasist/index.js +15 -0
- package/libraries/notifications/index.js +12 -6
- package/libraries/notifications/services/subscriber.service.js +12 -5
- package/package.json +12 -12
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
const addAlpha = (hexColor, alpha) => {
|
|
3
|
-
// Remove # if present
|
|
4
|
-
const hex = hexColor.replace('#', '');
|
|
5
|
-
|
|
6
|
-
// Parse RGB values
|
|
7
|
-
const r = parseInt(hex.substring(0, 2), 16);
|
|
8
|
-
const g = parseInt(hex.substring(2, 4), 16);
|
|
9
|
-
const b = parseInt(hex.substring(4, 6), 16);
|
|
10
|
-
|
|
11
|
-
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
12
|
-
};
|
|
1
|
+
import { addAlpha } from '../../libraries/core/helper/color';
|
|
13
2
|
|
|
14
3
|
export default function(theme) {
|
|
15
4
|
return {
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
Image
|
|
21
21
|
} from 'react-native';
|
|
22
22
|
import { connect } from 'react-redux'
|
|
23
|
-
import { Button, Dialog, Portal, useTheme } from 'react-native-paper';
|
|
23
|
+
import { Button, Dialog, IconButton, Portal, useTheme } from 'react-native-paper';
|
|
24
24
|
import { useTranslation } from 'react-i18next';
|
|
25
25
|
|
|
26
26
|
import { useFilteredMenu } from '../../context/context-canteen';
|
|
@@ -29,6 +29,7 @@ import { onUpdateRefreshing } from '../../libraries/core';
|
|
|
29
29
|
import IconsOpenasist from '../../libraries/icons-openasist';
|
|
30
30
|
|
|
31
31
|
import componentStyles from './styles';
|
|
32
|
+
import { addAlpha } from '../../libraries/core/helper/color';
|
|
32
33
|
|
|
33
34
|
/**
|
|
34
35
|
* Mensa Menu Component
|
|
@@ -199,19 +200,21 @@ function Meal({ settings, meal, priceGroupCode, priceGroupName }) {
|
|
|
199
200
|
{
|
|
200
201
|
meal?.additives || meal?.allergens
|
|
201
202
|
? <>
|
|
202
|
-
<
|
|
203
|
+
<IconButton
|
|
203
204
|
style={styles.btnAddionals}
|
|
204
|
-
|
|
205
|
-
|
|
205
|
+
iconColor={colors.secondaryText}
|
|
206
|
+
rippleColor={addAlpha(colors.primary, 0.12)}
|
|
207
|
+
size={15}
|
|
206
208
|
accessibilityLabel={t('canteen:allergeneTitle')}
|
|
207
209
|
onPress={() => setAdditionalDialogVisible(true)}
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
210
|
+
icon={({ size, color }) => (
|
|
211
|
+
<IconsOpenasist
|
|
212
|
+
icon={"info"}
|
|
213
|
+
color={color}
|
|
214
|
+
size={size}
|
|
215
|
+
/>
|
|
216
|
+
)}
|
|
217
|
+
/>
|
|
215
218
|
<AdditionalDialog
|
|
216
219
|
allergens={meal?.allergens}
|
|
217
220
|
additives={meal?.additives}
|
|
@@ -46,7 +46,7 @@ function CallManagerContextProvider({ children }) {
|
|
|
46
46
|
switch (callManagerApiProvider?.toLowerCase()) {
|
|
47
47
|
case TucCallManagerProviderName:
|
|
48
48
|
console.debug(componentName, ':', 'use tu chemnitz call manager');
|
|
49
|
-
return
|
|
49
|
+
return TucCallManager.from(callManagerApiBaseUrl, 'de', accessToken);
|
|
50
50
|
default:
|
|
51
51
|
console.log(`${componentName}: Can't build api provider: ${callManagerApiProvider}`)
|
|
52
52
|
return null;
|
|
@@ -386,10 +386,10 @@ function CanteenContextProvider({ children, settings, rootUrl, rootStgUrl, useSt
|
|
|
386
386
|
switch (canteenApiProvider?.toLowerCase()) {
|
|
387
387
|
case AsistServerProviderName:
|
|
388
388
|
console.debug(componentName, ': use asist server api');
|
|
389
|
-
return
|
|
389
|
+
return AsistServerApiProvider.from(canteenApiBaseUrl, canteenApiUniversity, language);
|
|
390
390
|
case CollectorVersion2ProviderName:
|
|
391
391
|
console.debug(componentName, ': use collector v2 api');
|
|
392
|
-
return
|
|
392
|
+
return CollektorVersion2ApiProvider.from(canteenApiBaseUrl, language);
|
|
393
393
|
default:
|
|
394
394
|
console.log(`${componentName}: Can't build api provider: ${canteenApiProvider}`)
|
|
395
395
|
return null;
|
|
@@ -61,7 +61,7 @@ function FlexMenuContextProvider({ children }) {
|
|
|
61
61
|
// return new AsistServerApiProvider.from(timetableApiBaseUrl, timetableApiUniversity, 'de');
|
|
62
62
|
// break;
|
|
63
63
|
case CollectorVersion2ProviderName:
|
|
64
|
-
return
|
|
64
|
+
return CollectorVersion2ApiProvider.from(flexMenuApiBaseUrl);
|
|
65
65
|
break;
|
|
66
66
|
default:
|
|
67
67
|
console.log(`${componentName}: Can't build api provider: ${flexMenuApiProvider}`)
|
|
@@ -72,7 +72,7 @@ function NewsContextProvider({ children }) {
|
|
|
72
72
|
switch (newsApiProvider?.toLowerCase()) {
|
|
73
73
|
case CollectorVersion2ProviderName:
|
|
74
74
|
console.debug(componentName, ': use collector v2 api');
|
|
75
|
-
return
|
|
75
|
+
return CollektorVersion2ApiProvider.from(newsApiBaseUrl, language);
|
|
76
76
|
default:
|
|
77
77
|
console.log(`${componentName}: Can't build api provider: ${newsApiProvider}`)
|
|
78
78
|
return null;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Add an alpha channel to a hex color, returning an rgba() string.
|
|
2
|
+
export const addAlpha = (hexColor, alpha) => {
|
|
3
|
+
const hex = hexColor.replace('#', '');
|
|
4
|
+
const r = parseInt(hex.substring(0, 2), 16);
|
|
5
|
+
const g = parseInt(hex.substring(2, 4), 16);
|
|
6
|
+
const b = parseInt(hex.substring(4, 6), 16);
|
|
7
|
+
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
|
|
8
|
+
};
|
|
@@ -83,6 +83,12 @@ const CustomIcon = createIconSet(glyphMap, 'openasist');
|
|
|
83
83
|
* This component handles the load of the icon font and
|
|
84
84
|
* provides a simple way to include these icons.
|
|
85
85
|
*
|
|
86
|
+
* Icon lookup precedence:
|
|
87
|
+
* 1. `iconSVG` prop (explicit React component)
|
|
88
|
+
* 2. `theme.icons[icon]` (per-app SVG registry)
|
|
89
|
+
* 3. `theme.AppIcons` (per-app font icon set)
|
|
90
|
+
* 4. library-default `CustomIcon` font icon set
|
|
91
|
+
*
|
|
86
92
|
* Parameters:
|
|
87
93
|
* - icon: Name (slug) of the icon
|
|
88
94
|
* - size: Size (as Number) of the icon
|
|
@@ -94,6 +100,7 @@ const CustomIcon = createIconSet(glyphMap, 'openasist');
|
|
|
94
100
|
function IconsOpenasist({ icon, iconSVG: IconSVG, size, color, accessibilityLabel, ...props }) {
|
|
95
101
|
const theme = useTheme();
|
|
96
102
|
const { AppIcons } = theme;
|
|
103
|
+
const ThemeIcon = theme.icons?.[icon];
|
|
97
104
|
|
|
98
105
|
const iconSize = size ?? 26;
|
|
99
106
|
const iconAriaLabel = props?.['aria-label'] ?? accessibilityLabel ?? null;
|
|
@@ -113,6 +120,14 @@ function IconsOpenasist({ icon, iconSVG: IconSVG, size, color, accessibilityLabe
|
|
|
113
120
|
height={iconSize}
|
|
114
121
|
/>
|
|
115
122
|
);
|
|
123
|
+
} else if (typeof ThemeIcon === 'function') {
|
|
124
|
+
return (
|
|
125
|
+
<ThemeIcon
|
|
126
|
+
{...iconProps}
|
|
127
|
+
width={iconSize}
|
|
128
|
+
height={iconSize}
|
|
129
|
+
/>
|
|
130
|
+
);
|
|
116
131
|
} else if (AppIcons) {
|
|
117
132
|
return (
|
|
118
133
|
<AppIcons
|
|
@@ -13,7 +13,13 @@
|
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
15
|
import React from 'react';
|
|
16
|
-
import
|
|
16
|
+
import {
|
|
17
|
+
getMessaging,
|
|
18
|
+
setBackgroundMessageHandler,
|
|
19
|
+
onMessage,
|
|
20
|
+
unregisterDeviceForRemoteMessages,
|
|
21
|
+
AuthorizationStatus,
|
|
22
|
+
} from '@react-native-firebase/messaging';
|
|
17
23
|
|
|
18
24
|
import notifee, { AndroidStyle, EventType } from '@notifee/react-native';
|
|
19
25
|
import { feedApi, RootNavigation, store, updateFeeds } from '../core';
|
|
@@ -44,7 +50,7 @@ export default class OpenASiSTNotifications {
|
|
|
44
50
|
* Important: This function must be called as soon as possible! (Before app initialization)
|
|
45
51
|
*/
|
|
46
52
|
initBackgroundHandler() {
|
|
47
|
-
|
|
53
|
+
setBackgroundMessageHandler(getMessaging(), async remoteMessage => {
|
|
48
54
|
await this.createNotification(remoteMessage);
|
|
49
55
|
});
|
|
50
56
|
|
|
@@ -61,7 +67,7 @@ export default class OpenASiSTNotifications {
|
|
|
61
67
|
await this.subscriberService.initializeSubscriber();
|
|
62
68
|
|
|
63
69
|
// Listen for new Messages while the app is in foreground
|
|
64
|
-
|
|
70
|
+
onMessage(getMessaging(), async remoteMessage => {
|
|
65
71
|
await this.createNotification(remoteMessage);
|
|
66
72
|
});
|
|
67
73
|
|
|
@@ -73,7 +79,7 @@ export default class OpenASiSTNotifications {
|
|
|
73
79
|
|
|
74
80
|
unregister() {
|
|
75
81
|
// Unregister the user device from firebase
|
|
76
|
-
|
|
82
|
+
unregisterDeviceForRemoteMessages(getMessaging()).then(() => {/* Unregistered */});
|
|
77
83
|
notifee.cancelAllNotifications().then(() => {/* Cancelled all notifications */});
|
|
78
84
|
}
|
|
79
85
|
|
|
@@ -128,8 +134,8 @@ export default class OpenASiSTNotifications {
|
|
|
128
134
|
});
|
|
129
135
|
|
|
130
136
|
const enabled =
|
|
131
|
-
authStatus ===
|
|
132
|
-
authStatus ===
|
|
137
|
+
authStatus === AuthorizationStatus.AUTHORIZED ||
|
|
138
|
+
authStatus === AuthorizationStatus.PROVISIONAL;
|
|
133
139
|
|
|
134
140
|
await notifee.requestPermission({
|
|
135
141
|
criticalAlert: true
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import uuid from 'react-native-uuid';
|
|
2
|
-
import
|
|
2
|
+
import {
|
|
3
|
+
getMessaging,
|
|
4
|
+
isDeviceRegisteredForRemoteMessages,
|
|
5
|
+
registerDeviceForRemoteMessages,
|
|
6
|
+
getToken,
|
|
7
|
+
onTokenRefresh,
|
|
8
|
+
} from '@react-native-firebase/messaging';
|
|
3
9
|
import debounce from 'lodash/debounce';
|
|
4
10
|
|
|
5
11
|
import { store } from '../../core';
|
|
@@ -32,8 +38,9 @@ export default class SubscriberService {
|
|
|
32
38
|
*/
|
|
33
39
|
async initializeSubscriber() {
|
|
34
40
|
this.subscriberId = this.getSubscriberId();
|
|
35
|
-
|
|
36
|
-
|
|
41
|
+
const messaging = getMessaging();
|
|
42
|
+
if(!isDeviceRegisteredForRemoteMessages(messaging)) {
|
|
43
|
+
await registerDeviceForRemoteMessages(messaging);
|
|
37
44
|
}
|
|
38
45
|
const token = await this.getFCMToken();
|
|
39
46
|
|
|
@@ -66,7 +73,7 @@ export default class SubscriberService {
|
|
|
66
73
|
* @returns {Promise<void>}
|
|
67
74
|
*/
|
|
68
75
|
async getFCMToken() {
|
|
69
|
-
return await
|
|
76
|
+
return await getToken(getMessaging());
|
|
70
77
|
}
|
|
71
78
|
|
|
72
79
|
|
|
@@ -92,7 +99,7 @@ export default class SubscriberService {
|
|
|
92
99
|
|
|
93
100
|
// Listen for Token updates
|
|
94
101
|
if(!skipRefresh) {
|
|
95
|
-
|
|
102
|
+
onTokenRefresh(getMessaging(), newToken => {
|
|
96
103
|
this.upsertSubscriber(newToken, true);
|
|
97
104
|
});
|
|
98
105
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@olea-bps/base",
|
|
3
|
-
"version": "1.0
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"description": "OLEA base library",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"repository": {
|
|
@@ -30,34 +30,34 @@
|
|
|
30
30
|
"@notifee/react-native": "^9.1.8",
|
|
31
31
|
"@novu/client": "^2.6.6",
|
|
32
32
|
"@react-native-async-storage/async-storage": "~2.2.0",
|
|
33
|
-
"@react-native-community/netinfo": "
|
|
34
|
-
"@react-native-firebase/app": "^
|
|
35
|
-
"@react-native-firebase/messaging": "^
|
|
33
|
+
"@react-native-community/netinfo": "12.0.1",
|
|
34
|
+
"@react-native-firebase/app": "^24.0.0",
|
|
35
|
+
"@react-native-firebase/messaging": "^24.0.0",
|
|
36
36
|
"@react-navigation/drawer": "^7.3.12",
|
|
37
37
|
"@react-navigation/native": "^7.1.9",
|
|
38
|
-
"expo-application": "~
|
|
39
|
-
"expo-auth-session": "~
|
|
40
|
-
"expo-crypto": "~
|
|
41
|
-
"expo-linear-gradient": "~
|
|
42
|
-
"expo-web-browser": "~
|
|
38
|
+
"expo-application": "~56.0.3",
|
|
39
|
+
"expo-auth-session": "~56.0.12",
|
|
40
|
+
"expo-crypto": "~56.0.4",
|
|
41
|
+
"expo-linear-gradient": "~56.0.4",
|
|
42
|
+
"expo-web-browser": "~56.0.5",
|
|
43
43
|
"jwt-decode": "4.0.0",
|
|
44
44
|
"moment": "^2.29.4",
|
|
45
45
|
"react-native-elements": "^3.4.3",
|
|
46
46
|
"react-native-modalbox": "^2.0.2",
|
|
47
|
-
"react-native-paper": "^5.
|
|
47
|
+
"react-native-paper": "^5.15.2",
|
|
48
48
|
"react-native-svg": "15.15.4",
|
|
49
49
|
"react-native-swipe-gestures": "^1.0.5",
|
|
50
50
|
"react-native-tab-view": "^4.1.3",
|
|
51
51
|
"react-native-uuid": "^2.0.3",
|
|
52
52
|
"react-native-vector-icons": "^10.2.0",
|
|
53
|
-
"react-native-webview": "13.16.
|
|
53
|
+
"react-native-webview": "13.16.1",
|
|
54
54
|
"react-redux": "^9.2.0",
|
|
55
55
|
"redux": "^4.0.5",
|
|
56
56
|
"redux-persist": "^6.0.0"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"react": "^19.0.0",
|
|
60
|
-
"react-native": "^0.
|
|
60
|
+
"react-native": "^0.85.0",
|
|
61
61
|
"react-native-paper": "^5.0.0",
|
|
62
62
|
"react-redux": "^9.2.0",
|
|
63
63
|
"redux": "^4.0.5"
|