Compare commits

..

No commits in common. "06d01e98b08fff55f5091583b7a85ffd1efab39d" and "98359dba7d13b402a595fce1caea20d66a441948" have entirely different histories.

9 changed files with 35 additions and 123 deletions

View file

@ -59,11 +59,6 @@ export default class AsyncStorageManager {
default: 'home',
current: '',
},
homeShowBanner: {
key: 'homeShowBanner',
default: '1',
current: '',
},
proxiwashShowBanner: {
key: 'proxiwashShowBanner',
default: '1',

View file

@ -1,7 +1,7 @@
// @flow
import * as React from 'react';
import {Animated, KeyboardAvoidingView, StyleSheet, View} from "react-native";
import {Animated, KeyboardAvoidingView, Linking, 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,6 +70,7 @@ class LoginScreen extends React.Component<Props, State> {
else
this.nextScreen = null;
}
console.log(this.nextScreen);
}
showErrorDialog = (error: number) =>
@ -87,7 +88,7 @@ class LoginScreen extends React.Component<Props, State> {
this.props.navigation.replace(this.nextScreen);
};
onResetPasswordClick = () => this.props.navigation.navigate('amicale-website', {path: RESET_PASSWORD_PATH});
onResetPasswordClick = () => Linking.openURL(RESET_PASSWORD_PATH);
validateEmail = () => this.setState({isEmailValidated: true});

View file

@ -245,7 +245,10 @@ class ProfileScreen extends React.Component<Props, State> {
<Button
icon="account-edit"
mode="contained"
onPress={() => this.props.navigation.navigate('amicale-website', {path: this.data.link})}
onPress={() => this.props.navigation.navigate('amicale-website', {
screen: 'amicale-website',
params: {path: this.data.link}
})}
style={styles.editButton}>
{i18n.t("profileScreen.editInformation")}
</Button>

View file

@ -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 {Avatar, Banner, withTheme} from 'react-native-paper';
import {withTheme} from 'react-native-paper';
import FeedItem from "../../components/Home/FeedItem";
import SquareDashboardItem from "../../components/Home/SmallDashboardItem";
import PreviewEventDashboardItem from "../../components/Home/PreviewEventDashboardItem";
@ -19,9 +19,6 @@ 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";
@ -98,12 +95,10 @@ type Props = {
navigation: StackNavigationProp,
route: { params: any, ... },
theme: CustomTheme,
collapsibleStack: Collapsible,
}
type State = {
dialogVisible: boolean,
bannerVisible: boolean,
}
/**
@ -120,7 +115,6 @@ class HomeScreen extends React.Component<Props, State> {
state = {
dialogVisible: false,
bannerVisible: false,
}
constructor(props) {
@ -146,11 +140,6 @@ 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 = () => {
@ -175,7 +164,7 @@ class HomeScreen extends React.Component<Props, State> {
};
getHeaderButton = () => {
let onPressLog = () => this.props.navigation.navigate("login", {nextScreen: "profile"});
let onPressLog = () => this.props.navigation.navigate("login");
let logIcon = "login";
let logColor = this.props.theme.colors.primary;
if (this.isLoggedIn) {
@ -546,46 +535,22 @@ 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}}
>
<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>
<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}
/>
<AnimatedFAB
{...this.props}
ref={this.fabRef}
@ -597,32 +562,9 @@ 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 withCollapsible(withTheme(HomeScreen));
export default withTheme(HomeScreen);

View file

@ -150,7 +150,9 @@ class PlanexScreen extends React.Component<Props, State> {
props.navigation.setOptions({title: currentGroup.name})
}
this.state = {
bannerVisible: false,
bannerVisible:
AsyncStorageManager.getInstance().preferences.planexShowBanner.current === '1' &&
AsyncStorageManager.getInstance().preferences.defaultStartScreen.current !== 'Planex',
dialogVisible: false,
dialogTitle: "",
dialogMessage: "",
@ -161,15 +163,6 @@ 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 = () => {
@ -322,10 +315,7 @@ class PlanexScreen extends React.Component<Props, State> {
: <View style={{height: '100%'}}>{this.getWebView()}</View>}
</View>
<Banner
style={{
marginTop: containerPaddingTop,
backgroundColor: this.props.theme.colors.surface
}}
style={{marginTop: containerPaddingTop,}}
visible={this.state.bannerVisible}
actions={[
{
@ -339,7 +329,7 @@ class PlanexScreen extends React.Component<Props, State> {
]}
icon={() => <Avatar.Icon
icon={'power'}
icon={'information'}
size={40}
/>}
>
@ -361,4 +351,4 @@ class PlanexScreen extends React.Component<Props, State> {
}
}
export default withCollapsible(withTheme(PlanexScreen));
export default withCollapsible(withTheme(PlanexScreen));

View file

@ -68,7 +68,7 @@ class ProxiwashScreen extends React.Component<Props, State> {
refreshing: false,
modalCurrentDisplayItem: null,
machinesWatched: JSON.parse(AsyncStorageManager.getInstance().preferences.proxiwashWatchedMachines.current),
bannerVisible: false,
bannerVisible: AsyncStorageManager.getInstance().preferences.proxiwashShowBanner.current === '1',
};
/**
@ -107,11 +107,6 @@ 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"})
}
/**
@ -422,19 +417,16 @@ class ProxiwashScreen extends React.Component<Props, State> {
updateData={this.state.machinesWatched.length}/>
</View>
<Banner
style={{
marginTop: containerPaddingTop,
backgroundColor: this.props.theme.colors.surface
}}
style={{marginTop: containerPaddingTop,}}
visible={this.state.bannerVisible}
actions={[
{
label: i18n.t('proxiwashScreen.bannerButton'),
label: 'OK',
onPress: this.onHideBanner,
},
]}
icon={() => <Avatar.Icon
icon={'bell'}
icon={'information'}
size={40}
/>}
>

View file

@ -2,6 +2,7 @@
import * as React from 'react';
import WebViewScreen from "../../../components/Screens/WebViewScreen";
import {CommonActions} from "@react-navigation/native";
const URL = 'https://www.amicale-insat.fr/';
/**
@ -14,9 +15,10 @@ 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}

View file

@ -109,11 +109,6 @@
"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": {
@ -179,7 +174,6 @@
"enableNotificationsTip": "Click on a running machine to enable notifications",
"numAvailable": "available",
"numAvailablePlural": "available",
"bannerButton": "Got it!",
"modal": {
"enableNotifications": "Notify me",
"disableNotifications": "Stop notifications",

View file

@ -109,13 +109,7 @@
"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",
@ -180,7 +174,6 @@
"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",