@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.
Files changed (268) hide show
  1. package/components/AppBar/index.js +84 -0
  2. package/components/AppBar/styles.js +27 -0
  3. package/components/BookDetail/index.js +268 -0
  4. package/components/BookDetail/styles.js +124 -0
  5. package/components/ComponentJobsFilter/index.js +188 -0
  6. package/components/ComponentJobsFilter/styles.js +12 -0
  7. package/components/ConnectivityWarning/index.js +65 -0
  8. package/components/ConnectivityWarning/styles.js +19 -0
  9. package/components/ContactDetail/index.js +232 -0
  10. package/components/ContactDetail/styles.js +32 -0
  11. package/components/CourseDetail/index.js +357 -0
  12. package/components/CourseDetail/styles.js +59 -0
  13. package/components/CourseDetailDialog/index.js +169 -0
  14. package/components/CourseDetailDialog/styles.js +116 -0
  15. package/components/CourseInfo/index.js +219 -0
  16. package/components/CourseInfo/styles.js +40 -0
  17. package/components/DevelopmentDialog/index.js +214 -0
  18. package/components/DevelopmentDialog/styles.js +10 -0
  19. package/components/EventCodeInput/index.js +149 -0
  20. package/components/EventCodeInput/styles.js +108 -0
  21. package/components/FlexMenuEntry/index.js +84 -0
  22. package/components/FlexMenuEntry/styles.js +27 -0
  23. package/components/MainMenuEntry/index.js +88 -0
  24. package/components/MainMenuEntry/styles.js +28 -0
  25. package/components/MealItem/index.js +87 -0
  26. package/components/MealItem/styles.js +84 -0
  27. package/components/MensaMenu/index.js +305 -0
  28. package/components/MensaMenu/styles.js +94 -0
  29. package/components/MensaSlider/index.js +188 -0
  30. package/components/MensaSlider/styles.js +53 -0
  31. package/components/Modal/index.js +106 -0
  32. package/components/Modal/styles.js +8 -0
  33. package/components/NewsDetail/index.js +377 -0
  34. package/components/NewsDetail/styles.js +77 -0
  35. package/components/NewsList/index.js +120 -0
  36. package/components/NewsList/styles.js +19 -0
  37. package/components/NewsListItem/index.js +89 -0
  38. package/components/NewsListItem/styles.js +32 -0
  39. package/components/OtherCourses/index.js +152 -0
  40. package/components/OtherCourses/styles.js +10 -0
  41. package/components/PtsDeparture/index.js +140 -0
  42. package/components/PtsDeparture/styles.js +7 -0
  43. package/components/PtsStation/index.js +186 -0
  44. package/components/PtsStation/styles.js +47 -0
  45. package/components/QuickLinks/index.js +127 -0
  46. package/components/QuickLinks/styles.js +45 -0
  47. package/components/RoomDetail/index.js +281 -0
  48. package/components/RoomDetail/styles.js +56 -0
  49. package/components/ScaledImage/index.js +92 -0
  50. package/components/SearchResults/index.js +362 -0
  51. package/components/SearchResults/styles.js +59 -0
  52. package/components/SettingSection/index.js +54 -0
  53. package/components/SettingSection/styles.js +15 -0
  54. package/components/SettingsDialog/index.js +52 -0
  55. package/components/SettingsDialog/styles.js +12 -0
  56. package/components/SettingsDialogRadio/index.js +66 -0
  57. package/components/SettingsDialogRadio/styles.js +7 -0
  58. package/components/SettingsDialogSelect/index.js +73 -0
  59. package/components/SettingsDialogSelect/styles.js +7 -0
  60. package/components/TimetableCodeInput/index.js +205 -0
  61. package/components/TimetableCodeInput/styles.js +28 -0
  62. package/components/TimetableDay/index.js +252 -0
  63. package/components/TimetableDay/styles.js +103 -0
  64. package/components/TimetableEvent/index.js +163 -0
  65. package/components/TimetableEvent/styles.js +108 -0
  66. package/components/TimetableList/index.js +180 -0
  67. package/components/TimetableList/styles.js +106 -0
  68. package/components/TimetableMonth/index.js +156 -0
  69. package/components/TimetableMonth/styles.js +29 -0
  70. package/components/TimetableWeek/index.js +230 -0
  71. package/components/TimetableWeek/styles.js +58 -0
  72. package/components/TopNews/index.js +282 -0
  73. package/components/TopNews/styles.js +125 -0
  74. package/components/TopNewsHtwk/index.js +279 -0
  75. package/components/TopNewsHtwk/styles.js +142 -0
  76. package/components/WebView/index.js +108 -0
  77. package/components/WebView/styles.js +11 -0
  78. package/context/context-callmanager/TucCallManager.js +74 -0
  79. package/context/context-callmanager/index.js +128 -0
  80. package/context/context-canteen/AsistServerApiProvider.js +126 -0
  81. package/context/context-canteen/CollektorVersion2ApiProvider.js +100 -0
  82. package/context/context-canteen/index.js +692 -0
  83. package/context/context-connectivity/index.js +85 -0
  84. package/context/context-event/AsistServerClient.js +82 -0
  85. package/context/context-event/index.js +205 -0
  86. package/context/context-flex-menu/AsistServerApiProvider.js +0 -0
  87. package/context/context-flex-menu/CollectorVersion2ApiProvider.js +32 -0
  88. package/context/context-flex-menu/index.js +160 -0
  89. package/context/context-info-dialog/CollektorVersion2ApiProvider.js +53 -0
  90. package/context/context-info-dialog/ProviderErrors.js +22 -0
  91. package/context/context-info-dialog/index.js +190 -0
  92. package/context/context-mails/MailService.js +147 -0
  93. package/context/context-mails/TucUnseenApiProvider.js +65 -0
  94. package/context/context-mails/index.js +131 -0
  95. package/context/context-news/CollektorVersion2ApiProvider.js +68 -0
  96. package/context/context-news/index.js +155 -0
  97. package/context/context-public-transport-ticket/CollektorVersion2ApiProvider.js +45 -0
  98. package/context/context-public-transport-ticket/ProviderErrors.js +11 -0
  99. package/context/context-public-transport-ticket/index.js +175 -0
  100. package/context/context-timetable/CollectorVersion2ApiProvider.js +102 -0
  101. package/context/context-timetable/ProviderErrors.js +22 -0
  102. package/context/context-timetable/TimetableService.js +357 -0
  103. package/context/context-timetable/index.js +215 -0
  104. package/context/context-user/index.js +586 -0
  105. package/index.js +178 -0
  106. package/libraries/base-api-provider/hooks.js +24 -0
  107. package/libraries/base-api-provider/http-api-provider.js +168 -0
  108. package/libraries/base-api-provider/index.js +20 -0
  109. package/libraries/core/api/canteens.js +88 -0
  110. package/libraries/core/api/corona.js +45 -0
  111. package/libraries/core/api/courses.js +54 -0
  112. package/libraries/core/api/device.js +98 -0
  113. package/libraries/core/api/feed.js +144 -0
  114. package/libraries/core/api/feedback.js +123 -0
  115. package/libraries/core/api/jobs.js +48 -0
  116. package/libraries/core/api/library.js +67 -0
  117. package/libraries/core/api/lostfound.js +77 -0
  118. package/libraries/core/api/occupancy.js +44 -0
  119. package/libraries/core/api/officehours.js +25 -0
  120. package/libraries/core/api/poi.js +25 -0
  121. package/libraries/core/api/pts.js +68 -0
  122. package/libraries/core/api/rooms.js +31 -0
  123. package/libraries/core/api/survey.js +121 -0
  124. package/libraries/core/api/telephone.js +32 -0
  125. package/libraries/core/api/tucrooms.js +31 -0
  126. package/libraries/core/constants/actions.js +75 -0
  127. package/libraries/core/constants/api.js +146 -0
  128. package/libraries/core/constants/enums.js +5 -0
  129. package/libraries/core/helper/date.js +9 -0
  130. package/libraries/core/helper/format.helper.js +2 -0
  131. package/libraries/core/index.js +60 -0
  132. package/libraries/core/redux/actions/notifications.js +6 -0
  133. package/libraries/core/redux/actions/setting.js +75 -0
  134. package/libraries/core/redux/actions/state.js +74 -0
  135. package/libraries/core/redux/asyncDispatch.js +27 -0
  136. package/libraries/core/redux/reducers/api.js +190 -0
  137. package/libraries/core/redux/reducers/index.js +32 -0
  138. package/libraries/core/redux/reducers/notifications.js +16 -0
  139. package/libraries/core/redux/reducers/setting.js +99 -0
  140. package/libraries/core/redux/reducers/state.js +122 -0
  141. package/libraries/core/redux/selectors.js +123 -0
  142. package/libraries/core/redux/store.js +40 -0
  143. package/libraries/core/services/data.js +96 -0
  144. package/libraries/core/services/root-navigation.js +36 -0
  145. package/libraries/core/services/search.js +175 -0
  146. package/libraries/core-plugins/enums/replaceTypes.js +53 -0
  147. package/libraries/core-plugins/index.js +21 -0
  148. package/libraries/core-plugins/redux/actions/plugin.js +13 -0
  149. package/libraries/core-plugins/redux/reducers/plugin.js +210 -0
  150. package/libraries/icons-openasist/index.js +143 -0
  151. package/libraries/notifications/index.js +268 -0
  152. package/libraries/notifications/services/subscriber.service.js +123 -0
  153. package/libraries/react-native-webview-autoheight/README.md +47 -0
  154. package/libraries/react-native-webview-autoheight/index.js +140 -0
  155. package/libraries/react-native-webview-autoheight/package.json +37 -0
  156. package/libraries/react-native-webview-autoheight/utils.js +268 -0
  157. package/libraries/redux-offline/.eslintignore +1 -0
  158. package/libraries/redux-offline/.github/ISSUE_TEMPLATE/redux-offline-core-issues-template.md +25 -0
  159. package/libraries/redux-offline/.prettierrc +6 -0
  160. package/libraries/redux-offline/LICENSE +21 -0
  161. package/libraries/redux-offline/README.md +133 -0
  162. package/libraries/redux-offline/flow-typed/npm/redux-logger_vx.x.x.js +109 -0
  163. package/libraries/redux-offline/flow-typed/npm/redux_v4.x.x.js +100 -0
  164. package/libraries/redux-offline/lib/actions.js +46 -0
  165. package/libraries/redux-offline/lib/config.js +15 -0
  166. package/libraries/redux-offline/lib/constants.js +17 -0
  167. package/libraries/redux-offline/lib/defaults/defaultCommit.js +11 -0
  168. package/libraries/redux-offline/lib/defaults/defaultRollback.js +11 -0
  169. package/libraries/redux-offline/lib/defaults/detectNetwork.js +33 -0
  170. package/libraries/redux-offline/lib/defaults/detectNetwork.native.js +211 -0
  171. package/libraries/redux-offline/lib/defaults/discard.js +18 -0
  172. package/libraries/redux-offline/lib/defaults/effect.js +87 -0
  173. package/libraries/redux-offline/lib/defaults/index.js +32 -0
  174. package/libraries/redux-offline/lib/defaults/offlineStateLens.js +24 -0
  175. package/libraries/redux-offline/lib/defaults/persist.js +9 -0
  176. package/libraries/redux-offline/lib/defaults/persist.native.js +17 -0
  177. package/libraries/redux-offline/lib/defaults/persistAutoRehydrate.js +8 -0
  178. package/libraries/redux-offline/lib/defaults/queue.js +27 -0
  179. package/libraries/redux-offline/lib/defaults/retry.js +29 -0
  180. package/libraries/redux-offline/lib/index.js +115 -0
  181. package/libraries/redux-offline/lib/middleware.js +56 -0
  182. package/libraries/redux-offline/lib/offlineActionTracker.js +43 -0
  183. package/libraries/redux-offline/lib/send.js +112 -0
  184. package/libraries/redux-offline/lib/types.js +3 -0
  185. package/libraries/redux-offline/lib/updater.js +111 -0
  186. package/libraries/redux-offline/package.json +69 -0
  187. package/libraries/redux-offline/src/__tests__/defaults/discard.js +22 -0
  188. package/libraries/redux-offline/src/__tests__/defaults/effect.js +118 -0
  189. package/libraries/redux-offline/src/__tests__/index.js +116 -0
  190. package/libraries/redux-offline/src/__tests__/middleware.js +185 -0
  191. package/libraries/redux-offline/src/__tests__/offlineActionTracker.js +54 -0
  192. package/libraries/redux-offline/src/__tests__/send.js +208 -0
  193. package/libraries/redux-offline/src/actions.js +36 -0
  194. package/libraries/redux-offline/src/config.js +9 -0
  195. package/libraries/redux-offline/src/constants.js +18 -0
  196. package/libraries/redux-offline/src/defaults/defaultCommit.js +7 -0
  197. package/libraries/redux-offline/src/defaults/defaultRollback.js +7 -0
  198. package/libraries/redux-offline/src/defaults/detectNetwork.js +16 -0
  199. package/libraries/redux-offline/src/defaults/detectNetwork.native.js +148 -0
  200. package/libraries/redux-offline/src/defaults/discard.js +19 -0
  201. package/libraries/redux-offline/src/defaults/effect.js +86 -0
  202. package/libraries/redux-offline/src/defaults/index.js +25 -0
  203. package/libraries/redux-offline/src/defaults/offlineStateLens.js +11 -0
  204. package/libraries/redux-offline/src/defaults/persist.js +4 -0
  205. package/libraries/redux-offline/src/defaults/persist.native.js +9 -0
  206. package/libraries/redux-offline/src/defaults/persistAutoRehydrate.js +4 -0
  207. package/libraries/redux-offline/src/defaults/queue.js +20 -0
  208. package/libraries/redux-offline/src/defaults/retry.js +18 -0
  209. package/libraries/redux-offline/src/index.js +138 -0
  210. package/libraries/redux-offline/src/middleware.js +52 -0
  211. package/libraries/redux-offline/src/offlineActionTracker.js +40 -0
  212. package/libraries/redux-offline/src/send.js +111 -0
  213. package/libraries/redux-offline/src/types.js +127 -0
  214. package/libraries/redux-offline/src/updater.js +141 -0
  215. package/libraries/redux-offline/typings.d.ts +150 -0
  216. package/libraries/redux-offline/yarn.lock +6460 -0
  217. package/libraries/stored-state/index.js +155 -0
  218. package/package.json +68 -0
  219. package/views/Callmanager/index.js +148 -0
  220. package/views/Callmanager/styles.js +62 -0
  221. package/views/Canteens/index.js +383 -0
  222. package/views/Canteens/styles.js +89 -0
  223. package/views/Dashboard/index.js +176 -0
  224. package/views/Dashboard/styles.js +16 -0
  225. package/views/DashboardHtwk/index.js +197 -0
  226. package/views/DashboardHtwk/styles.js +24 -0
  227. package/views/Event/index.js +373 -0
  228. package/views/Event/styles.js +63 -0
  229. package/views/FeedList/index.js +165 -0
  230. package/views/FeedList/styles.js +15 -0
  231. package/views/FeedNews/index.js +243 -0
  232. package/views/FeedNews/styles.js +32 -0
  233. package/views/Flexmenu/index.js +185 -0
  234. package/views/Flexmenu/styles.js +62 -0
  235. package/views/FlexmenuWebview/index.js +167 -0
  236. package/views/FlexmenuWebview/styles.js +16 -0
  237. package/views/Howhy/index.js +151 -0
  238. package/views/Howhy/styles.js +11 -0
  239. package/views/Jobs/index.js +217 -0
  240. package/views/Jobs/styles.js +41 -0
  241. package/views/MainMenu/index.js +283 -0
  242. package/views/MainMenu/styles.js +36 -0
  243. package/views/NewsTabbar/index.js +164 -0
  244. package/views/NewsTabbar/styles.js +27 -0
  245. package/views/Opal/index.js +136 -0
  246. package/views/Opal/styles.js +11 -0
  247. package/views/PublicTransportTicket/index.js +173 -0
  248. package/views/PublicTransportTicket/styles.js +17 -0
  249. package/views/Search/index.js +186 -0
  250. package/views/Search/styles.js +67 -0
  251. package/views/SettingsAccessibility/index.js +148 -0
  252. package/views/SettingsAccessibility/styles.js +13 -0
  253. package/views/SettingsAppInfo/index.js +86 -0
  254. package/views/SettingsAppInfo/styles.js +18 -0
  255. package/views/SettingsCanteens/index.js +249 -0
  256. package/views/SettingsCanteens/styles.js +33 -0
  257. package/views/SettingsGeneral/index.js +173 -0
  258. package/views/SettingsGeneral/styles.js +28 -0
  259. package/views/SettingsNotifications/index.js +204 -0
  260. package/views/SettingsNotifications/styles.js +38 -0
  261. package/views/SettingsUser/index.js +170 -0
  262. package/views/SettingsUser/styles.js +17 -0
  263. package/views/TimetableCalendar/index.js +387 -0
  264. package/views/TimetableCalendar/styles.js +121 -0
  265. package/views/TimetableList/index.js +402 -0
  266. package/views/TimetableList/styles.js +55 -0
  267. package/views/Webviews/index.js +158 -0
  268. package/views/Webviews/styles.js +11 -0
@@ -0,0 +1,62 @@
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
+ cardContent: {
16
+ justifyContent: 'center',
17
+ alignItems: 'flex-start'
18
+ },
19
+ cardTitle: {
20
+ flexWrap: 'wrap',
21
+ justifyContent: 'center',
22
+ fontSize: theme.fontSizes.l,
23
+ ...theme.fonts.light,
24
+ },
25
+ cardImage: {
26
+ justifyContent: 'center',
27
+ alignContent: 'center',
28
+ paddingRight: theme.paddings.default,
29
+ },
30
+ cardSubTitle: {
31
+ width: 250,
32
+ fontSize: theme.fontSizes.s,
33
+ ...theme.fonts.regular,
34
+ lineHeight: theme.lineHeights.xxs,
35
+ color: theme.colors.subtitle,
36
+ marginTop: theme.paddings.xsmall
37
+ },
38
+ title : {
39
+ fontSize: theme.fontSizes.title,
40
+ color: theme.colors.text,
41
+ textAlign: 'center',
42
+ marginTop: theme.paddings.default,
43
+ marginLeft: theme.paddings.default,
44
+ marginRight: theme.paddings.default,
45
+ },
46
+ subtitle : {
47
+ fontSize: theme.fontSizes.subtitle,
48
+ color: theme.colors.subtitle,
49
+ textAlign: 'center',
50
+ marginTop: theme.paddings.default,
51
+ marginLeft: theme.paddings.default,
52
+ marginRight: theme.paddings.default,
53
+ },
54
+ containerErrorMsg: {
55
+ flex: 1,
56
+ justifyContent: 'center',
57
+ alignContent: 'center',
58
+ alignItems: 'center',
59
+ margin: theme.paddings.default,
60
+ },
61
+ }
62
+ };
@@ -0,0 +1,167 @@
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, useState, useCallback, useRef } from 'react';
16
+ import {
17
+ StyleSheet,
18
+ SafeAreaView,
19
+ ActivityIndicator,
20
+ BackHandler,
21
+ Platform,
22
+ } from 'react-native';
23
+
24
+ import { Appbar, useTheme } from "react-native-paper";
25
+ import { useTranslation } from "react-i18next";
26
+ import { useFocusEffect } from '@react-navigation/native';
27
+ import { WebView } from 'react-native-webview';
28
+
29
+ import AppbarComponent from '../../components/AppBar';
30
+ import IconsOpenasist from '../../libraries/icons-openasist';
31
+
32
+ import componentStyles from "./styles";
33
+
34
+ /**
35
+ * Corona Info View
36
+ *
37
+ * The home screen of the app. Shows different informations like the top news, weather,
38
+ * current mensa menus and informations of the next course (if the student has imported his timtetable)
39
+ *
40
+ * Parameters:
41
+ * - none
42
+ *
43
+ * Navigation-Parameters:
44
+ * - none
45
+ */
46
+ export default function FlexMenuWebView({ route, ...props }) {
47
+ const theme = useTheme();
48
+ const { colors, themeStyles } = theme;
49
+ const { t } = useTranslation();
50
+ const flexMenuEntry = route?.params?.item ?? props?.item;
51
+
52
+ const webviewURL = route?.params?.url ?? props?.url;
53
+ const webviewTitle = flexMenuEntry.title;
54
+
55
+ const webview = useRef(null);
56
+ const [webviewCanGoBack, setWebviewCanGoBack] = useState();
57
+
58
+ /**
59
+ * Erstellen einer Liste von erlauben Hosts, die in der Webview verwendet werden dürfen.
60
+ * In der Liste ist nur ein Host, welcher aus der anzuzeigenden URL extrahiert wird.
61
+ *
62
+ * Unter iOS wird der `undefined`-Wert verwendet.
63
+ * Wird in der Webseite eine Ressource von einem anderem Host eingebunden, öffnet es die Ressource im Browser, weil der Dritthost nicht erlaubt ist.
64
+ * Somit führen zum Beispiel eingebundene Youtube-Videos zu einem öffnen des Videos im Browser.
65
+ *
66
+ * @type {string[]|undefined}
67
+ */
68
+ const webviewOriginWhitelist = useMemo(
69
+ () => {
70
+ // URL-String in URL-Instanze konvertieren
71
+ const url = new URL(webviewURL);
72
+ // Host/Origin aus URL extrahieren
73
+ const webviewURLOrigin = url.origin;
74
+
75
+ // Auswahl das Rückgabewerted abhängig vond der Plattform
76
+ // Standartmäßig wird eine Liste mit dem Host der URL zurückgegeben
77
+ // Unter iOS wird undefined zurückgegeben
78
+ return Platform.select({
79
+ default: [webviewURLOrigin],
80
+ ios: undefined,
81
+ });
82
+ },
83
+ [webviewURL]
84
+ );
85
+
86
+ // Styles of this component
87
+ const styles = useMemo(
88
+ () => StyleSheet.create(componentStyles(theme)),
89
+ [theme]
90
+ )
91
+
92
+ useFocusEffect(
93
+ useCallback(
94
+ () => {
95
+ const onBackPress = webviewCanGoBack && webview?.current
96
+ ? () => {
97
+ webview?.current?.goBack();
98
+ return true;
99
+ }
100
+ : () => {
101
+ props?.navigation?.goBack();
102
+ return true;
103
+ }
104
+
105
+ const subscription = BackHandler.addEventListener(
106
+ 'hardwareBackPress',
107
+ onBackPress
108
+ );
109
+
110
+ return () => subscription.remove();
111
+ },
112
+ [webviewCanGoBack]
113
+ )
114
+ );
115
+
116
+ return (
117
+ <SafeAreaView style={[styles.container, themeStyles.appSafeAreaContainer]}>
118
+ <AppbarComponent {...props}
119
+ title={t(webviewTitle)}
120
+ leftAction={
121
+ <Appbar.Action
122
+ icon={props => <IconsOpenasist {...props} icon={'back'} color={colors.primaryText} />}
123
+ onPress={
124
+ webviewCanGoBack
125
+ ? webview?.current?.goBack
126
+ : props?.navigation?.goBack
127
+ }
128
+ accessible={true}
129
+ accessibilityLabel={
130
+ webviewCanGoBack
131
+ ? t('accessibility:appbar.navigateBack')
132
+ : t('accessibility:appbar.back')
133
+ }
134
+ />
135
+ }
136
+ rightAction={
137
+ <Appbar.Action
138
+ icon="refresh"
139
+ onPress={webview?.current?.reload}
140
+ accessible={true}
141
+ accessibilityLabel={t('accessibility:appbar.reload')}
142
+ />
143
+ }
144
+ />
145
+ <WebView
146
+ ref={webview}
147
+ source={{ uri: webviewURL }}
148
+ startInLoadingState={true}
149
+ allowsFullscreenVideo={true}
150
+ allowsInlineMediaPlayback={true}
151
+ originWhitelist={webviewOriginWhitelist}
152
+ renderLoading={
153
+ () =>
154
+ <ActivityIndicator
155
+ style={styles.activity}
156
+ size='large'
157
+ color={colors.loadingIndicator}
158
+ />
159
+ }
160
+ onLoad={
161
+ syntheticEvent =>
162
+ setWebviewCanGoBack(syntheticEvent?.nativeEvent?.canGoBack ?? false)
163
+ }
164
+ />
165
+ </SafeAreaView>
166
+ );
167
+ }
@@ -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
+ };
@@ -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 AppbarComponent from '../../components/AppBar';
24
+ import IconsOpenasist from '../../libraries/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
+ };
@@ -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 AppbarComponent from '../../components/AppBar';
34
+ import IconsOpenasist from '../../libraries/icons-openasist';
35
+ import { useLanguage, useStagingServer } from '../../libraries/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
+ }
@@ -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
+ };