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',
|
||||
current: '',
|
||||
},
|
||||
homeShowBanner: {
|
||||
key: 'homeShowBanner',
|
||||
default: '1',
|
||||
current: '',
|
||||
},
|
||||
proxiwashShowBanner: {
|
||||
key: 'proxiwashShowBanner',
|
||||
default: '1',
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
// @flow
|
||||
|
||||
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 ConnectionManager from "../../managers/ConnectionManager";
|
||||
import i18n from 'i18n-js';
|
||||
|
|
@ -30,7 +30,7 @@ type State = {
|
|||
|
||||
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 = /^.+@.+\..+$/;
|
||||
|
||||
|
|
@ -70,7 +70,6 @@ class LoginScreen extends React.Component<Props, State> {
|
|||
else
|
||||
this.nextScreen = null;
|
||||
}
|
||||
console.log(this.nextScreen);
|
||||
}
|
||||
|
||||
showErrorDialog = (error: number) =>
|
||||
|
|
@ -88,7 +87,7 @@ class LoginScreen extends React.Component<Props, State> {
|
|||
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});
|
||||
|
||||
|
|
|
|||
|
|
@ -245,10 +245,7 @@ class ProfileScreen extends React.Component<Props, State> {
|
|||
<Button
|
||||
icon="account-edit"
|
||||
mode="contained"
|
||||
onPress={() => this.props.navigation.navigate('amicale-website', {
|
||||
screen: 'amicale-website',
|
||||
params: {path: this.data.link}
|
||||
})}
|
||||
onPress={() => this.props.navigation.navigate('amicale-website', {path: this.data.link})}
|
||||
style={styles.editButton}>
|
||||
{i18n.t("profileScreen.editInformation")}
|
||||
</Button>
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ import {FlatList} from 'react-native';
|
|||
import i18n from "i18n-js";
|
||||
import DashboardItem from "../../components/Home/EventDashboardItem";
|
||||
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 SquareDashboardItem from "../../components/Home/SmallDashboardItem";
|
||||
import PreviewEventDashboardItem from "../../components/Home/PreviewEventDashboardItem";
|
||||
|
|
@ -19,6 +19,9 @@ import type {CustomTheme} from "../../managers/ThemeManager";
|
|||
import {View} from "react-native-animatable";
|
||||
import ConnectionManager from "../../managers/ConnectionManager";
|
||||
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";
|
||||
|
||||
|
||||
|
|
@ -95,10 +98,12 @@ type Props = {
|
|||
navigation: StackNavigationProp,
|
||||
route: { params: any, ... },
|
||||
theme: CustomTheme,
|
||||
collapsibleStack: Collapsible,
|
||||
}
|
||||
|
||||
type State = {
|
||||
dialogVisible: boolean,
|
||||
bannerVisible: boolean,
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -115,6 +120,7 @@ class HomeScreen extends React.Component<Props, State> {
|
|||
|
||||
state = {
|
||||
dialogVisible: false,
|
||||
bannerVisible: false,
|
||||
}
|
||||
|
||||
constructor(props) {
|
||||
|
|
@ -140,6 +146,11 @@ class HomeScreen extends React.Component<Props, State> {
|
|||
this.props.navigation.addListener('focus', this.onScreenFocus);
|
||||
// Handle link open when home is focused
|
||||
this.props.navigation.addListener('state', this.handleNavigationParams);
|
||||
setTimeout(this.onBannerTimeout, 2000);
|
||||
}
|
||||
|
||||
onBannerTimeout = () => {
|
||||
this.setState({bannerVisible: AsyncStorageManager.getInstance().preferences.homeShowBanner.current === "1"})
|
||||
}
|
||||
|
||||
onScreenFocus = () => {
|
||||
|
|
@ -164,7 +175,7 @@ class HomeScreen extends React.Component<Props, State> {
|
|||
};
|
||||
|
||||
getHeaderButton = () => {
|
||||
let onPressLog = () => this.props.navigation.navigate("login");
|
||||
let onPressLog = () => this.props.navigation.navigate("login", {nextScreen: "profile"});
|
||||
let logIcon = "login";
|
||||
let logColor = this.props.theme.colors.primary;
|
||||
if (this.isLoggedIn) {
|
||||
|
|
@ -535,22 +546,46 @@ class HomeScreen extends React.Component<Props, State> {
|
|||
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() {
|
||||
const {containerPaddingTop} = this.props.collapsibleStack;
|
||||
return (
|
||||
<View
|
||||
style={{flex: 1}}
|
||||
>
|
||||
<WebSectionList
|
||||
{...this.props}
|
||||
createDataset={this.createDataset}
|
||||
autoRefreshTime={REFRESH_TIME}
|
||||
refreshOnFocus={true}
|
||||
fetchUrl={DATA_URL}
|
||||
renderItem={this.getRenderItem}
|
||||
itemHeight={FEED_ITEM_HEIGHT}
|
||||
onScroll={this.onScroll}
|
||||
showError={false}
|
||||
/>
|
||||
<View style={{
|
||||
position: "absolute",
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
}}>
|
||||
<WebSectionList
|
||||
{...this.props}
|
||||
createDataset={this.createDataset}
|
||||
autoRefreshTime={REFRESH_TIME}
|
||||
refreshOnFocus={true}
|
||||
fetchUrl={DATA_URL}
|
||||
renderItem={this.getRenderItem}
|
||||
itemHeight={FEED_ITEM_HEIGHT}
|
||||
onScroll={this.onScroll}
|
||||
showError={false}
|
||||
/>
|
||||
</View>
|
||||
<AnimatedFAB
|
||||
{...this.props}
|
||||
ref={this.fabRef}
|
||||
|
|
@ -562,9 +597,32 @@ class HomeScreen extends React.Component<Props, State> {
|
|||
visible={this.state.dialogVisible}
|
||||
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>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
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})
|
||||
}
|
||||
this.state = {
|
||||
bannerVisible:
|
||||
AsyncStorageManager.getInstance().preferences.planexShowBanner.current === '1' &&
|
||||
AsyncStorageManager.getInstance().preferences.defaultStartScreen.current !== 'Planex',
|
||||
bannerVisible: false,
|
||||
dialogVisible: false,
|
||||
dialogTitle: "",
|
||||
dialogMessage: "",
|
||||
|
|
@ -163,6 +161,15 @@ class PlanexScreen extends React.Component<Props, State> {
|
|||
|
||||
componentDidMount() {
|
||||
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 = () => {
|
||||
|
|
@ -315,7 +322,10 @@ class PlanexScreen extends React.Component<Props, State> {
|
|||
: <View style={{height: '100%'}}>{this.getWebView()}</View>}
|
||||
</View>
|
||||
<Banner
|
||||
style={{marginTop: containerPaddingTop,}}
|
||||
style={{
|
||||
marginTop: containerPaddingTop,
|
||||
backgroundColor: this.props.theme.colors.surface
|
||||
}}
|
||||
visible={this.state.bannerVisible}
|
||||
actions={[
|
||||
{
|
||||
|
|
@ -329,7 +339,7 @@ class PlanexScreen extends React.Component<Props, State> {
|
|||
|
||||
]}
|
||||
icon={() => <Avatar.Icon
|
||||
icon={'information'}
|
||||
icon={'power'}
|
||||
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,
|
||||
modalCurrentDisplayItem: null,
|
||||
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}/>
|
||||
</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}/>
|
||||
</View>
|
||||
<Banner
|
||||
style={{marginTop: containerPaddingTop,}}
|
||||
style={{
|
||||
marginTop: containerPaddingTop,
|
||||
backgroundColor: this.props.theme.colors.surface
|
||||
}}
|
||||
visible={this.state.bannerVisible}
|
||||
actions={[
|
||||
{
|
||||
label: 'OK',
|
||||
label: i18n.t('proxiwashScreen.bannerButton'),
|
||||
onPress: this.onHideBanner,
|
||||
},
|
||||
]}
|
||||
icon={() => <Avatar.Icon
|
||||
icon={'information'}
|
||||
icon={'bell'}
|
||||
size={40}
|
||||
/>}
|
||||
>
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
import * as React from 'react';
|
||||
import WebViewScreen from "../../../components/Screens/WebViewScreen";
|
||||
import {CommonActions} from "@react-navigation/native";
|
||||
|
||||
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) {
|
||||
path = props.route.params.path;
|
||||
path = path.replace(URL, '');
|
||||
// reset params to prevent infinite loop
|
||||
props.navigation.dispatch(CommonActions.setParams({path: null}));
|
||||
}
|
||||
}
|
||||
console.log(URL + path);
|
||||
return (
|
||||
<WebViewScreen
|
||||
{...props}
|
||||
|
|
|
|||
|
|
@ -109,6 +109,11 @@
|
|||
"amicaleTitle": "The Amicale",
|
||||
"amicaleConnect": "Login",
|
||||
"amicaleConnected": "See available services"
|
||||
},
|
||||
"loginBanner": {
|
||||
"login": "Login",
|
||||
"later": "Later",
|
||||
"message": "Login to your Amicale account to get access to more services!"
|
||||
}
|
||||
},
|
||||
"aboutScreen": {
|
||||
|
|
@ -174,6 +179,7 @@
|
|||
"enableNotificationsTip": "Click on a running machine to enable notifications",
|
||||
"numAvailable": "available",
|
||||
"numAvailablePlural": "available",
|
||||
"bannerButton": "Got it!",
|
||||
"modal": {
|
||||
"enableNotifications": "Notify me",
|
||||
"disableNotifications": "Stop notifications",
|
||||
|
|
|
|||
|
|
@ -109,7 +109,13 @@
|
|||
"amicaleTitle": "L'Amicale",
|
||||
"amicaleConnect": "Se connecter",
|
||||
"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": {
|
||||
"buttonDesc": "Informations sur l'appli et son créateur",
|
||||
|
|
@ -174,6 +180,7 @@
|
|||
"enableNotificationsTip": "Cliquez sur une machine en cours pour activer les notifications",
|
||||
"numAvailable": "disponible",
|
||||
"numAvailablePlural": "disponibles",
|
||||
"bannerButton": "Compris !",
|
||||
"modal": {
|
||||
"enableNotifications": "Me Notifier",
|
||||
"disableNotifications": "Désactiver les notifications",
|
||||
|
|
|
|||
Loading…
Reference in a new issue