Browse Source

Changed data source for proximo to use proximo's website

keplyx 4 years ago
parent
commit
ed597bfa8a

+ 1
- 0
components/FetchedDataSectionList.js View File

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

+ 5
- 5
screens/Proximo/ProximoListScreen.js View File

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

+ 34
- 28
screens/Proximo/ProximoMainScreen.js View File

@@ -1,12 +1,13 @@
1 1
 // @flow
2 2
 
3 3
 import * as React from 'react';
4
+import {View} from 'react-native'
4 5
 import {Badge, Body, H2, Left, ListItem, Right, Text} from 'native-base';
5 6
 import i18n from "i18n-js";
6 7
 import CustomMaterialIcon from "../../components/CustomMaterialIcon";
7 8
 import FetchedDataSectionList from "../../components/FetchedDataSectionList";
8 9
 
9
-const DATA_URL = "https://etud.insa-toulouse.fr/~vergnet/appli-amicale/dataProximo.json";
10
+const DATA_URL = "https://srv-falcon.etud.insa-toulouse.fr/~proximo/data/stock.json";
10 11
 
11 12
 const typesIcons = {
12 13
     Nouveau: "alert-decagram",
@@ -78,33 +79,38 @@ export default class ProximoMainScreen extends FetchedDataSectionList {
78 79
     }
79 80
 
80 81
     getRenderItem(item: Object, section : Object, data : Object) {
81
-        return (
82
-            <ListItem
83
-                button
84
-                thumbnail
85
-                onPress={() => {
86
-                    this.props.navigation.navigate('ProximoListScreen', item);
87
-                }}
88
-            >
89
-                <Left>
90
-                    <CustomMaterialIcon
91
-                        icon={typesIcons[item.type] ? typesIcons[item.type] : typesIcons.Default}
92
-                        fontSize={30}
93
-                    />
94
-                </Left>
95
-                <Body>
96
-                    <Text>
97
-                        {item.type}
98
-                    </Text>
99
-                    <Badge><Text>
100
-                        {item.data.length} {item.data.length > 1 ? i18n.t('proximoScreen.articles') : i18n.t('proximoScreen.article')}
101
-                    </Text></Badge>
102
-                </Body>
103
-                <Right>
104
-                    <CustomMaterialIcon icon="chevron-right"/>
105
-                </Right>
106
-            </ListItem>
107
-        );
82
+        if (item.data.length > 0) {
83
+            return (
84
+                <ListItem
85
+                    button
86
+                    thumbnail
87
+                    onPress={() => {
88
+                        this.props.navigation.navigate('ProximoListScreen', item);
89
+                    }}
90
+                >
91
+                    <Left>
92
+                        <CustomMaterialIcon
93
+                            icon={typesIcons[item.type] ? typesIcons[item.type] : typesIcons.Default}
94
+                            fontSize={30}
95
+                        />
96
+                    </Left>
97
+                    <Body>
98
+                        <Text>
99
+                            {item.type}
100
+                        </Text>
101
+                        <Badge><Text>
102
+                            {item.data.length} {item.data.length > 1 ? i18n.t('proximoScreen.articles') : i18n.t('proximoScreen.article')}
103
+                        </Text></Badge>
104
+                    </Body>
105
+                    <Right>
106
+                        <CustomMaterialIcon icon="chevron-right"/>
107
+                    </Right>
108
+                </ListItem>
109
+            );
110
+        } else {
111
+            return <View/>;
112
+        }
113
+
108 114
     }
109 115
 
110 116
     getRenderSectionHeader(title: String) {

+ 2
- 1
translations/en.json View File

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

+ 2
- 1
translations/fr.json View File

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

Loading…
Cancel
Save