Compare commits
5 commits
98359dba7d
...
06d01e98b0
| Author | SHA1 | Date | |
|---|---|---|---|
| 06d01e98b0 | |||
| 57f7716700 | |||
| 4cdadbc6c1 | |||
| d07b34c748 | |||
| 629f0401bc |
9 changed files with 123 additions and 35 deletions
|
|
@ -59,6 +59,11 @@ export default class AsyncStorageManager {
|
||||||
default: 'home',
|
default: 'home',
|
||||||
current: '',
|
current: '',
|
||||||
},
|
},
|
||||||
|
homeShowBanner: {
|
||||||
|
key: 'homeShowBanner',
|
||||||
|
default: '1',
|
||||||
|
current: '',
|
||||||
|
},
|
||||||
proxiwashShowBanner: {
|
proxiwashShowBanner: {
|
||||||
key: 'proxiwashShowBanner',
|
key: 'proxiwashShowBanner',
|
||||||
default: '1',
|
default: '1',
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import {Animated, KeyboardAvoidingView, Linking, StyleSheet, View} from "react-native";
|
import {Animated, KeyboardAvoidingView, StyleSheet, View} from "react-native";
|
||||||
import {Avatar, Button, Card, HelperText, Paragraph, TextInput, withTheme} from 'react-native-paper';
|
import {Avatar, Button, Card, HelperText, Paragraph, TextInput, withTheme} from 'react-native-paper';
|
||||||
import ConnectionManager from "../../managers/ConnectionManager";
|
import ConnectionManager from "../../managers/ConnectionManager";
|
||||||
import i18n from 'i18n-js';
|
import i18n from 'i18n-js';
|
||||||
|
|
@ -30,7 +30,7 @@ type State = {
|
||||||
|
|
||||||
const ICON_AMICALE = require('../../../assets/amicale.png');
|
const ICON_AMICALE = require('../../../assets/amicale.png');
|
||||||
|
|
||||||
const RESET_PASSWORD_PATH = "https://www.amicale-insat.fr//password/reset";
|
const RESET_PASSWORD_PATH = "https://www.amicale-insat.fr/password/reset";
|
||||||
|
|
||||||
const emailRegex = /^.+@.+\..+$/;
|
const emailRegex = /^.+@.+\..+$/;
|
||||||
|
|
||||||
|
|
@ -70,7 +70,6 @@ class LoginScreen extends React.Component<Props, State> {
|
||||||
else
|
else
|
||||||
this.nextScreen = null;
|
this.nextScreen = null;
|
||||||
}
|
}
|
||||||
console.log(this.nextScreen);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
showErrorDialog = (error: number) =>
|
showErrorDialog = (error: number) =>
|
||||||
|
|
@ -88,7 +87,7 @@ class LoginScreen extends React.Component<Props, State> {
|
||||||
this.props.navigation.replace(this.nextScreen);
|
this.props.navigation.replace(this.nextScreen);
|
||||||
};
|
};
|
||||||
|
|
||||||
onResetPasswordClick = () => Linking.openURL(RESET_PASSWORD_PATH);
|
onResetPasswordClick = () => this.props.navigation.navigate('amicale-website', {path: RESET_PASSWORD_PATH});
|
||||||
|
|
||||||
validateEmail = () => this.setState({isEmailValidated: true});
|
validateEmail = () => this.setState({isEmailValidated: true});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -245,10 +245,7 @@ class ProfileScreen extends React.Component<Props, State> {
|
||||||
<Button
|
<Button
|
||||||
icon="account-edit"
|
icon="account-edit"
|
||||||
mode="contained"
|
mode="contained"
|
||||||
onPress={() => this.props.navigation.navigate('amicale-website', {
|
onPress={() => this.props.navigation.navigate('amicale-website', {path: this.data.link})}
|
||||||
screen: 'amicale-website',
|
|
||||||
params: {path: this.data.link}
|
|
||||||
})}
|
|
||||||
style={styles.editButton}>
|
style={styles.editButton}>
|
||||||
{i18n.t("profileScreen.editInformation")}
|
{i18n.t("profileScreen.editInformation")}
|
||||||
</Button>
|
</Button>
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import {FlatList} from 'react-native';
|
||||||
import i18n from "i18n-js";
|
import i18n from "i18n-js";
|
||||||
import DashboardItem from "../../components/Home/EventDashboardItem";
|
import DashboardItem from "../../components/Home/EventDashboardItem";
|
||||||
import WebSectionList from "../../components/Screens/WebSectionList";
|
import WebSectionList from "../../components/Screens/WebSectionList";
|
||||||
import {withTheme} from 'react-native-paper';
|
import {Avatar, Banner, withTheme} from 'react-native-paper';
|
||||||
import FeedItem from "../../components/Home/FeedItem";
|
import FeedItem from "../../components/Home/FeedItem";
|
||||||
import SquareDashboardItem from "../../components/Home/SmallDashboardItem";
|
import SquareDashboardItem from "../../components/Home/SmallDashboardItem";
|
||||||
import PreviewEventDashboardItem from "../../components/Home/PreviewEventDashboardItem";
|
import PreviewEventDashboardItem from "../../components/Home/PreviewEventDashboardItem";
|
||||||
|
|
@ -19,6 +19,9 @@ import type {CustomTheme} from "../../managers/ThemeManager";
|
||||||
import {View} from "react-native-animatable";
|
import {View} from "react-native-animatable";
|
||||||
import ConnectionManager from "../../managers/ConnectionManager";
|
import ConnectionManager from "../../managers/ConnectionManager";
|
||||||
import LogoutDialog from "../../components/Amicale/LogoutDialog";
|
import LogoutDialog from "../../components/Amicale/LogoutDialog";
|
||||||
|
import {withCollapsible} from "../../utils/withCollapsible";
|
||||||
|
import {Collapsible} from "react-navigation-collapsible";
|
||||||
|
import AsyncStorageManager from "../../managers/AsyncStorageManager";
|
||||||
// import DATA from "../dashboard_data.json";
|
// import DATA from "../dashboard_data.json";
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -95,10 +98,12 @@ type Props = {
|
||||||
navigation: StackNavigationProp,
|
navigation: StackNavigationProp,
|
||||||
route: { params: any, ... },
|
route: { params: any, ... },
|
||||||
theme: CustomTheme,
|
theme: CustomTheme,
|
||||||
|
collapsibleStack: Collapsible,
|
||||||
}
|
}
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
dialogVisible: boolean,
|
dialogVisible: boolean,
|
||||||
|
bannerVisible: boolean,
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -115,6 +120,7 @@ class HomeScreen extends React.Component<Props, State> {
|
||||||
|
|
||||||
state = {
|
state = {
|
||||||
dialogVisible: false,
|
dialogVisible: false,
|
||||||
|
bannerVisible: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
|
@ -140,6 +146,11 @@ class HomeScreen extends React.Component<Props, State> {
|
||||||
this.props.navigation.addListener('focus', this.onScreenFocus);
|
this.props.navigation.addListener('focus', this.onScreenFocus);
|
||||||
// Handle link open when home is focused
|
// Handle link open when home is focused
|
||||||
this.props.navigation.addListener('state', this.handleNavigationParams);
|
this.props.navigation.addListener('state', this.handleNavigationParams);
|
||||||
|
setTimeout(this.onBannerTimeout, 2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
onBannerTimeout = () => {
|
||||||
|
this.setState({bannerVisible: AsyncStorageManager.getInstance().preferences.homeShowBanner.current === "1"})
|
||||||
}
|
}
|
||||||
|
|
||||||
onScreenFocus = () => {
|
onScreenFocus = () => {
|
||||||
|
|
@ -164,7 +175,7 @@ class HomeScreen extends React.Component<Props, State> {
|
||||||
};
|
};
|
||||||
|
|
||||||
getHeaderButton = () => {
|
getHeaderButton = () => {
|
||||||
let onPressLog = () => this.props.navigation.navigate("login");
|
let onPressLog = () => this.props.navigation.navigate("login", {nextScreen: "profile"});
|
||||||
let logIcon = "login";
|
let logIcon = "login";
|
||||||
let logColor = this.props.theme.colors.primary;
|
let logColor = this.props.theme.colors.primary;
|
||||||
if (this.isLoggedIn) {
|
if (this.isLoggedIn) {
|
||||||
|
|
@ -535,22 +546,46 @@ class HomeScreen extends React.Component<Props, State> {
|
||||||
this.fabRef.current.onScroll(event);
|
this.fabRef.current.onScroll(event);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Callback used when closing the banner.
|
||||||
|
* This hides the banner and saves to preferences to prevent it from reopening
|
||||||
|
*/
|
||||||
|
onHideBanner = () => {
|
||||||
|
this.setState({bannerVisible: false});
|
||||||
|
AsyncStorageManager.getInstance().savePref(
|
||||||
|
AsyncStorageManager.getInstance().preferences.homeShowBanner.key,
|
||||||
|
'0'
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
onLoginBanner = () => {
|
||||||
|
this.onHideBanner();
|
||||||
|
this.props.navigation.navigate("login", {nextScreen: "profile"});
|
||||||
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
const {containerPaddingTop} = this.props.collapsibleStack;
|
||||||
return (
|
return (
|
||||||
<View
|
<View
|
||||||
style={{flex: 1}}
|
style={{flex: 1}}
|
||||||
>
|
>
|
||||||
<WebSectionList
|
<View style={{
|
||||||
{...this.props}
|
position: "absolute",
|
||||||
createDataset={this.createDataset}
|
width: "100%",
|
||||||
autoRefreshTime={REFRESH_TIME}
|
height: "100%",
|
||||||
refreshOnFocus={true}
|
}}>
|
||||||
fetchUrl={DATA_URL}
|
<WebSectionList
|
||||||
renderItem={this.getRenderItem}
|
{...this.props}
|
||||||
itemHeight={FEED_ITEM_HEIGHT}
|
createDataset={this.createDataset}
|
||||||
onScroll={this.onScroll}
|
autoRefreshTime={REFRESH_TIME}
|
||||||
showError={false}
|
refreshOnFocus={true}
|
||||||
/>
|
fetchUrl={DATA_URL}
|
||||||
|
renderItem={this.getRenderItem}
|
||||||
|
itemHeight={FEED_ITEM_HEIGHT}
|
||||||
|
onScroll={this.onScroll}
|
||||||
|
showError={false}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
<AnimatedFAB
|
<AnimatedFAB
|
||||||
{...this.props}
|
{...this.props}
|
||||||
ref={this.fabRef}
|
ref={this.fabRef}
|
||||||
|
|
@ -562,9 +597,32 @@ class HomeScreen extends React.Component<Props, State> {
|
||||||
visible={this.state.dialogVisible}
|
visible={this.state.dialogVisible}
|
||||||
onDismiss={this.hideDisconnectDialog}
|
onDismiss={this.hideDisconnectDialog}
|
||||||
/>
|
/>
|
||||||
|
<Banner
|
||||||
|
style={{
|
||||||
|
marginTop: containerPaddingTop,
|
||||||
|
backgroundColor: this.props.theme.colors.surface
|
||||||
|
}}
|
||||||
|
visible={this.state.bannerVisible}
|
||||||
|
actions={[
|
||||||
|
{
|
||||||
|
label: i18n.t('homeScreen.loginBanner.login'),
|
||||||
|
onPress: this.onLoginBanner,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: i18n.t('homeScreen.loginBanner.later'),
|
||||||
|
onPress: this.onHideBanner,
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
icon={() => <Avatar.Icon
|
||||||
|
icon={'login'}
|
||||||
|
size={50}
|
||||||
|
/>}
|
||||||
|
>
|
||||||
|
{i18n.t('homeScreen.loginBanner.message')}
|
||||||
|
</Banner>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default withTheme(HomeScreen);
|
export default withCollapsible(withTheme(HomeScreen));
|
||||||
|
|
|
||||||
|
|
@ -150,9 +150,7 @@ class PlanexScreen extends React.Component<Props, State> {
|
||||||
props.navigation.setOptions({title: currentGroup.name})
|
props.navigation.setOptions({title: currentGroup.name})
|
||||||
}
|
}
|
||||||
this.state = {
|
this.state = {
|
||||||
bannerVisible:
|
bannerVisible: false,
|
||||||
AsyncStorageManager.getInstance().preferences.planexShowBanner.current === '1' &&
|
|
||||||
AsyncStorageManager.getInstance().preferences.defaultStartScreen.current !== 'Planex',
|
|
||||||
dialogVisible: false,
|
dialogVisible: false,
|
||||||
dialogTitle: "",
|
dialogTitle: "",
|
||||||
dialogMessage: "",
|
dialogMessage: "",
|
||||||
|
|
@ -163,6 +161,15 @@ class PlanexScreen extends React.Component<Props, State> {
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this.props.navigation.addListener('focus', this.onScreenFocus);
|
this.props.navigation.addListener('focus', this.onScreenFocus);
|
||||||
|
setTimeout(this.onBannerTimeout, 2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
onBannerTimeout = () => {
|
||||||
|
this.setState({
|
||||||
|
bannerVisible:
|
||||||
|
AsyncStorageManager.getInstance().preferences.planexShowBanner.current === '1' &&
|
||||||
|
AsyncStorageManager.getInstance().preferences.defaultStartScreen.current !== 'Planex'
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
onScreenFocus = () => {
|
onScreenFocus = () => {
|
||||||
|
|
@ -315,7 +322,10 @@ class PlanexScreen extends React.Component<Props, State> {
|
||||||
: <View style={{height: '100%'}}>{this.getWebView()}</View>}
|
: <View style={{height: '100%'}}>{this.getWebView()}</View>}
|
||||||
</View>
|
</View>
|
||||||
<Banner
|
<Banner
|
||||||
style={{marginTop: containerPaddingTop,}}
|
style={{
|
||||||
|
marginTop: containerPaddingTop,
|
||||||
|
backgroundColor: this.props.theme.colors.surface
|
||||||
|
}}
|
||||||
visible={this.state.bannerVisible}
|
visible={this.state.bannerVisible}
|
||||||
actions={[
|
actions={[
|
||||||
{
|
{
|
||||||
|
|
@ -329,7 +339,7 @@ class PlanexScreen extends React.Component<Props, State> {
|
||||||
|
|
||||||
]}
|
]}
|
||||||
icon={() => <Avatar.Icon
|
icon={() => <Avatar.Icon
|
||||||
icon={'information'}
|
icon={'power'}
|
||||||
size={40}
|
size={40}
|
||||||
/>}
|
/>}
|
||||||
>
|
>
|
||||||
|
|
@ -351,4 +361,4 @@ class PlanexScreen extends React.Component<Props, State> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default withCollapsible(withTheme(PlanexScreen));
|
export default withCollapsible(withTheme(PlanexScreen));
|
||||||
|
|
|
||||||
|
|
@ -68,7 +68,7 @@ class ProxiwashScreen extends React.Component<Props, State> {
|
||||||
refreshing: false,
|
refreshing: false,
|
||||||
modalCurrentDisplayItem: null,
|
modalCurrentDisplayItem: null,
|
||||||
machinesWatched: JSON.parse(AsyncStorageManager.getInstance().preferences.proxiwashWatchedMachines.current),
|
machinesWatched: JSON.parse(AsyncStorageManager.getInstance().preferences.proxiwashWatchedMachines.current),
|
||||||
bannerVisible: AsyncStorageManager.getInstance().preferences.proxiwashShowBanner.current === '1',
|
bannerVisible: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -107,6 +107,11 @@ class ProxiwashScreen extends React.Component<Props, State> {
|
||||||
<Item title="information" iconName="information" onPress={this.onAboutPress}/>
|
<Item title="information" iconName="information" onPress={this.onAboutPress}/>
|
||||||
</MaterialHeaderButtons>,
|
</MaterialHeaderButtons>,
|
||||||
});
|
});
|
||||||
|
setTimeout(this.onBannerTimeout, 2000);
|
||||||
|
}
|
||||||
|
|
||||||
|
onBannerTimeout = () => {
|
||||||
|
this.setState({bannerVisible: AsyncStorageManager.getInstance().preferences.proxiwashShowBanner.current === "1"})
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -417,16 +422,19 @@ class ProxiwashScreen extends React.Component<Props, State> {
|
||||||
updateData={this.state.machinesWatched.length}/>
|
updateData={this.state.machinesWatched.length}/>
|
||||||
</View>
|
</View>
|
||||||
<Banner
|
<Banner
|
||||||
style={{marginTop: containerPaddingTop,}}
|
style={{
|
||||||
|
marginTop: containerPaddingTop,
|
||||||
|
backgroundColor: this.props.theme.colors.surface
|
||||||
|
}}
|
||||||
visible={this.state.bannerVisible}
|
visible={this.state.bannerVisible}
|
||||||
actions={[
|
actions={[
|
||||||
{
|
{
|
||||||
label: 'OK',
|
label: i18n.t('proxiwashScreen.bannerButton'),
|
||||||
onPress: this.onHideBanner,
|
onPress: this.onHideBanner,
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
icon={() => <Avatar.Icon
|
icon={() => <Avatar.Icon
|
||||||
icon={'information'}
|
icon={'bell'}
|
||||||
size={40}
|
size={40}
|
||||||
/>}
|
/>}
|
||||||
>
|
>
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import WebViewScreen from "../../../components/Screens/WebViewScreen";
|
import WebViewScreen from "../../../components/Screens/WebViewScreen";
|
||||||
import {CommonActions} from "@react-navigation/native";
|
|
||||||
|
|
||||||
const URL = 'https://www.amicale-insat.fr/';
|
const URL = 'https://www.amicale-insat.fr/';
|
||||||
/**
|
/**
|
||||||
|
|
@ -15,10 +14,9 @@ export const AmicaleWebsiteScreen = (props: Object) => {
|
||||||
if (props.route.params.path !== undefined && props.route.params.path !== null) {
|
if (props.route.params.path !== undefined && props.route.params.path !== null) {
|
||||||
path = props.route.params.path;
|
path = props.route.params.path;
|
||||||
path = path.replace(URL, '');
|
path = path.replace(URL, '');
|
||||||
// reset params to prevent infinite loop
|
|
||||||
props.navigation.dispatch(CommonActions.setParams({path: null}));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
console.log(URL + path);
|
||||||
return (
|
return (
|
||||||
<WebViewScreen
|
<WebViewScreen
|
||||||
{...props}
|
{...props}
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,11 @@
|
||||||
"amicaleTitle": "The Amicale",
|
"amicaleTitle": "The Amicale",
|
||||||
"amicaleConnect": "Login",
|
"amicaleConnect": "Login",
|
||||||
"amicaleConnected": "See available services"
|
"amicaleConnected": "See available services"
|
||||||
|
},
|
||||||
|
"loginBanner": {
|
||||||
|
"login": "Login",
|
||||||
|
"later": "Later",
|
||||||
|
"message": "Login to your Amicale account to get access to more services!"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"aboutScreen": {
|
"aboutScreen": {
|
||||||
|
|
@ -174,6 +179,7 @@
|
||||||
"enableNotificationsTip": "Click on a running machine to enable notifications",
|
"enableNotificationsTip": "Click on a running machine to enable notifications",
|
||||||
"numAvailable": "available",
|
"numAvailable": "available",
|
||||||
"numAvailablePlural": "available",
|
"numAvailablePlural": "available",
|
||||||
|
"bannerButton": "Got it!",
|
||||||
"modal": {
|
"modal": {
|
||||||
"enableNotifications": "Notify me",
|
"enableNotifications": "Notify me",
|
||||||
"disableNotifications": "Stop notifications",
|
"disableNotifications": "Stop notifications",
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,13 @@
|
||||||
"amicaleTitle": "L'Amicale",
|
"amicaleTitle": "L'Amicale",
|
||||||
"amicaleConnect": "Se connecter",
|
"amicaleConnect": "Se connecter",
|
||||||
"amicaleConnected": "Voir les services disponibles"
|
"amicaleConnected": "Voir les services disponibles"
|
||||||
|
},
|
||||||
|
"loginBanner": {
|
||||||
|
"login": "Se Connecter",
|
||||||
|
"later": "Plus Tard",
|
||||||
|
"message": "Connectez-vous à votre compte Amicale pour profiter de plus de services !"
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
"aboutScreen": {
|
"aboutScreen": {
|
||||||
"buttonDesc": "Informations sur l'appli et son créateur",
|
"buttonDesc": "Informations sur l'appli et son créateur",
|
||||||
|
|
@ -174,6 +180,7 @@
|
||||||
"enableNotificationsTip": "Cliquez sur une machine en cours pour activer les notifications",
|
"enableNotificationsTip": "Cliquez sur une machine en cours pour activer les notifications",
|
||||||
"numAvailable": "disponible",
|
"numAvailable": "disponible",
|
||||||
"numAvailablePlural": "disponibles",
|
"numAvailablePlural": "disponibles",
|
||||||
|
"bannerButton": "Compris !",
|
||||||
"modal": {
|
"modal": {
|
||||||
"enableNotifications": "Me Notifier",
|
"enableNotifications": "Me Notifier",
|
||||||
"disableNotifications": "Désactiver les notifications",
|
"disableNotifications": "Désactiver les notifications",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue