forked from vergnet/application-amicale
Compare commits
12 commits
b7bc46f800
...
82f7af58bd
Author | SHA1 | Date | |
---|---|---|---|
|
82f7af58bd | ||
|
c5b6e128ee | ||
|
5b6176a361 | ||
|
02e30f87cf | ||
|
83a3354d1e | ||
|
ce1227901c | ||
|
5a92b5096a | ||
|
115c90b712 | ||
|
41a17a9a91 | ||
|
7867e12a49 | ||
|
f8f5749478 | ||
|
3de49732b9 |
11 changed files with 150 additions and 190 deletions
4
App.js
4
App.js
|
@ -7,7 +7,6 @@ import {Provider as PaperProvider} from 'react-native-paper';
|
||||||
import {setSafeBounceHeight} from 'react-navigation-collapsible';
|
import {setSafeBounceHeight} from 'react-navigation-collapsible';
|
||||||
import SplashScreen from 'react-native-splash-screen';
|
import SplashScreen from 'react-native-splash-screen';
|
||||||
import {OverflowMenuProvider} from 'react-navigation-header-buttons';
|
import {OverflowMenuProvider} from 'react-navigation-header-buttons';
|
||||||
import LocaleManager from './src/managers/LocaleManager';
|
|
||||||
import AsyncStorageManager from './src/managers/AsyncStorageManager';
|
import AsyncStorageManager from './src/managers/AsyncStorageManager';
|
||||||
import CustomIntroSlider from './src/components/Overrides/CustomIntroSlider';
|
import CustomIntroSlider from './src/components/Overrides/CustomIntroSlider';
|
||||||
import type {CustomThemeType} from './src/managers/ThemeManager';
|
import type {CustomThemeType} from './src/managers/ThemeManager';
|
||||||
|
@ -19,6 +18,7 @@ import ConnectionManager from './src/managers/ConnectionManager';
|
||||||
import type {ParsedUrlDataType} from './src/utils/URLHandler';
|
import type {ParsedUrlDataType} from './src/utils/URLHandler';
|
||||||
import URLHandler from './src/utils/URLHandler';
|
import URLHandler from './src/utils/URLHandler';
|
||||||
import {setupStatusBar} from './src/utils/Utils';
|
import {setupStatusBar} from './src/utils/Utils';
|
||||||
|
import initLocales from './src/utils/Locales';
|
||||||
|
|
||||||
// Native optimizations https://reactnavigation.org/docs/react-native-screens
|
// Native optimizations https://reactnavigation.org/docs/react-native-screens
|
||||||
// Crashes app when navigating away from webview on android 9+
|
// Crashes app when navigating away from webview on android 9+
|
||||||
|
@ -56,7 +56,7 @@ export default class App extends React.Component<null, StateType> {
|
||||||
showAprilFools: false,
|
showAprilFools: false,
|
||||||
currentTheme: null,
|
currentTheme: null,
|
||||||
};
|
};
|
||||||
LocaleManager.initTranslations();
|
initLocales();
|
||||||
this.navigatorRef = React.createRef();
|
this.navigatorRef = React.createRef();
|
||||||
this.defaultHomeRoute = null;
|
this.defaultHomeRoute = null;
|
||||||
this.defaultHomeData = {};
|
this.defaultHomeData = {};
|
||||||
|
|
|
@ -62,8 +62,8 @@
|
||||||
},
|
},
|
||||||
"tripodeB": {
|
"tripodeB": {
|
||||||
"title": "Tripode B laundromat",
|
"title": "Tripode B laundromat",
|
||||||
"subtitle": "[A TRADUIRE] Celle de ceux qui habite prés du métro.",
|
"subtitle": "That of those who live near the metro.",
|
||||||
"description": "[A TRADUIRE] C'est le service de laverie proposé par le crous pour les résidences Tripode B et C ainsi que Thalès et Pythagore. Le local situé au pied du Tripode B en face de de la résidence Pythagore avec ses 2 sèche-linges et 6 machines est ouvert 7J/7 de 7h à 23h. En plus des machine 6kg il y as une machine de 10kg.",
|
"description": "This is the washing service operated by the CROUS for the Tripode B and C residences as well as Thalès and Pythagore. The room is at the foot of Tripod B in front of the Pythagore residence, with 2 dryers and 6 washers, is open 7d/7 from 7am to 11pm. In addition to the 6kg washers there is one 10kg washers",
|
||||||
"tariff": "Washers 6kg: 2.60€ the washer + 0.90€ with detergent.\nWashers 10kg: 4.90€ the washer + 1.50€ with detergent.\nDryers 14kg: 0.40€ for 5min of dryer usage.",
|
"tariff": "Washers 6kg: 2.60€ the washer + 0.90€ with detergent.\nWashers 10kg: 4.90€ the washer + 1.50€ with detergent.\nDryers 14kg: 0.40€ for 5min of dryer usage.",
|
||||||
"paymentMethods": "Carte bancaire acceptée."
|
"paymentMethods": "Carte bancaire acceptée."
|
||||||
},
|
},
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
"tripodeB": {
|
"tripodeB": {
|
||||||
"title": "Laverie Tripode B",
|
"title": "Laverie Tripode B",
|
||||||
"subtitle": "Celle de ceux qui habite prés du métro.",
|
"subtitle": "Celle de ceux qui habite prés du métro.",
|
||||||
"description": "C'est le service de laverie proposé par le crous pour les résidences Tripode B et C ainsi que Thalès et Pythagore. Le local situé au pied du Tripode B en face de de la résidence Pythagore avec ses 2 sèche-linges et 6 machines est ouvert 7J/7 de 7h à 23h. En plus des machine 6kg il y as une machine de 10kg.",
|
"description": "C'est le service de laverie proposé par le CROUS pour les résidences Tripode B et C ainsi que Thalès et Pythagore. Le local situé au pied du Tripode B en face de de la résidence Pythagore avec ses 2 sèche-linges et 6 machines est ouvert 7J/7 de 7h à 23h. En plus des machine 6kg il y as une machine de 10kg.",
|
||||||
"tariff": "Lave-Linges 6kg: 2.60€ la machine + 0.90€ avec la lessive.\nLave-Linges 10kg: 4.90€ la machine + 1.50€ avec la lessive.\nSèche-Linges 14kg: 0.40€ pour 5min de sèche linge.",
|
"tariff": "Lave-Linges 6kg: 2.60€ la machine + 0.90€ avec la lessive.\nLave-Linges 10kg: 4.90€ la machine + 1.50€ avec la lessive.\nSèche-Linges 14kg: 0.40€ pour 5min de sèche linge.",
|
||||||
"paymentMethods": "Carte bancaire acceptée."
|
"paymentMethods": "Carte bancaire acceptée."
|
||||||
},
|
},
|
||||||
|
|
|
@ -69,7 +69,7 @@ class ProxiwashListItem extends React.Component<PropsType> {
|
||||||
this.updateStateStrings();
|
this.updateStateStrings();
|
||||||
|
|
||||||
let displayNumber = props.item.number;
|
let displayNumber = props.item.number;
|
||||||
const displayMaxWeight = props.item['maxWeight '];
|
const displayMaxWeight = props.item.maxWeight;
|
||||||
if (AprilFoolsManager.getInstance().isAprilFoolsEnabled())
|
if (AprilFoolsManager.getInstance().isAprilFoolsEnabled())
|
||||||
displayNumber = AprilFoolsManager.getProxiwashMachineDisplayNumber(
|
displayNumber = AprilFoolsManager.getProxiwashMachineDisplayNumber(
|
||||||
parseInt(props.item.number, 10),
|
parseInt(props.item.number, 10),
|
||||||
|
|
|
@ -1,24 +0,0 @@
|
||||||
// @flow
|
|
||||||
|
|
||||||
import i18n from 'i18n-js';
|
|
||||||
import * as RNLocalize from 'react-native-localize';
|
|
||||||
|
|
||||||
import en from '../../locales/en.json';
|
|
||||||
import fr from '../../locales/fr.json';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Static class used to manage locales
|
|
||||||
*/
|
|
||||||
export default class LocaleManager {
|
|
||||||
/**
|
|
||||||
* Initialize translations using language files
|
|
||||||
*/
|
|
||||||
static initTranslations() {
|
|
||||||
i18n.fallbacks = true;
|
|
||||||
i18n.translations = {fr, en};
|
|
||||||
i18n.locale = RNLocalize.findBestAvailableLanguage([
|
|
||||||
'en',
|
|
||||||
'fr',
|
|
||||||
]).languageTag;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -29,7 +29,6 @@ import {
|
||||||
getWebsiteStack,
|
getWebsiteStack,
|
||||||
} from '../utils/CollapsibleUtils';
|
} from '../utils/CollapsibleUtils';
|
||||||
import Mascot, {MASCOT_STYLE} from '../components/Mascot/Mascot';
|
import Mascot, {MASCOT_STYLE} from '../components/Mascot/Mascot';
|
||||||
import ProxiwashSettingsScreen from '../screens/Proxiwash/ProxiwashSettingsScreen';
|
|
||||||
|
|
||||||
const modalTransition =
|
const modalTransition =
|
||||||
Platform.OS === 'ios'
|
Platform.OS === 'ios'
|
||||||
|
@ -92,12 +91,6 @@ function ProxiwashStackComponent(): React.Node {
|
||||||
ProxiwashAboutScreen,
|
ProxiwashAboutScreen,
|
||||||
i18n.t('screens.proxiwash.title'),
|
i18n.t('screens.proxiwash.title'),
|
||||||
)}
|
)}
|
||||||
{createScreenCollapsibleStack(
|
|
||||||
'proxiwash-settings',
|
|
||||||
ProxiwashStack,
|
|
||||||
ProxiwashSettingsScreen,
|
|
||||||
i18n.t('screens.proxiwash.title'),
|
|
||||||
)}
|
|
||||||
</ProxiwashStack.Navigator>
|
</ProxiwashStack.Navigator>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,14 @@
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import {View} from 'react-native';
|
import {View} from 'react-native';
|
||||||
import i18n from 'i18n-js';
|
import i18n from 'i18n-js';
|
||||||
import {Card, List, Switch, ToggleButton, withTheme} from 'react-native-paper';
|
import {
|
||||||
|
RadioButton,
|
||||||
|
Card,
|
||||||
|
List,
|
||||||
|
Switch,
|
||||||
|
ToggleButton,
|
||||||
|
withTheme,
|
||||||
|
} from 'react-native-paper';
|
||||||
import {Appearance} from 'react-native-appearance';
|
import {Appearance} from 'react-native-appearance';
|
||||||
import {StackNavigationProp} from '@react-navigation/stack';
|
import {StackNavigationProp} from '@react-navigation/stack';
|
||||||
import type {CustomThemeType} from '../../../managers/ThemeManager';
|
import type {CustomThemeType} from '../../../managers/ThemeManager';
|
||||||
|
@ -22,6 +29,7 @@ type StateType = {
|
||||||
nightMode: boolean,
|
nightMode: boolean,
|
||||||
nightModeFollowSystem: boolean,
|
nightModeFollowSystem: boolean,
|
||||||
startScreenPickerSelected: string,
|
startScreenPickerSelected: string,
|
||||||
|
selectedWash: string,
|
||||||
isDebugUnlocked: boolean,
|
isDebugUnlocked: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -52,6 +60,9 @@ class SettingsScreen extends React.Component<PropsType, StateType> {
|
||||||
startScreenPickerSelected: AsyncStorageManager.getString(
|
startScreenPickerSelected: AsyncStorageManager.getString(
|
||||||
AsyncStorageManager.PREFERENCES.defaultStartScreen.key,
|
AsyncStorageManager.PREFERENCES.defaultStartScreen.key,
|
||||||
),
|
),
|
||||||
|
selectedWash: AsyncStorageManager.getString(
|
||||||
|
AsyncStorageManager.PREFERENCES.selectedWash.key,
|
||||||
|
),
|
||||||
isDebugUnlocked: AsyncStorageManager.getBool(
|
isDebugUnlocked: AsyncStorageManager.getBool(
|
||||||
AsyncStorageManager.PREFERENCES.debugUnlocked.key,
|
AsyncStorageManager.PREFERENCES.debugUnlocked.key,
|
||||||
),
|
),
|
||||||
|
@ -106,6 +117,29 @@ class SettingsScreen extends React.Component<PropsType, StateType> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a radio picker allowing the user to select the proxiwash
|
||||||
|
*
|
||||||
|
* @returns {React.Node}
|
||||||
|
*/
|
||||||
|
getProxiwashChangePicker(): React.Node {
|
||||||
|
const {selectedWash} = this.state;
|
||||||
|
return (
|
||||||
|
<RadioButton.Group
|
||||||
|
onValueChange={this.onSelectWashValueChange}
|
||||||
|
value={selectedWash}>
|
||||||
|
<RadioButton.Item
|
||||||
|
label={i18n.t('screens.proxiwash.washinsa.title')}
|
||||||
|
value="washinsa"
|
||||||
|
/>
|
||||||
|
<RadioButton.Item
|
||||||
|
label={i18n.t('screens.proxiwash.tripodeB.title')}
|
||||||
|
value="tripodeB"
|
||||||
|
/>
|
||||||
|
</RadioButton.Group>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a picker allowing the user to select the start screen
|
* Returns a picker allowing the user to select the start screen
|
||||||
*
|
*
|
||||||
|
@ -212,6 +246,21 @@ class SettingsScreen extends React.Component<PropsType, StateType> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Saves the value for the proxiwash selected wash
|
||||||
|
*
|
||||||
|
* @param value The value to store
|
||||||
|
*/
|
||||||
|
onSelectWashValueChange = (value: string) => {
|
||||||
|
if (value != null) {
|
||||||
|
this.setState({selectedWash: value});
|
||||||
|
AsyncStorageManager.set(
|
||||||
|
AsyncStorageManager.PREFERENCES.selectedWash.key,
|
||||||
|
value,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unlocks debug mode and saves its state to user preferences
|
* Unlocks debug mode and saves its state to user preferences
|
||||||
*/
|
*/
|
||||||
|
@ -288,6 +337,20 @@ class SettingsScreen extends React.Component<PropsType, StateType> {
|
||||||
<View style={{marginLeft: 30}}>
|
<View style={{marginLeft: 30}}>
|
||||||
{this.getProxiwashNotifPicker()}
|
{this.getProxiwashNotifPicker()}
|
||||||
</View>
|
</View>
|
||||||
|
<List.Item
|
||||||
|
title="Test"
|
||||||
|
description="Test"
|
||||||
|
left={(props: ListIconPropsType): React.Node => (
|
||||||
|
<List.Icon
|
||||||
|
color={props.color}
|
||||||
|
style={props.style}
|
||||||
|
icon="washing-machine"
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<View style={{marginLeft: 30}}>
|
||||||
|
{this.getProxiwashChangePicker()}
|
||||||
|
</View>
|
||||||
</List.Section>
|
</List.Section>
|
||||||
</Card>
|
</Card>
|
||||||
<Card style={{margin: 5}}>
|
<Card style={{margin: 5}}>
|
||||||
|
|
|
@ -9,11 +9,67 @@ import type {CardTitleIconPropsType} from '../../constants/PaperStyles';
|
||||||
|
|
||||||
const LOGO = 'https://etud.insa-toulouse.fr/~amicale_app/images/Proxiwash.png';
|
const LOGO = 'https://etud.insa-toulouse.fr/~amicale_app/images/Proxiwash.png';
|
||||||
|
|
||||||
|
export type LaverieType = {
|
||||||
|
id: string,
|
||||||
|
title: string,
|
||||||
|
subtitle: string,
|
||||||
|
description: string,
|
||||||
|
tarif: string,
|
||||||
|
paymentMethods: string,
|
||||||
|
icon: string,
|
||||||
|
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.
|
* Class defining the proxiwash about screen.
|
||||||
*/
|
*/
|
||||||
// eslint-disable-next-line react/prefer-stateless-function
|
|
||||||
export default class ProxiwashAboutScreen extends React.Component<null> {
|
export default class ProxiwashAboutScreen extends React.Component<null> {
|
||||||
|
static getCardItem(item: LaverieType): React.Node {
|
||||||
|
return (
|
||||||
|
<Card style={{margin: 5}}>
|
||||||
|
<Card.Title
|
||||||
|
title={i18n.t(item.title)}
|
||||||
|
subtitle={i18n.t(item.subtitle)}
|
||||||
|
left={(iconProps: CardTitleIconPropsType): React.Node => (
|
||||||
|
<Avatar.Icon size={iconProps.size} icon={item.icon} />
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
<Card.Content>
|
||||||
|
<Paragraph>{i18n.t(item.description)}</Paragraph>
|
||||||
|
<Title>{i18n.t('screens.proxiwash.tariffs')}</Title>
|
||||||
|
<Paragraph>{i18n.t(item.tarif)}</Paragraph>
|
||||||
|
<Title>{i18n.t('screens.proxiwash.paymentMethods')}</Title>
|
||||||
|
<Paragraph>{i18n.t(item.paymentMethods)}</Paragraph>
|
||||||
|
</Card.Content>
|
||||||
|
</Card>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
render(): React.Node {
|
render(): React.Node {
|
||||||
return (
|
return (
|
||||||
<CollapsibleScrollView style={{padding: 5}} hasTab>
|
<CollapsibleScrollView style={{padding: 5}} hasTab>
|
||||||
|
@ -32,6 +88,10 @@ export default class ProxiwashAboutScreen extends React.Component<null> {
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
|
{ProxiwashAboutScreen.getCardItem(PROXIWASH_DATA.washinsa)}
|
||||||
|
|
||||||
|
{ProxiwashAboutScreen.getCardItem(PROXIWASH_DATA.tripodeB)}
|
||||||
|
|
||||||
<Card style={{margin: 5}}>
|
<Card style={{margin: 5}}>
|
||||||
<Card.Title
|
<Card.Title
|
||||||
title={i18n.t('screens.proxiwash.dryer')}
|
title={i18n.t('screens.proxiwash.dryer')}
|
||||||
|
|
|
@ -27,7 +27,7 @@ import {MASCOT_STYLE} from '../../components/Mascot/Mascot';
|
||||||
import MascotPopup from '../../components/Mascot/MascotPopup';
|
import MascotPopup from '../../components/Mascot/MascotPopup';
|
||||||
import type {SectionListDataType} from '../../components/Screens/WebSectionList';
|
import type {SectionListDataType} from '../../components/Screens/WebSectionList';
|
||||||
import type {ListIconPropsType} from '../../constants/PaperStyles';
|
import type {ListIconPropsType} from '../../constants/PaperStyles';
|
||||||
import {PROXIWASH_DATA} from './ProxiwashSettingsScreen';
|
import {PROXIWASH_DATA} from './ProxiwashAboutScreen';
|
||||||
|
|
||||||
const modalStateStrings = {};
|
const modalStateStrings = {};
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ const LIST_ITEM_HEIGHT = 64;
|
||||||
export type ProxiwashMachineType = {
|
export type ProxiwashMachineType = {
|
||||||
number: string,
|
number: string,
|
||||||
state: string,
|
state: string,
|
||||||
'maxWeight ': number,
|
maxWeight: number,
|
||||||
startTime: string,
|
startTime: string,
|
||||||
endTime: string,
|
endTime: string,
|
||||||
donePercent: string,
|
donePercent: string,
|
||||||
|
@ -128,11 +128,6 @@ class ProxiwashScreen extends React.Component<PropsType, StateType> {
|
||||||
iconName="information"
|
iconName="information"
|
||||||
onPress={this.onAboutPress}
|
onPress={this.onAboutPress}
|
||||||
/>
|
/>
|
||||||
<Item
|
|
||||||
title="settings"
|
|
||||||
iconName="settings"
|
|
||||||
onPress={this.onSettingsPress}
|
|
||||||
/>
|
|
||||||
</MaterialHeaderButtons>
|
</MaterialHeaderButtons>
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
@ -147,15 +142,6 @@ class ProxiwashScreen extends React.Component<PropsType, StateType> {
|
||||||
navigation.navigate('proxiwash-about');
|
navigation.navigate('proxiwash-about');
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback used when pressing the settings button.
|
|
||||||
* This will open the ProxiwashSettingsScreen.
|
|
||||||
*/
|
|
||||||
onSettingsPress = () => {
|
|
||||||
const {navigation} = this.props;
|
|
||||||
navigation.navigate('proxiwash-settings');
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Callback used when the user clicks on enable notifications for a machine
|
* Callback used when the user clicks on enable notifications for a machine
|
||||||
*
|
*
|
||||||
|
|
|
@ -1,135 +0,0 @@
|
||||||
// @flow
|
|
||||||
|
|
||||||
import * as React from 'react';
|
|
||||||
import {
|
|
||||||
Title,
|
|
||||||
Button,
|
|
||||||
Card,
|
|
||||||
Avatar,
|
|
||||||
withTheme,
|
|
||||||
Paragraph,
|
|
||||||
} from 'react-native-paper';
|
|
||||||
import i18n from 'i18n-js';
|
|
||||||
import CollapsibleScrollView from '../../components/Collapsible/CollapsibleScrollView';
|
|
||||||
import type {CardTitleIconPropsType} from '../../constants/PaperStyles';
|
|
||||||
import AsyncStorageManager from '../../managers/AsyncStorageManager';
|
|
||||||
import ThemeManager from '../../managers/ThemeManager';
|
|
||||||
import type {CustomThemeType} from '../../managers/ThemeManager';
|
|
||||||
|
|
||||||
export type LaverieType = {
|
|
||||||
id: string,
|
|
||||||
title: string,
|
|
||||||
subtitle: string,
|
|
||||||
description: string,
|
|
||||||
tarif: string,
|
|
||||||
paymentMethods: string,
|
|
||||||
icon: string,
|
|
||||||
url: string,
|
|
||||||
};
|
|
||||||
|
|
||||||
export const PROXIWASH_DATA = {
|
|
||||||
washinsa: {
|
|
||||||
id: 'washinsa',
|
|
||||||
title: i18n.t('screens.proxiwash.washinsa.title'),
|
|
||||||
subtitle: i18n.t('screens.proxiwash.washinsa.subtitle'),
|
|
||||||
description: i18n.t('screens.proxiwash.washinsa.description'),
|
|
||||||
tarif: i18n.t('screens.proxiwash.washinsa.tariff'),
|
|
||||||
paymentMethods: i18n.t('screens.proxiwash.washinsa.paymentMethods'),
|
|
||||||
icon: 'school-outline',
|
|
||||||
url:
|
|
||||||
'https://etud.insa-toulouse.fr/~amicale_app/v2/washinsa/washinsa_data.json',
|
|
||||||
},
|
|
||||||
tripodeB: {
|
|
||||||
id: 'tripodeB',
|
|
||||||
title: i18n.t('screens.proxiwash.tripodeB.title'),
|
|
||||||
subtitle: i18n.t('screens.proxiwash.tripodeB.subtitle'),
|
|
||||||
description: i18n.t('screens.proxiwash.tripodeB.description'),
|
|
||||||
tarif: i18n.t('screens.proxiwash.tripodeB.tariff'),
|
|
||||||
paymentMethods: i18n.t('screens.proxiwash.tripodeB.paymentMethods'),
|
|
||||||
icon: 'domain',
|
|
||||||
url:
|
|
||||||
'https://etud.insa-toulouse.fr/~amicale_app/v2/washinsa/tripode_b_data.json',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
type StateType = {
|
|
||||||
selectedWash: string,
|
|
||||||
currentTheme: CustomThemeType,
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Class defining the proxiwash settings screen.
|
|
||||||
*/
|
|
||||||
class ProxiwashSettingsScreen extends React.Component<null, StateType> {
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
this.state = {
|
|
||||||
selectedWash: AsyncStorageManager.getString(
|
|
||||||
AsyncStorageManager.PREFERENCES.selectedWash.key,
|
|
||||||
),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Saves the value for the proxiwash selected wash
|
|
||||||
*
|
|
||||||
* @param value The value to store
|
|
||||||
*/
|
|
||||||
onSelectWashValueChange = (value: string) => {
|
|
||||||
if (value != null) {
|
|
||||||
this.setState({selectedWash: value});
|
|
||||||
AsyncStorageManager.set(
|
|
||||||
AsyncStorageManager.PREFERENCES.selectedWash.key,
|
|
||||||
value,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
getCardItem(item: LaverieType): React.Node {
|
|
||||||
const {selectedWash} = this.state;
|
|
||||||
const onSelectWashValueChange = (): void =>
|
|
||||||
this.onSelectWashValueChange(item.id);
|
|
||||||
let cardStyle = {
|
|
||||||
margin: 5,
|
|
||||||
};
|
|
||||||
if (selectedWash === item.id) {
|
|
||||||
cardStyle = {
|
|
||||||
margin: 5,
|
|
||||||
backgroundColor: ThemeManager.getCurrentTheme().colors
|
|
||||||
.proxiwashUnknownColor,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return (
|
|
||||||
<Card style={cardStyle}>
|
|
||||||
<Card.Title
|
|
||||||
title={item.title}
|
|
||||||
subtitle={item.subtitle}
|
|
||||||
left={(iconProps: CardTitleIconPropsType): React.Node => (
|
|
||||||
<Avatar.Icon size={iconProps.size} icon={item.icon} />
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
<Card.Content>
|
|
||||||
<Paragraph>{item.description}</Paragraph>
|
|
||||||
<Title>{i18n.t('screens.proxiwash.tariffs')}</Title>
|
|
||||||
<Paragraph>{item.tarif}</Paragraph>
|
|
||||||
<Title>{i18n.t('screens.proxiwash.paymentMethods')}</Title>
|
|
||||||
<Paragraph>{item.paymentMethods}</Paragraph>
|
|
||||||
</Card.Content>
|
|
||||||
<Card.Actions>
|
|
||||||
<Button onPress={onSelectWashValueChange}>Select</Button>
|
|
||||||
</Card.Actions>
|
|
||||||
</Card>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
render(): React.Node {
|
|
||||||
return (
|
|
||||||
<CollapsibleScrollView style={{padding: 5}} hasTab>
|
|
||||||
{this.getCardItem(PROXIWASH_DATA.washinsa)}
|
|
||||||
{this.getCardItem(PROXIWASH_DATA.tripodeB)}
|
|
||||||
</CollapsibleScrollView>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default withTheme(ProxiwashSettingsScreen);
|
|
17
src/utils/Locales.js
Normal file
17
src/utils/Locales.js
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
// @flow
|
||||||
|
|
||||||
|
import i18n from 'i18n-js';
|
||||||
|
import * as RNLocalize from 'react-native-localize';
|
||||||
|
|
||||||
|
import en from '../../locales/en.json';
|
||||||
|
import fr from '../../locales/fr.json';
|
||||||
|
|
||||||
|
const initLocales = () => {
|
||||||
|
i18n.fallbacks = true;
|
||||||
|
i18n.translations = {fr, en};
|
||||||
|
i18n.locale = RNLocalize.findBestAvailableLanguage([
|
||||||
|
'en',
|
||||||
|
'fr',
|
||||||
|
]).languageTag;
|
||||||
|
}
|
||||||
|
export default initLocales;
|
Loading…
Reference in a new issue