@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.
- package/Callmanager/index.js +148 -0
- package/Callmanager/styles.js +62 -0
- package/Canteens/index.js +383 -0
- package/Canteens/styles.js +89 -0
- package/Dashboard/index.js +176 -0
- package/Dashboard/styles.js +16 -0
- package/DashboardHtwk/index.js +197 -0
- package/DashboardHtwk/styles.js +24 -0
- package/Event/index.js +369 -0
- package/Event/styles.js +63 -0
- package/FeedList/index.js +165 -0
- package/FeedList/styles.js +15 -0
- package/FeedNews/index.js +243 -0
- package/FeedNews/styles.js +32 -0
- package/Flexmenu/index.js +185 -0
- package/Flexmenu/styles.js +62 -0
- package/FlexmenuWebview/index.js +167 -0
- package/FlexmenuWebview/styles.js +16 -0
- package/Howhy/index.js +151 -0
- package/Howhy/styles.js +11 -0
- package/Jobs/index.js +217 -0
- package/Jobs/styles.js +41 -0
- package/MainMenu/index.js +329 -0
- package/MainMenu/styles.js +36 -0
- package/NewsTabbar/index.js +164 -0
- package/NewsTabbar/styles.js +27 -0
- package/Opal/index.js +136 -0
- package/Opal/styles.js +11 -0
- package/PublicTransportTicket/index.js +173 -0
- package/PublicTransportTicket/styles.js +17 -0
- package/Search/index.js +186 -0
- package/Search/styles.js +67 -0
- package/SettingsAccessibility/index.js +148 -0
- package/SettingsAccessibility/styles.js +13 -0
- package/SettingsAppInfo/index.js +86 -0
- package/SettingsAppInfo/styles.js +18 -0
- package/SettingsCanteens/index.js +249 -0
- package/SettingsCanteens/styles.js +33 -0
- package/SettingsGeneral/index.js +173 -0
- package/SettingsGeneral/styles.js +28 -0
- package/SettingsNotifications/index.js +204 -0
- package/SettingsNotifications/styles.js +38 -0
- package/SettingsUser/index.js +170 -0
- package/SettingsUser/styles.js +17 -0
- package/TimetableCalendar/index.js +322 -0
- package/TimetableCalendar/styles.js +117 -0
- package/TimetableList/index.js +397 -0
- package/TimetableList/styles.js +55 -0
- package/Webviews/index.js +158 -0
- package/Webviews/styles.js +11 -0
- package/index.js +25 -0
- package/package.json +41 -0
|
@@ -0,0 +1,176 @@
|
|
|
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, useCallback } from 'react';
|
|
16
|
+
import {
|
|
17
|
+
Animated,
|
|
18
|
+
StyleSheet,
|
|
19
|
+
View,
|
|
20
|
+
RefreshControl,
|
|
21
|
+
SafeAreaView,
|
|
22
|
+
useAnimatedValue,
|
|
23
|
+
} from 'react-native';
|
|
24
|
+
|
|
25
|
+
import { connect } from 'react-redux';
|
|
26
|
+
import { Appbar, Button, Dialog, Portal, useTheme } from 'react-native-paper';
|
|
27
|
+
import { useTranslation } from 'react-i18next';
|
|
28
|
+
import { useFocusEffect } from '@react-navigation/native';
|
|
29
|
+
import Markdown from 'react-native-markdown-display';
|
|
30
|
+
|
|
31
|
+
import { onUpdateRefreshing, DataService } from '@olea-bps/core';
|
|
32
|
+
import { TopNews as TopNewsComponent } from '@olea-bps/components';
|
|
33
|
+
import { QuickLinks as QuickLinksComponent } from '@olea-bps/components';
|
|
34
|
+
import { MensaSlider as MensaSliderCompnent } from '@olea-bps/components';
|
|
35
|
+
import { CourseInfo as CourseInfoCompnent } from '@olea-bps/components';
|
|
36
|
+
import { usePendingInfos } from '@olea-bps/context-info-dialog';
|
|
37
|
+
|
|
38
|
+
import componentStyles from './styles';
|
|
39
|
+
|
|
40
|
+
export const scrollRangeForAnimation = 160;
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Dashboard View
|
|
44
|
+
*
|
|
45
|
+
* The home screen of the app. Shows different informations like the top news, weather,
|
|
46
|
+
* current mensa menus and informations of the next course (if the student has imported his timtetable)
|
|
47
|
+
*
|
|
48
|
+
* Parameters:
|
|
49
|
+
* - none
|
|
50
|
+
*
|
|
51
|
+
* Navigation-Parameters:
|
|
52
|
+
* - none
|
|
53
|
+
*/
|
|
54
|
+
function DashboardView(props) {
|
|
55
|
+
const componentName = DashboardView.name;
|
|
56
|
+
const theme = useTheme();
|
|
57
|
+
const { t } = useTranslation();
|
|
58
|
+
const { themeStyles } = theme;
|
|
59
|
+
const [pendingInfos, setInfoDisplayed, refreshInfos] = usePendingInfos();
|
|
60
|
+
const pendingInfo = pendingInfos?.[0];
|
|
61
|
+
const hasNextPendingInfo = (pendingInfos?.length ?? 0) > 1
|
|
62
|
+
|
|
63
|
+
// Generate styles. Will be generated only if not present or the theme property changes.
|
|
64
|
+
const styles = useMemo(
|
|
65
|
+
() => StyleSheet.create(componentStyles(theme)),
|
|
66
|
+
[theme]
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
const dataService = useMemo(
|
|
70
|
+
() => new DataService,
|
|
71
|
+
[]
|
|
72
|
+
);
|
|
73
|
+
|
|
74
|
+
useFocusEffect(
|
|
75
|
+
useCallback(
|
|
76
|
+
() => {
|
|
77
|
+
refreshInfos();
|
|
78
|
+
},
|
|
79
|
+
[refreshInfos]
|
|
80
|
+
)
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const scrollY = useAnimatedValue(0);
|
|
84
|
+
|
|
85
|
+
const headerTranslate = scrollY.interpolate({
|
|
86
|
+
inputRange: [0, scrollRangeForAnimation],
|
|
87
|
+
outputRange: [0, 1],
|
|
88
|
+
extrapolate: 'clamp',
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
console.debug(componentName, ':', 'pending info', ':', pendingInfo);
|
|
92
|
+
|
|
93
|
+
return (
|
|
94
|
+
<SafeAreaView style={[styles.container, themeStyles.appSafeAreaContainer]}>
|
|
95
|
+
<Appbar.Header style={{ elevation: 0 }} statusBarHeight={0}>
|
|
96
|
+
<Appbar.Content title={t('home:title')} titleStyle={styles.titleStyle} />
|
|
97
|
+
</Appbar.Header>
|
|
98
|
+
<Animated.ScrollView
|
|
99
|
+
style={styles.container}
|
|
100
|
+
contentContainerStyle={styles.contentContainer}
|
|
101
|
+
scrollEventThrottle={2}
|
|
102
|
+
onScroll={
|
|
103
|
+
Animated.event(
|
|
104
|
+
[
|
|
105
|
+
{
|
|
106
|
+
nativeEvent: { contentOffset: { y: scrollY } },
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
{
|
|
110
|
+
useNativeDriver: true,
|
|
111
|
+
},
|
|
112
|
+
)
|
|
113
|
+
}
|
|
114
|
+
refreshControl={
|
|
115
|
+
<RefreshControl
|
|
116
|
+
refreshing={props.refreshing}
|
|
117
|
+
onRefresh={() => {
|
|
118
|
+
props.onUpdateRefreshing(true);
|
|
119
|
+
dataService.refresh();
|
|
120
|
+
}}
|
|
121
|
+
/>
|
|
122
|
+
}>
|
|
123
|
+
<View>
|
|
124
|
+
<TopNewsComponent {...props} animationRange={headerTranslate} />
|
|
125
|
+
<QuickLinksComponent {...props} />
|
|
126
|
+
<MensaSliderCompnent {...props} />
|
|
127
|
+
<CourseInfoCompnent {...props} />
|
|
128
|
+
</View>
|
|
129
|
+
</Animated.ScrollView>
|
|
130
|
+
<Portal>
|
|
131
|
+
<Dialog
|
|
132
|
+
visible={
|
|
133
|
+
pendingInfo === undefined
|
|
134
|
+
? false
|
|
135
|
+
: true
|
|
136
|
+
}
|
|
137
|
+
dismissable={false}
|
|
138
|
+
>
|
|
139
|
+
<Dialog.Title>{pendingInfo?.title ?? 'Info'}</Dialog.Title>
|
|
140
|
+
<Dialog.Content>
|
|
141
|
+
{
|
|
142
|
+
pendingInfo
|
|
143
|
+
? <Markdown>
|
|
144
|
+
{pendingInfo?.message}
|
|
145
|
+
</Markdown>
|
|
146
|
+
: null
|
|
147
|
+
}
|
|
148
|
+
</Dialog.Content>
|
|
149
|
+
<Dialog.Actions>
|
|
150
|
+
<Button onPress={() => setInfoDisplayed(pendingInfo?.id)}>
|
|
151
|
+
{
|
|
152
|
+
hasNextPendingInfo
|
|
153
|
+
? 'Next'
|
|
154
|
+
: 'Ok'
|
|
155
|
+
}
|
|
156
|
+
</Button>
|
|
157
|
+
</Dialog.Actions>
|
|
158
|
+
</Dialog>
|
|
159
|
+
</Portal>
|
|
160
|
+
</SafeAreaView>
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const mapStateToProps = state => {
|
|
165
|
+
return {
|
|
166
|
+
pluginComponent: state.pluginReducer.dashboard.component,
|
|
167
|
+
pluginStyles: state.pluginReducer.dashboard.styles,
|
|
168
|
+
view: state.stateReducer.view,
|
|
169
|
+
feedItems: state.stateReducer.feedItems,
|
|
170
|
+
feeds: state.stateReducer.feeds,
|
|
171
|
+
refreshing: state.stateReducer.refreshing,
|
|
172
|
+
settings: state.settingReducer
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
export default connect(mapStateToProps, { onUpdateRefreshing })(DashboardView)
|
|
@@ -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,197 @@
|
|
|
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 {
|
|
17
|
+
Animated,
|
|
18
|
+
StyleSheet,
|
|
19
|
+
View,
|
|
20
|
+
RefreshControl,
|
|
21
|
+
SafeAreaView
|
|
22
|
+
} from 'react-native';
|
|
23
|
+
import {connect} from 'react-redux'
|
|
24
|
+
import { withTheme } from "react-native-paper";
|
|
25
|
+
import {withTranslation} from "react-i18next";
|
|
26
|
+
|
|
27
|
+
import merge from 'lodash/merge';
|
|
28
|
+
|
|
29
|
+
import {onUpdateRefreshing, DataService} from '@olea-bps/core';
|
|
30
|
+
import { TopNewsHtwk as TopNewsComponent } from '@olea-bps/components';
|
|
31
|
+
import { MensaSlider as MensaSliderCompnent } from '@olea-bps/components';
|
|
32
|
+
import { CourseInfo as CourseInfoCompnent } from '@olea-bps/components';
|
|
33
|
+
import { QuickLinks as QuickLinksComponent } from '@olea-bps/components'
|
|
34
|
+
|
|
35
|
+
import componentStyles from "./styles"
|
|
36
|
+
export const scrollRangeForAnimation = 160;
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Dashboard View
|
|
41
|
+
*
|
|
42
|
+
* The home screen of the app. Shows different informations like the top news, weather,
|
|
43
|
+
* current mensa menus and informations of the next course (if the student has imported his timtetable)
|
|
44
|
+
*
|
|
45
|
+
* Parameters:
|
|
46
|
+
* - none
|
|
47
|
+
*
|
|
48
|
+
* Navigation-Parameters:
|
|
49
|
+
* - none
|
|
50
|
+
*/
|
|
51
|
+
class DashboardView extends React.Component {
|
|
52
|
+
static navigationOptions = {
|
|
53
|
+
header: null
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
// Styles of this component
|
|
57
|
+
styles;
|
|
58
|
+
|
|
59
|
+
dataService = null;
|
|
60
|
+
_scrollView = null;
|
|
61
|
+
|
|
62
|
+
|
|
63
|
+
constructor(props) {
|
|
64
|
+
super(props);
|
|
65
|
+
|
|
66
|
+
// ------------------------------------------------------------------------
|
|
67
|
+
// PLUGIN FUNCTIONALITY
|
|
68
|
+
// ------------------------------------------------------------------------
|
|
69
|
+
|
|
70
|
+
const { pluginStyles,theme } = this.props;
|
|
71
|
+
this.styles = componentStyles(theme);
|
|
72
|
+
|
|
73
|
+
if(pluginStyles) {
|
|
74
|
+
this.styles = merge(this.styles, pluginStyles);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
this.styles = StyleSheet.create(this.styles);
|
|
78
|
+
|
|
79
|
+
// ------------------------------------------------------------------------
|
|
80
|
+
|
|
81
|
+
this.dataService = new DataService();
|
|
82
|
+
this.props.onUpdateRefreshing(false);
|
|
83
|
+
|
|
84
|
+
this.state = {
|
|
85
|
+
scrollY: new Animated.Value(0)
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* User has dragged down the view to update the informations
|
|
91
|
+
*
|
|
92
|
+
* @private
|
|
93
|
+
*/
|
|
94
|
+
_onRefresh = () => {
|
|
95
|
+
this.props.onUpdateRefreshing(true);
|
|
96
|
+
this.dataService.refresh();
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* User has scrolled down. If the header animation isn't fully finished,
|
|
101
|
+
* scroll up or down (depends on how far the user has scrolled) to finish the animation.
|
|
102
|
+
* This prevents that the top view looks like its stuck.
|
|
103
|
+
*
|
|
104
|
+
* @param event
|
|
105
|
+
*
|
|
106
|
+
* @private
|
|
107
|
+
*/
|
|
108
|
+
_onScrollEndSnapToEdge = event => {
|
|
109
|
+
/* TODO Disabled at the moment. On smaller devices the user isn't able to
|
|
110
|
+
use the course component because of the scroll back
|
|
111
|
+
|
|
112
|
+
const y = event.nativeEvent.contentOffset.y;
|
|
113
|
+
if (0 < y && y < this._scrollRangeForAnimation / 2) {
|
|
114
|
+
if (this._scrollView) {
|
|
115
|
+
this._scrollView.scrollTo({y: 0});
|
|
116
|
+
}
|
|
117
|
+
} else if (this._scrollRangeForAnimation / 2 <= y && y < this._scrollRangeForAnimation) {
|
|
118
|
+
if (this._scrollView) {
|
|
119
|
+
this._scrollView.scrollTo({y: this._scrollRangeForAnimation});
|
|
120
|
+
}
|
|
121
|
+
}*/
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
render() {
|
|
125
|
+
// ------------------------------------------------------------------------
|
|
126
|
+
// PLUGIN FUNCTIONALITY
|
|
127
|
+
// ------------------------------------------------------------------------
|
|
128
|
+
const PluginComponent = this.props.pluginComponent;
|
|
129
|
+
if (PluginComponent) {
|
|
130
|
+
return <PluginComponent />;
|
|
131
|
+
}
|
|
132
|
+
// ------------------------------------------------------------------------
|
|
133
|
+
|
|
134
|
+
const { t } = this.props;
|
|
135
|
+
const { themeStyles } = this.props.theme;
|
|
136
|
+
|
|
137
|
+
const scrollY = Animated.add(
|
|
138
|
+
this.state.scrollY,
|
|
139
|
+
0,
|
|
140
|
+
);
|
|
141
|
+
const headerTranslate = scrollY.interpolate({
|
|
142
|
+
inputRange: [0, scrollRangeForAnimation],
|
|
143
|
+
outputRange: [0, 1],
|
|
144
|
+
extrapolate: 'clamp',
|
|
145
|
+
});
|
|
146
|
+
|
|
147
|
+
return (
|
|
148
|
+
<SafeAreaView style={[this.styles.container, themeStyles.appSafeAreaContainer]}>
|
|
149
|
+
<Animated.ScrollView
|
|
150
|
+
ref={scrollView => {
|
|
151
|
+
this._scrollView = scrollView ? scrollView._component : null;
|
|
152
|
+
}}
|
|
153
|
+
style={this.styles.container}
|
|
154
|
+
contentContainerStyle={this.styles.contentContainer}
|
|
155
|
+
scrollEventThrottle={2}
|
|
156
|
+
onScrollEndDrag={this._onScrollEndSnapToEdge}
|
|
157
|
+
onMomentumScrollEnd={this._onScrollEndSnapToEdge}
|
|
158
|
+
onScroll={Animated.event(
|
|
159
|
+
[
|
|
160
|
+
{
|
|
161
|
+
nativeEvent: {contentOffset: {y: this.state.scrollY}},
|
|
162
|
+
},
|
|
163
|
+
],
|
|
164
|
+
{
|
|
165
|
+
useNativeDriver: true,
|
|
166
|
+
}
|
|
167
|
+
)}
|
|
168
|
+
refreshControl={
|
|
169
|
+
<RefreshControl
|
|
170
|
+
refreshing={this.props.refreshing}
|
|
171
|
+
onRefresh={this._onRefresh}
|
|
172
|
+
/>
|
|
173
|
+
}>
|
|
174
|
+
<View>
|
|
175
|
+
<TopNewsComponent {...this.props} animationRange={headerTranslate}/>
|
|
176
|
+
<QuickLinksComponent {...this.props} />
|
|
177
|
+
<MensaSliderCompnent {...this.props} />
|
|
178
|
+
<CourseInfoCompnent {...this.props} />
|
|
179
|
+
</View>
|
|
180
|
+
</Animated.ScrollView>
|
|
181
|
+
</SafeAreaView>
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
const mapStateToProps = state => {
|
|
187
|
+
return {
|
|
188
|
+
pluginComponent: state.pluginReducer.dashboard.component,
|
|
189
|
+
pluginStyles: state.pluginReducer.dashboard.styles,
|
|
190
|
+
view : state.stateReducer.view,
|
|
191
|
+
feedItems: state.stateReducer.feedItems,
|
|
192
|
+
feeds: state.stateReducer.feeds,
|
|
193
|
+
refreshing: state.stateReducer.refreshing
|
|
194
|
+
};
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
export default connect(mapStateToProps, {onUpdateRefreshing})(withTranslation()(withTheme(DashboardView)))
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import {Dimensions} from 'react-native';
|
|
2
|
+
|
|
3
|
+
export default function(theme) {
|
|
4
|
+
const width = Dimensions.get('window').width;
|
|
5
|
+
return {
|
|
6
|
+
container: {
|
|
7
|
+
flex: 1,
|
|
8
|
+
backgroundColor: theme.colors.background,
|
|
9
|
+
},
|
|
10
|
+
contentContainer: {
|
|
11
|
+
paddingTop: 0
|
|
12
|
+
},
|
|
13
|
+
titleStyle: {
|
|
14
|
+
...theme.fonts.medium,
|
|
15
|
+
fontSize: theme.fontSizes.xxl,
|
|
16
|
+
alignSelf: 'center'
|
|
17
|
+
},
|
|
18
|
+
universityIcon: {
|
|
19
|
+
width: width * .40,
|
|
20
|
+
height: (width * .40) * .5625, // 56.25% = 16:9 Ratio
|
|
21
|
+
margin: theme.paddings.default
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|