Changed data source for proximo to use proximo's website

This commit is contained in:
keplyx 2019-08-01 11:04:27 +02:00
parent 054d8f4a33
commit ed597bfa8a
5 changed files with 44 additions and 35 deletions

View file

@ -27,6 +27,7 @@ export default class FetchedDataSectionList extends React.Component<Props, State
willFocusSubscription : function; willFocusSubscription : function;
willBlurSubscription : function; willBlurSubscription : function;
refreshInterval: IntervalID; refreshInterval: IntervalID;
refreshTime: number;
constructor(fetchUrl: string, refreshTime : number) { constructor(fetchUrl: string, refreshTime : number) {
super(); super();

View file

@ -8,9 +8,6 @@ import Touchable from 'react-native-platform-touchable';
import Menu, {MenuItem} from 'react-native-material-menu'; import Menu, {MenuItem} from 'react-native-material-menu';
import i18n from "i18n-js"; import i18n from "i18n-js";
const IMG_URL = "https://etud.insa-toulouse.fr/~vergnet/appli-amicale/img/";
const defaultImage = require('../../assets/image-missing.png');
const sortMode = { const sortMode = {
price: "0", price: "0",
name: '1', name: '1',
@ -217,16 +214,19 @@ export default class ProximoListScreen extends React.Component<Props, State> {
<ListItem <ListItem
thumbnail thumbnail
onPress={() => { onPress={() => {
console.log(IMG_URL + item.name + '.jpg') console.log(item.image)
}} }}
> >
<Left> <Left>
<Thumbnail square source={{uri: IMG_URL + item.name + '.jpg'}}/> <Thumbnail square source={{uri: item.image}}/>
</Left> </Left>
<Body> <Body>
<Text style={{marginLeft: 20}}> <Text style={{marginLeft: 20}}>
{item.name} {item.name}
</Text> </Text>
<Text note style={{marginLeft: 20}}>
{item.quantity + ' ' + i18n.t('proximoScreen.inStock')}
</Text>
</Body> </Body>
<Right style={{flex: 1}}> <Right style={{flex: 1}}>
<Text> <Text>

View file

@ -1,12 +1,13 @@
// @flow // @flow
import * as React from 'react'; import * as React from 'react';
import {View} from 'react-native'
import {Badge, Body, H2, Left, ListItem, Right, Text} from 'native-base'; import {Badge, Body, H2, Left, ListItem, Right, Text} from 'native-base';
import i18n from "i18n-js"; import i18n from "i18n-js";
import CustomMaterialIcon from "../../components/CustomMaterialIcon"; import CustomMaterialIcon from "../../components/CustomMaterialIcon";
import FetchedDataSectionList from "../../components/FetchedDataSectionList"; import FetchedDataSectionList from "../../components/FetchedDataSectionList";
const DATA_URL = "https://etud.insa-toulouse.fr/~vergnet/appli-amicale/dataProximo.json"; const DATA_URL = "https://srv-falcon.etud.insa-toulouse.fr/~proximo/data/stock.json";
const typesIcons = { const typesIcons = {
Nouveau: "alert-decagram", Nouveau: "alert-decagram",
@ -78,33 +79,38 @@ export default class ProximoMainScreen extends FetchedDataSectionList {
} }
getRenderItem(item: Object, section : Object, data : Object) { getRenderItem(item: Object, section : Object, data : Object) {
return ( if (item.data.length > 0) {
<ListItem return (
button <ListItem
thumbnail button
onPress={() => { thumbnail
this.props.navigation.navigate('ProximoListScreen', item); onPress={() => {
}} this.props.navigation.navigate('ProximoListScreen', item);
> }}
<Left> >
<CustomMaterialIcon <Left>
icon={typesIcons[item.type] ? typesIcons[item.type] : typesIcons.Default} <CustomMaterialIcon
fontSize={30} icon={typesIcons[item.type] ? typesIcons[item.type] : typesIcons.Default}
/> fontSize={30}
</Left> />
<Body> </Left>
<Text> <Body>
{item.type} <Text>
</Text> {item.type}
<Badge><Text> </Text>
{item.data.length} {item.data.length > 1 ? i18n.t('proximoScreen.articles') : i18n.t('proximoScreen.article')} <Badge><Text>
</Text></Badge> {item.data.length} {item.data.length > 1 ? i18n.t('proximoScreen.articles') : i18n.t('proximoScreen.article')}
</Body> </Text></Badge>
<Right> </Body>
<CustomMaterialIcon icon="chevron-right"/> <Right>
</Right> <CustomMaterialIcon icon="chevron-right"/>
</ListItem> </Right>
); </ListItem>
);
} else {
return <View/>;
}
} }
getRenderSectionHeader(title: String) { getRenderSectionHeader(title: String) {

View file

@ -49,7 +49,8 @@
"listUpdated": "Article list updated!", "listUpdated": "Article list updated!",
"listUpdateFail": "Error while updating article list", "listUpdateFail": "Error while updating article list",
"loading": "Loading...", "loading": "Loading...",
"listTitle": "Choose a category" "listTitle": "Choose a category",
"inStock": "in stock"
}, },
"proxiwashScreen": { "proxiwashScreen": {
"dryer": "Dryer", "dryer": "Dryer",

View file

@ -49,7 +49,8 @@
"listUpdated": "Liste d'articles mise à jour !", "listUpdated": "Liste d'articles mise à jour !",
"listUpdateFail": "Erreur lors de la mise à jour de la list d'articles", "listUpdateFail": "Erreur lors de la mise à jour de la list d'articles",
"loading": "Chargement...", "loading": "Chargement...",
"listTitle": "Choisissez une catégorie" "listTitle": "Choisissez une catégorie",
"inStock": "en stock"
}, },
"proxiwashScreen": { "proxiwashScreen": {
"dryer": "Sèche Linge", "dryer": "Sèche Linge",