Compare commits
9 commits
e693636464
...
9baaed9f6a
| Author | SHA1 | Date | |
|---|---|---|---|
| 9baaed9f6a | |||
| 2abed04a9d | |||
| b6b87b6c06 | |||
| 28168aacf8 | |||
| 912a30edc6 | |||
| fe4d9ffecf | |||
| c52fa3a7d8 | |||
| ac59121609 | |||
| ffb0b03b41 |
11 changed files with 232 additions and 81 deletions
|
|
@ -45,13 +45,13 @@
|
||||||
"react-native-gesture-handler": "~1.6.0",
|
"react-native-gesture-handler": "~1.6.0",
|
||||||
"react-native-image-modal": "^1.0.1",
|
"react-native-image-modal": "^1.0.1",
|
||||||
"react-native-modalize": "^1.3.6",
|
"react-native-modalize": "^1.3.6",
|
||||||
"react-native-paper": "^3.6.0",
|
"react-native-paper": "^3.8.0",
|
||||||
"react-native-reanimated": "~1.7.0",
|
"react-native-reanimated": "~1.7.0",
|
||||||
"react-native-render-html": "^4.1.2",
|
"react-native-render-html": "^4.1.2",
|
||||||
"react-native-safe-area-context": "0.7.3",
|
"react-native-safe-area-context": "0.7.3",
|
||||||
"react-native-screens": "~2.2.0",
|
"react-native-screens": "~2.2.0",
|
||||||
"react-native-webview": "8.1.1",
|
"react-native-webview": "8.1.1",
|
||||||
"react-navigation-collapsible": "^5.4.0",
|
"react-navigation-collapsible": "^5.5.0",
|
||||||
"react-navigation-header-buttons": "^3.0.5"
|
"react-navigation-header-buttons": "^3.0.5"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import {StyleSheet, View} from "react-native";
|
import {StyleSheet, View} from "react-native";
|
||||||
import {Button, IconButton, Surface, withTheme} from "react-native-paper";
|
import {FAB, IconButton, Surface, withTheme} from "react-native-paper";
|
||||||
import AutoHideComponent from "./AutoHideComponent";
|
import AutoHideComponent from "./AutoHideComponent";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
|
@ -41,8 +41,9 @@ class AnimatedBottomBar extends React.Component<Props, State> {
|
||||||
this.displayModeIcons[DISPLAY_MODES.MONTH] = "calendar-range";
|
this.displayModeIcons[DISPLAY_MODES.MONTH] = "calendar-range";
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldComponentUpdate(nextProps: Props) {
|
shouldComponentUpdate(nextProps: Props, nextState: State) {
|
||||||
return (nextProps.currentGroup !== this.props.currentGroup);
|
return (nextProps.currentGroup !== this.props.currentGroup)
|
||||||
|
|| (nextState.currentMode !== this.state.currentMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
onScroll = (event: Object) => {
|
onScroll = (event: Object) => {
|
||||||
|
|
@ -85,13 +86,13 @@ class AnimatedBottomBar extends React.Component<Props, State> {
|
||||||
style={{marginLeft: 5}}
|
style={{marginLeft: 5}}
|
||||||
onPress={() => this.props.onPress('today', undefined)}/>
|
onPress={() => this.props.onPress('today', undefined)}/>
|
||||||
</View>
|
</View>
|
||||||
<Button
|
<View style={styles.fabContainer}>
|
||||||
icon="book-variant"
|
<FAB
|
||||||
onPress={() => this.props.navigation.navigate('group-select')}
|
style={styles.fab}
|
||||||
style={{maxWidth: '40%'}}
|
icon="account-clock"
|
||||||
>
|
onPress={() => this.props.navigation.navigate('group-select')}
|
||||||
{this.props.currentGroup.replace(/_/g, " ")}
|
/>
|
||||||
</Button>
|
</View>
|
||||||
<View style={{flexDirection: 'row'}}>
|
<View style={{flexDirection: 'row'}}>
|
||||||
<IconButton
|
<IconButton
|
||||||
icon="chevron-left"
|
icon="chevron-left"
|
||||||
|
|
@ -117,13 +118,25 @@ const styles = StyleSheet.create({
|
||||||
width: '90%',
|
width: '90%',
|
||||||
},
|
},
|
||||||
surface: {
|
surface: {
|
||||||
|
position: 'relative',
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
justifyContent: 'space-between',
|
justifyContent: 'space-between',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
borderRadius: 50,
|
borderRadius: 50,
|
||||||
elevation: 2,
|
elevation: 2,
|
||||||
padding: 10,
|
},
|
||||||
paddingHorizontal: 20,
|
fabContainer: {
|
||||||
|
position: "absolute",
|
||||||
|
left: 0,
|
||||||
|
right: 0,
|
||||||
|
alignItems: "center",
|
||||||
|
width: '100%',
|
||||||
|
height: '100%'
|
||||||
|
},
|
||||||
|
fab: {
|
||||||
|
position: 'absolute',
|
||||||
|
alignSelf: 'center',
|
||||||
|
top: -10,
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,9 @@ type Props = {
|
||||||
route: Object,
|
route: Object,
|
||||||
errorCode: number,
|
errorCode: number,
|
||||||
onRefresh: Function,
|
onRefresh: Function,
|
||||||
|
icon: string,
|
||||||
|
message: string,
|
||||||
|
showRetryButton: boolean,
|
||||||
}
|
}
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
|
|
@ -27,6 +30,13 @@ class ErrorView extends React.PureComponent<Props, State> {
|
||||||
|
|
||||||
showLoginButton: boolean;
|
showLoginButton: boolean;
|
||||||
|
|
||||||
|
static defaultProps = {
|
||||||
|
errorCode: 0,
|
||||||
|
icon: '',
|
||||||
|
message: '',
|
||||||
|
showRetryButton: true,
|
||||||
|
}
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
refreshing: false,
|
refreshing: false,
|
||||||
};
|
};
|
||||||
|
|
@ -38,41 +48,47 @@ class ErrorView extends React.PureComponent<Props, State> {
|
||||||
|
|
||||||
generateMessage() {
|
generateMessage() {
|
||||||
this.showLoginButton = false;
|
this.showLoginButton = false;
|
||||||
switch (this.props.errorCode) {
|
if (this.props.errorCode !== 0) {
|
||||||
case ERROR_TYPE.BAD_CREDENTIALS:
|
switch (this.props.errorCode) {
|
||||||
this.message = i18n.t("errors.badCredentials");
|
case ERROR_TYPE.BAD_CREDENTIALS:
|
||||||
this.icon = "account-alert-outline";
|
this.message = i18n.t("errors.badCredentials");
|
||||||
break;
|
this.icon = "account-alert-outline";
|
||||||
case ERROR_TYPE.BAD_TOKEN:
|
break;
|
||||||
this.message = i18n.t("errors.badToken");
|
case ERROR_TYPE.BAD_TOKEN:
|
||||||
this.icon = "account-alert-outline";
|
this.message = i18n.t("errors.badToken");
|
||||||
this.showLoginButton = true;
|
this.icon = "account-alert-outline";
|
||||||
break;
|
this.showLoginButton = true;
|
||||||
case ERROR_TYPE.NO_CONSENT:
|
break;
|
||||||
this.message = i18n.t("errors.noConsent");
|
case ERROR_TYPE.NO_CONSENT:
|
||||||
this.icon = "account-remove-outline";
|
this.message = i18n.t("errors.noConsent");
|
||||||
break;
|
this.icon = "account-remove-outline";
|
||||||
case ERROR_TYPE.BAD_INPUT:
|
break;
|
||||||
this.message = i18n.t("errors.badInput");
|
case ERROR_TYPE.BAD_INPUT:
|
||||||
this.icon = "alert-circle-outline";
|
this.message = i18n.t("errors.badInput");
|
||||||
break;
|
this.icon = "alert-circle-outline";
|
||||||
case ERROR_TYPE.FORBIDDEN:
|
break;
|
||||||
this.message = i18n.t("errors.forbidden");
|
case ERROR_TYPE.FORBIDDEN:
|
||||||
this.icon = "lock";
|
this.message = i18n.t("errors.forbidden");
|
||||||
break;
|
this.icon = "lock";
|
||||||
case ERROR_TYPE.CONNECTION_ERROR:
|
break;
|
||||||
this.message = i18n.t("errors.connectionError");
|
case ERROR_TYPE.CONNECTION_ERROR:
|
||||||
this.icon = "access-point-network-off";
|
this.message = i18n.t("errors.connectionError");
|
||||||
break;
|
this.icon = "access-point-network-off";
|
||||||
case ERROR_TYPE.SERVER_ERROR:
|
break;
|
||||||
this.message = i18n.t("errors.serverError");
|
case ERROR_TYPE.SERVER_ERROR:
|
||||||
this.icon = "server-network-off";
|
this.message = i18n.t("errors.serverError");
|
||||||
break;
|
this.icon = "server-network-off";
|
||||||
default:
|
break;
|
||||||
this.message = i18n.t("errors.unknown");
|
default:
|
||||||
this.icon = "alert-circle-outline";
|
this.message = i18n.t("errors.unknown");
|
||||||
break;
|
this.icon = "alert-circle-outline";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.message = this.props.message;
|
||||||
|
this.icon = this.props.icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
getRetryButton() {
|
getRetryButton() {
|
||||||
|
|
@ -88,10 +104,11 @@ class ErrorView extends React.PureComponent<Props, State> {
|
||||||
|
|
||||||
goToLogin = () => {
|
goToLogin = () => {
|
||||||
this.props.navigation.navigate("login",
|
this.props.navigation.navigate("login",
|
||||||
{
|
{
|
||||||
screen: 'login',
|
screen: 'login',
|
||||||
params: {nextScreen: this.props.route.name}
|
params: {nextScreen: this.props.route.name}
|
||||||
})};
|
})
|
||||||
|
};
|
||||||
|
|
||||||
getLoginButton() {
|
getLoginButton() {
|
||||||
return <Button
|
return <Button
|
||||||
|
|
@ -124,9 +141,11 @@ class ErrorView extends React.PureComponent<Props, State> {
|
||||||
}}>
|
}}>
|
||||||
{this.message}
|
{this.message}
|
||||||
</Subheading>
|
</Subheading>
|
||||||
{this.showLoginButton
|
{this.props.showRetryButton
|
||||||
? this.getLoginButton()
|
? (this.showLoginButton
|
||||||
: this.getRetryButton()}
|
? this.getLoginButton()
|
||||||
|
: this.getRetryButton())
|
||||||
|
: null}
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
|
@ -148,6 +167,7 @@ const styles = StyleSheet.create({
|
||||||
},
|
},
|
||||||
subheading: {
|
subheading: {
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
|
paddingHorizontal: 20
|
||||||
},
|
},
|
||||||
button: {
|
button: {
|
||||||
marginTop: 10,
|
marginTop: 10,
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,18 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import {List} from 'react-native-paper';
|
import {IconButton, List, withTheme} from 'react-native-paper';
|
||||||
import {FlatList} from "react-native";
|
import {FlatList} from "react-native";
|
||||||
import {stringMatchQuery} from "../../utils/Search";
|
import {stringMatchQuery} from "../../utils/Search";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
item: Object,
|
item: Object,
|
||||||
onGroupPress: Function,
|
onGroupPress: Function,
|
||||||
|
onFavoritePress: Function,
|
||||||
currentSearchString: string,
|
currentSearchString: string,
|
||||||
|
favoriteNumber: number,
|
||||||
height: number,
|
height: number,
|
||||||
|
theme: Object,
|
||||||
}
|
}
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
|
|
@ -18,12 +21,13 @@ type State = {
|
||||||
|
|
||||||
const LIST_ITEM_HEIGHT = 64;
|
const LIST_ITEM_HEIGHT = 64;
|
||||||
|
|
||||||
const REPLACE_REGEX = /_/g;
|
class GroupListAccordion extends React.Component<Props, State> {
|
||||||
|
|
||||||
export default class GroupListAccordion extends React.Component<Props, State> {
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
state = {
|
this.state = {
|
||||||
expanded: false,
|
expanded: props.item.id === "0",
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
shouldComponentUpdate(nextProps: Props, nextSate: State) {
|
shouldComponentUpdate(nextProps: Props, nextSate: State) {
|
||||||
|
|
@ -31,28 +35,37 @@ export default class GroupListAccordion extends React.Component<Props, State> {
|
||||||
this.state.expanded = nextProps.currentSearchString.length > 0;
|
this.state.expanded = nextProps.currentSearchString.length > 0;
|
||||||
|
|
||||||
return (nextProps.currentSearchString !== this.props.currentSearchString)
|
return (nextProps.currentSearchString !== this.props.currentSearchString)
|
||||||
|| (nextSate.expanded !== this.state.expanded);
|
|| (nextSate.expanded !== this.state.expanded)
|
||||||
|
|| (nextProps.favoriteNumber !== this.props.favoriteNumber);
|
||||||
}
|
}
|
||||||
|
|
||||||
onPress = () => this.setState({expanded: !this.state.expanded});
|
onPress = () => this.setState({expanded: !this.state.expanded});
|
||||||
|
|
||||||
keyExtractor = (item: Object) => item.id.toString();
|
keyExtractor = (item: Object) => item.id.toString();
|
||||||
|
|
||||||
|
isItemFavorite(item: Object) {
|
||||||
|
return item.isFav !== undefined && item.isFav;
|
||||||
|
}
|
||||||
|
|
||||||
renderItem = ({item}: Object) => {
|
renderItem = ({item}: Object) => {
|
||||||
if (stringMatchQuery(item.name, this.props.currentSearchString)) {
|
if (stringMatchQuery(item.name, this.props.currentSearchString)) {
|
||||||
const onPress = () => this.props.onGroupPress(item);
|
const onPress = () => this.props.onGroupPress(item);
|
||||||
|
const onStartPress = () => this.props.onFavoritePress(item);
|
||||||
return (
|
return (
|
||||||
<List.Item
|
<List.Item
|
||||||
title={item.name.replace(REPLACE_REGEX, " ")}
|
title={item.name}
|
||||||
onPress={onPress}
|
onPress={onPress}
|
||||||
left={props =>
|
left={props =>
|
||||||
<List.Icon
|
<List.Icon
|
||||||
{...props}
|
{...props}
|
||||||
icon={"chevron-right"}/>}
|
icon={"chevron-right"}/>}
|
||||||
right={props =>
|
right={props =>
|
||||||
<List.Icon
|
<IconButton
|
||||||
{...props}
|
{...props}
|
||||||
icon={"star"}/>}
|
icon={"star"}
|
||||||
|
onPress={onStartPress}
|
||||||
|
color={this.isItemFavorite(item) ? this.props.theme.colors.tetrisScore : props.color}
|
||||||
|
/>}
|
||||||
style={{
|
style={{
|
||||||
height: LIST_ITEM_HEIGHT,
|
height: LIST_ITEM_HEIGHT,
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
|
|
@ -76,6 +89,14 @@ export default class GroupListAccordion extends React.Component<Props, State> {
|
||||||
height: this.props.height,
|
height: this.props.height,
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
}}
|
}}
|
||||||
|
left={props =>
|
||||||
|
item.id === "0"
|
||||||
|
? <List.Icon
|
||||||
|
{...props}
|
||||||
|
icon={"star"}
|
||||||
|
color={this.props.theme.colors.tetrisScore}
|
||||||
|
/>
|
||||||
|
: null}
|
||||||
>
|
>
|
||||||
{/*$FlowFixMe*/}
|
{/*$FlowFixMe*/}
|
||||||
<FlatList
|
<FlatList
|
||||||
|
|
@ -91,4 +112,6 @@ export default class GroupListAccordion extends React.Component<Props, State> {
|
||||||
</List.Accordion>
|
</List.Accordion>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default withTheme(GroupListAccordion)
|
||||||
|
|
@ -84,6 +84,11 @@ export default class AsyncStorageManager {
|
||||||
default: '',
|
default: '',
|
||||||
current: '',
|
current: '',
|
||||||
},
|
},
|
||||||
|
planexFavoriteGroups: {
|
||||||
|
key: 'planexFavoriteGroups',
|
||||||
|
default: '[]',
|
||||||
|
current: '',
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
|
|
@ -58,4 +58,8 @@ export default class DateManager {
|
||||||
return this.daysOfWeek[date.getDay()] + " " + date.getDate() + " " + this.monthsOfYear[date.getMonth()] + " " + date.getFullYear();
|
return this.daysOfWeek[date.getDay()] + " " + date.getDate() + " " + this.monthsOfYear[date.getMonth()] + " " + date.getFullYear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static isWeekend(date: Date) {
|
||||||
|
return date.getDay() === 6 || date.getDay() === 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -291,6 +291,9 @@ function PlanexStackComponent() {
|
||||||
options={({navigation}) => {
|
options={({navigation}) => {
|
||||||
return {
|
return {
|
||||||
title: 'GroupSelectionScreen',
|
title: 'GroupSelectionScreen',
|
||||||
|
headerStyle: {
|
||||||
|
backgroundColor: colors.surface,
|
||||||
|
},
|
||||||
...TransitionPresets.ModalSlideFromBottomIOS,
|
...TransitionPresets.ModalSlideFromBottomIOS,
|
||||||
};
|
};
|
||||||
}}
|
}}
|
||||||
|
|
@ -345,11 +348,14 @@ class TabNavigator extends React.Component<Props> {
|
||||||
>
|
>
|
||||||
<Tab.Screen
|
<Tab.Screen
|
||||||
name="proximo"
|
name="proximo"
|
||||||
|
option
|
||||||
component={ProximoStackComponent}
|
component={ProximoStackComponent}
|
||||||
|
options={{title: i18n.t('screens.proximo')}}
|
||||||
/>
|
/>
|
||||||
<Tab.Screen
|
<Tab.Screen
|
||||||
name="planning"
|
name="planning"
|
||||||
component={PlanningStackComponent}
|
component={PlanningStackComponent}
|
||||||
|
options={{title: i18n.t('screens.planning')}}
|
||||||
/>
|
/>
|
||||||
<Tab.Screen
|
<Tab.Screen
|
||||||
name="home"
|
name="home"
|
||||||
|
|
@ -359,10 +365,12 @@ class TabNavigator extends React.Component<Props> {
|
||||||
<Tab.Screen
|
<Tab.Screen
|
||||||
name="proxiwash"
|
name="proxiwash"
|
||||||
component={ProxiwashStackComponent}
|
component={ProxiwashStackComponent}
|
||||||
|
options={{title: i18n.t('screens.proxiwash')}}
|
||||||
/>
|
/>
|
||||||
<Tab.Screen
|
<Tab.Screen
|
||||||
name="planex"
|
name="planex"
|
||||||
component={PlanexStackComponent}
|
component={PlanexStackComponent}
|
||||||
|
options={{title: "Planex"}}
|
||||||
/>
|
/>
|
||||||
</Tab.Navigator>
|
</Tab.Navigator>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ import {Searchbar, withTheme} from "react-native-paper";
|
||||||
import {stringMatchQuery} from "../utils/Search";
|
import {stringMatchQuery} from "../utils/Search";
|
||||||
import WebSectionList from "../components/Lists/WebSectionList";
|
import WebSectionList from "../components/Lists/WebSectionList";
|
||||||
import GroupListAccordion from "../components/Lists/GroupListAccordion";
|
import GroupListAccordion from "../components/Lists/GroupListAccordion";
|
||||||
|
import AsyncStorageManager from "../managers/AsyncStorageManager";
|
||||||
|
|
||||||
const LIST_ITEM_HEIGHT = 70;
|
const LIST_ITEM_HEIGHT = 70;
|
||||||
|
|
||||||
|
|
@ -19,6 +20,7 @@ type Props = {
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
currentSearchString: string,
|
currentSearchString: string,
|
||||||
|
favoriteGroups: Array<Object>,
|
||||||
};
|
};
|
||||||
|
|
||||||
function sortName(a, b) {
|
function sortName(a, b) {
|
||||||
|
|
@ -30,6 +32,7 @@ function sortName(a, b) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const GROUPS_URL = 'http://planex.insa-toulouse.fr/wsAdeGrp.php?projectId=1';
|
const GROUPS_URL = 'http://planex.insa-toulouse.fr/wsAdeGrp.php?projectId=1';
|
||||||
|
const REPLACE_REGEX = /_/g;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class defining proximo's article list of a certain category.
|
* Class defining proximo's article list of a certain category.
|
||||||
|
|
@ -40,6 +43,7 @@ class GroupSelectionScreen extends React.Component<Props, State> {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
currentSearchString: '',
|
currentSearchString: '',
|
||||||
|
favoriteGroups: JSON.parse(AsyncStorageManager.getInstance().preferences.planexFavoriteGroups.current),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -92,6 +96,49 @@ class GroupSelectionScreen extends React.Component<Props, State> {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onListFavoritePress = (item: Object) => {
|
||||||
|
this.updateGroupFavorites(item);
|
||||||
|
};
|
||||||
|
|
||||||
|
isGroupInFavorites(group: Object) {
|
||||||
|
let isFav = false;
|
||||||
|
for (let i = 0; i < this.state.favoriteGroups.length; i++) {
|
||||||
|
if (group.id === this.state.favoriteGroups[i].id) {
|
||||||
|
isFav = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return isFav;
|
||||||
|
}
|
||||||
|
|
||||||
|
removeGroupFromFavorites(favorites: Array<Object>, group: Object) {
|
||||||
|
for (let i = 0; i < favorites.length; i++) {
|
||||||
|
if (group.id === favorites[i].id) {
|
||||||
|
favorites.splice(i, 1);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addGroupToFavorites(favorites: Array<Object>, group: Object) {
|
||||||
|
group.isFav = true;
|
||||||
|
favorites.push(group);
|
||||||
|
favorites.sort(sortName);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateGroupFavorites(group: Object) {
|
||||||
|
let newFavorites = [...this.state.favoriteGroups]
|
||||||
|
if (this.isGroupInFavorites(group))
|
||||||
|
this.removeGroupFromFavorites(newFavorites, group);
|
||||||
|
else
|
||||||
|
this.addGroupToFavorites(newFavorites, group);
|
||||||
|
this.setState({favoriteGroups: newFavorites})
|
||||||
|
console.log(newFavorites);
|
||||||
|
AsyncStorageManager.getInstance().savePref(
|
||||||
|
AsyncStorageManager.getInstance().preferences.planexFavoriteGroups.key,
|
||||||
|
JSON.stringify(newFavorites));
|
||||||
|
}
|
||||||
|
|
||||||
shouldDisplayAccordion(item: Object) {
|
shouldDisplayAccordion(item: Object) {
|
||||||
let shouldDisplay = false;
|
let shouldDisplay = false;
|
||||||
for (let i = 0; i < item.content.length; i++) {
|
for (let i = 0; i < item.content.length; i++) {
|
||||||
|
|
@ -115,7 +162,9 @@ class GroupSelectionScreen extends React.Component<Props, State> {
|
||||||
<GroupListAccordion
|
<GroupListAccordion
|
||||||
item={item}
|
item={item}
|
||||||
onGroupPress={this.onListItemPress}
|
onGroupPress={this.onListItemPress}
|
||||||
|
onFavoritePress={this.onListFavoritePress}
|
||||||
currentSearchString={this.state.currentSearchString}
|
currentSearchString={this.state.currentSearchString}
|
||||||
|
favoriteNumber={this.state.favoriteGroups.length}
|
||||||
height={LIST_ITEM_HEIGHT}
|
height={LIST_ITEM_HEIGHT}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|
@ -126,12 +175,21 @@ class GroupSelectionScreen extends React.Component<Props, State> {
|
||||||
generateData(fetchedData: Object) {
|
generateData(fetchedData: Object) {
|
||||||
let data = [];
|
let data = [];
|
||||||
for (let key in fetchedData) {
|
for (let key in fetchedData) {
|
||||||
|
this.formatGroups(fetchedData[key]);
|
||||||
data.push(fetchedData[key]);
|
data.push(fetchedData[key]);
|
||||||
}
|
}
|
||||||
data.sort(sortName);
|
data.sort(sortName);
|
||||||
|
data.unshift({name: "FAVORITES", id: "0", content: this.state.favoriteGroups});
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
formatGroups(item: Object) {
|
||||||
|
for (let i = 0; i < item.content.length; i++) {
|
||||||
|
item.content[i].name = item.content[i].name.replace(REPLACE_REGEX, " ")
|
||||||
|
item.content[i].isFav = this.isGroupInFavorites(item.content[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates the dataset to be used in the FlatList
|
* Creates the dataset to be used in the FlatList
|
||||||
*
|
*
|
||||||
|
|
@ -159,7 +217,7 @@ class GroupSelectionScreen extends React.Component<Props, State> {
|
||||||
refreshOnFocus={false}
|
refreshOnFocus={false}
|
||||||
fetchUrl={GROUPS_URL}
|
fetchUrl={GROUPS_URL}
|
||||||
renderItem={this.renderItem}
|
renderItem={this.renderItem}
|
||||||
updateData={this.state.currentSearchString}
|
updateData={this.state.currentSearchString + this.state.favoriteGroups.length}
|
||||||
itemHeight={LIST_ITEM_HEIGHT}
|
itemHeight={LIST_ITEM_HEIGHT}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,7 @@ import {dateToString, getTimeOnlyString} from "../../utils/Planning";
|
||||||
import DateManager from "../../managers/DateManager";
|
import DateManager from "../../managers/DateManager";
|
||||||
import AnimatedBottomBar from "../../components/Custom/AnimatedBottomBar";
|
import AnimatedBottomBar from "../../components/Custom/AnimatedBottomBar";
|
||||||
import {CommonActions} from "@react-navigation/native";
|
import {CommonActions} from "@react-navigation/native";
|
||||||
|
import ErrorView from "../../components/Custom/ErrorView";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
navigation: Object,
|
navigation: Object,
|
||||||
|
|
@ -136,16 +137,18 @@ class PlanexScreen extends React.Component<Props, State> {
|
||||||
/**
|
/**
|
||||||
* Defines custom injected JavaScript to improve the page display on mobile
|
* Defines custom injected JavaScript to improve the page display on mobile
|
||||||
*/
|
*/
|
||||||
constructor() {
|
constructor(props) {
|
||||||
super();
|
super(props);
|
||||||
this.webScreenRef = React.createRef();
|
this.webScreenRef = React.createRef();
|
||||||
this.barRef = React.createRef();
|
this.barRef = React.createRef();
|
||||||
|
|
||||||
let currentGroup = AsyncStorageManager.getInstance().preferences.planexCurrentGroup.current;
|
let currentGroup = AsyncStorageManager.getInstance().preferences.planexCurrentGroup.current;
|
||||||
if (currentGroup === '')
|
if (currentGroup === '')
|
||||||
currentGroup = {name: "SELECT GROUP", id: 0};
|
currentGroup = {name: "SELECT GROUP", id: -1};
|
||||||
else
|
else {
|
||||||
currentGroup = JSON.parse(currentGroup);
|
currentGroup = JSON.parse(currentGroup);
|
||||||
|
props.navigation.setOptions({title: currentGroup.name})
|
||||||
|
}
|
||||||
this.state = {
|
this.state = {
|
||||||
bannerVisible:
|
bannerVisible:
|
||||||
AsyncStorageManager.getInstance().preferences.planexShowBanner.current === '1' &&
|
AsyncStorageManager.getInstance().preferences.planexShowBanner.current === '1' &&
|
||||||
|
|
@ -182,6 +185,7 @@ class PlanexScreen extends React.Component<Props, State> {
|
||||||
AsyncStorageManager.getInstance().savePref(
|
AsyncStorageManager.getInstance().savePref(
|
||||||
AsyncStorageManager.getInstance().preferences.planexCurrentGroup.key,
|
AsyncStorageManager.getInstance().preferences.planexCurrentGroup.key,
|
||||||
JSON.stringify(group));
|
JSON.stringify(group));
|
||||||
|
this.props.navigation.setOptions({title: group.name})
|
||||||
this.generateInjectedJS(group.id);
|
this.generateInjectedJS(group.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -190,6 +194,7 @@ class PlanexScreen extends React.Component<Props, State> {
|
||||||
+ OBSERVE_MUTATIONS_INJECTED
|
+ OBSERVE_MUTATIONS_INJECTED
|
||||||
+ FULL_CALENDAR_SETTINGS
|
+ FULL_CALENDAR_SETTINGS
|
||||||
+ "displayAde(" + groupID + ");" // Reset Ade
|
+ "displayAde(" + groupID + ");" // Reset Ade
|
||||||
|
+ (DateManager.isWeekend(new Date()) ? "calendar.next()" : "")
|
||||||
+ LISTEN_TO_MESSAGES
|
+ LISTEN_TO_MESSAGES
|
||||||
+ INJECT_STYLE;
|
+ INJECT_STYLE;
|
||||||
|
|
||||||
|
|
@ -260,15 +265,28 @@ class PlanexScreen extends React.Component<Props, State> {
|
||||||
};
|
};
|
||||||
|
|
||||||
getWebView() {
|
getWebView() {
|
||||||
|
const showWebview = this.state.currentGroup.id !== -1;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<WebViewScreen
|
<View style={{height: '100%'}}>
|
||||||
ref={this.webScreenRef}
|
{!showWebview
|
||||||
navigation={this.props.navigation}
|
? <ErrorView
|
||||||
url={PLANEX_URL}
|
{...this.props}
|
||||||
customJS={this.customInjectedJS}
|
icon={'account-clock'}
|
||||||
onMessage={this.onMessage}
|
message={i18n.t("planexScreen.noGroupSelected")}
|
||||||
onScroll={this.onScroll}
|
showRetryButton={false}
|
||||||
/>
|
/>
|
||||||
|
: null}
|
||||||
|
|
||||||
|
<WebViewScreen
|
||||||
|
ref={this.webScreenRef}
|
||||||
|
navigation={this.props.navigation}
|
||||||
|
url={PLANEX_URL}
|
||||||
|
customJS={this.customInjectedJS}
|
||||||
|
onMessage={this.onMessage}
|
||||||
|
onScroll={this.onScroll}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -212,7 +212,8 @@
|
||||||
"planexScreen": {
|
"planexScreen": {
|
||||||
"enableStartScreen": "Come here often? Set it as default screen!",
|
"enableStartScreen": "Come here often? Set it as default screen!",
|
||||||
"enableStartOK": "Yes please!",
|
"enableStartOK": "Yes please!",
|
||||||
"enableStartCancel": "Later"
|
"enableStartCancel": "Later",
|
||||||
|
"noGroupSelected": "No group selected. Please select your group using the big beautiful red button bellow."
|
||||||
},
|
},
|
||||||
"availableRoomScreen": {
|
"availableRoomScreen": {
|
||||||
"normalRoom": "Work",
|
"normalRoom": "Work",
|
||||||
|
|
|
||||||
|
|
@ -212,7 +212,8 @@
|
||||||
"planexScreen": {
|
"planexScreen": {
|
||||||
"enableStartScreen": "Vous venez souvent ici ? Démarrez l'appli sur cette page!",
|
"enableStartScreen": "Vous venez souvent ici ? Démarrez l'appli sur cette page!",
|
||||||
"enableStartOK": "Oui svp!",
|
"enableStartOK": "Oui svp!",
|
||||||
"enableStartCancel": "Plus tard"
|
"enableStartCancel": "Plus tard",
|
||||||
|
"noGroupSelected": "Pas de group sélectionné. Merci de choisir un groupe avec le beau bouton rouge ci-dessous."
|
||||||
},
|
},
|
||||||
"availableRoomScreen": {
|
"availableRoomScreen": {
|
||||||
"normalRoom": "Travail",
|
"normalRoom": "Travail",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue