Compare commits

..

No commits in common. "2c3f89816bdd893cf4231dea5ded30cb3974848e" and "d5e1e6c7eb40d0b8b4ab79fbcab746155083c167" have entirely different histories.

4 changed files with 61 additions and 53 deletions

View file

@ -99,9 +99,7 @@ class WebSectionList<T> extends React.PureComponent<PropsType<T>, StateType> {
*/
onScreenFocus = () => {
const {props} = this;
if (props.refreshOnFocus && this.lastRefresh) {
setTimeout(this.onRefresh, 200);
}
if (props.refreshOnFocus && this.lastRefresh) this.onRefresh();
if (props.autoRefreshTime > 0)
this.refreshInterval = setInterval(this.onRefresh, props.autoRefreshTime);
};

View file

@ -17,26 +17,4 @@ export default {
5: 'alert',
6: 'help-circle-outline',
},
washinsa: {
id: 'washinsa',
title: 'screens.proxiwash.washinsa.title',
subtitle: 'screens.proxiwash.washinsa.subtitle',
description: 'screens.proxiwash.washinsa.description',
tarif: 'screens.proxiwash.washinsa.tariff',
paymentMethods: 'screens.proxiwash.washinsa.paymentMethods',
icon: 'school-outline',
url:
'https://etud.insa-toulouse.fr/~amicale_app/v2/washinsa/washinsa_data.json',
},
tripodeB: {
id: 'tripodeB',
title: 'screens.proxiwash.tripodeB.title',
subtitle: 'screens.proxiwash.tripodeB.subtitle',
description: 'screens.proxiwash.tripodeB.description',
tarif: 'screens.proxiwash.tripodeB.tariff',
paymentMethods: 'screens.proxiwash.tripodeB.paymentMethods',
icon: 'domain',
url:
'https://etud.insa-toulouse.fr/~amicale_app/v2/washinsa/tripode_b_data.json',
},
};

View file

@ -6,11 +6,10 @@ import i18n from 'i18n-js';
import {Card, Avatar, Paragraph, Title} from 'react-native-paper';
import CollapsibleScrollView from '../../components/Collapsible/CollapsibleScrollView';
import type {CardTitleIconPropsType} from '../../constants/PaperStyles';
import ProxiwashConstants from '../../constants/ProxiwashConstants';
const LOGO = 'https://etud.insa-toulouse.fr/~amicale_app/images/Proxiwash.png';
export type LaundromatType = {
export type LaverieType = {
id: string,
title: string,
subtitle: string,
@ -21,11 +20,36 @@ export type LaundromatType = {
url: string,
};
export const PROXIWASH_DATA = {
washinsa: {
id: 'washinsa',
title: 'screens.proxiwash.washinsa.title',
subtitle: 'screens.proxiwash.washinsa.subtitle',
description: 'screens.proxiwash.washinsa.description',
tarif: 'screens.proxiwash.washinsa.tariff',
paymentMethods: 'screens.proxiwash.washinsa.paymentMethods',
icon: 'school-outline',
url:
'https://etud.insa-toulouse.fr/~amicale_app/v2/washinsa/washinsa_data.json',
},
tripodeB: {
id: 'tripodeB',
title: 'screens.proxiwash.tripodeB.title',
subtitle: 'screens.proxiwash.tripodeB.subtitle',
description: 'screens.proxiwash.tripodeB.description',
tarif: 'screens.proxiwash.tripodeB.tariff',
paymentMethods: 'screens.proxiwash.tripodeB.paymentMethods',
icon: 'domain',
url:
'https://etud.insa-toulouse.fr/~amicale_app/v2/washinsa/tripode_b_data.json',
},
};
/**
* Class defining the proxiwash about screen.
*/
export default class ProxiwashAboutScreen extends React.Component<null> {
static getCardItem(item: LaundromatType): React.Node {
static getCardItem(item: LaverieType): React.Node {
return (
<Card style={{margin: 5}}>
<Card.Title
@ -64,9 +88,9 @@ export default class ProxiwashAboutScreen extends React.Component<null> {
/>
</View>
{ProxiwashAboutScreen.getCardItem(ProxiwashConstants.washinsa)}
{ProxiwashAboutScreen.getCardItem(PROXIWASH_DATA.washinsa)}
{ProxiwashAboutScreen.getCardItem(ProxiwashConstants.tripodeB)}
{ProxiwashAboutScreen.getCardItem(PROXIWASH_DATA.tripodeB)}
<Card style={{margin: 5}}>
<Card.Title

View file

@ -3,7 +3,7 @@
import * as React from 'react';
import {Alert, View} from 'react-native';
import i18n from 'i18n-js';
import {Avatar, Button, Card, Text, withTheme} from 'react-native-paper';
import {Avatar, Button, Card, List, Text, withTheme} from 'react-native-paper';
import {StackNavigationProp} from '@react-navigation/stack';
import {Modalize} from 'react-native-modalize';
import WebSectionList from '../../components/Screens/WebSectionList';
@ -26,7 +26,8 @@ import {
import {MASCOT_STYLE} from '../../components/Mascot/Mascot';
import MascotPopup from '../../components/Mascot/MascotPopup';
import type {SectionListDataType} from '../../components/Screens/WebSectionList';
import type {LaundromatType} from './ProxiwashAboutScreen';
import type {ListIconPropsType} from '../../constants/PaperStyles';
import {PROXIWASH_DATA} from './ProxiwashAboutScreen';
const modalStateStrings = {};
@ -122,11 +123,6 @@ class ProxiwashScreen extends React.Component<PropsType, StateType> {
navigation.setOptions({
headerRight: (): React.Node => (
<MaterialHeaderButtons>
<Item
title="switch"
iconName="swap-horizontal"
onPress={():void => navigation.navigate('settings')}
/>
<Item
title="information"
iconName="information"
@ -135,19 +131,6 @@ class ProxiwashScreen extends React.Component<PropsType, StateType> {
</MaterialHeaderButtons>
),
});
navigation.addListener('focus', this.onScreenFocus);
}
onScreenFocus = () => {
const {state} = this;
const selected = AsyncStorageManager.getString(
AsyncStorageManager.PREFERENCES.selectedWash.key,
);
if (selected !== state.selectedWash) {
this.setState({
selectedWash: selected
});
}
}
/**
@ -360,6 +343,31 @@ class ProxiwashScreen extends React.Component<PropsType, StateType> {
return count;
}
/**
* Gets a chevron icon
*
* @param props
* @return {*}
*/
static getChevronIcon(props: ListIconPropsType): React.Node {
return (
<List.Icon color={props.color} style={props.style} icon="chevron-right" />
);
}
/**
* Gets a custom list item icon
*
* @param item The item to show the icon for
* @param props
* @return {*}
*/
static getItemIcon(item: ListItemType, props: ListIconPropsType): React.Node {
return (
<List.Icon color={props.color} style={props.style} icon={item.icon} />
);
}
/**
* Creates the dataset to be used by the FlatList
*
@ -464,13 +472,13 @@ class ProxiwashScreen extends React.Component<PropsType, StateType> {
render(): React.Node {
const {state} = this;
const {navigation} = this.props;
let data: LaundromatType;
let data: LaverieType;
switch (state.selectedWash) {
case 'tripodeB':
data = ProxiwashConstants.tripodeB;
data = PROXIWASH_DATA.tripodeB;
break;
default:
data = ProxiwashConstants.washinsa;
data = PROXIWASH_DATA.washinsa;
}
return (
<View