Browse Source

Fixed refresh control not working + added back home list update toast

keplyx 4 years ago
parent
commit
bba237abe1
3 changed files with 26 additions and 29 deletions
  1. 16
    25
      components/FetchedDataSectionList.js
  2. 7
    3
      screens/HomeScreen.js
  3. 3
    1
      screens/ProxiwashScreen.js

+ 16
- 25
components/FetchedDataSectionList.js View File

@@ -2,9 +2,9 @@
2 2
 
3 3
 import * as React from 'react';
4 4
 import WebDataManager from "../utils/WebDataManager";
5
-import {Container, Content, Tab, TabHeading, Tabs, Text} from "native-base";
5
+import {Container, Tab, TabHeading, Tabs, Text} from "native-base";
6 6
 import CustomHeader from "./CustomHeader";
7
-import {RefreshControl, SectionList, View, TouchableHighlight} from "react-native";
7
+import {RefreshControl, SectionList, View} from "react-native";
8 8
 import CustomMaterialIcon from "./CustomMaterialIcon";
9 9
 
10 10
 type Props = {
@@ -42,10 +42,6 @@ export default class FetchedDataSectionList extends React.Component<Props, State
42 42
         return ["whoa", "nah"];
43 43
     }
44 44
 
45
-    shouldShowUpdateToast() {
46
-        return true;
47
-    }
48
-
49 45
     /**
50 46
      * Refresh the FetchedData on first screen load
51 47
      */
@@ -61,8 +57,7 @@ export default class FetchedDataSectionList extends React.Component<Props, State
61 57
                 refreshing: false,
62 58
                 firstLoading: false
63 59
             });
64
-            if (this.shouldShowUpdateToast())
65
-                this.webDataManager.showUpdateToast(this.getUpdateToastTranslations()[0], this.getUpdateToastTranslations()[1]);
60
+            this.webDataManager.showUpdateToast(this.getUpdateToastTranslations()[0], this.getUpdateToastTranslations()[1]);
66 61
         });
67 62
     };
68 63
 
@@ -111,7 +106,7 @@ export default class FetchedDataSectionList extends React.Component<Props, State
111 106
     getTabbedView(dataset: Array<Object>) {
112 107
         let tabbedView = [];
113 108
         for (let i = 0; i < dataset.length; i++) {
114
-             tabbedView.push(
109
+            tabbedView.push(
115 110
                 <Tab heading={
116 111
                     <TabHeading>
117 112
                         <CustomMaterialIcon icon={dataset[i].icon}
@@ -120,19 +115,17 @@ export default class FetchedDataSectionList extends React.Component<Props, State
120 115
                         />
121 116
                         <Text>{dataset[i].title}</Text>
122 117
                     </TabHeading>}
123
-                key={dataset[i].title}>
124
-                    <Content padder>
125
-                        {this.getSectionList(
126
-                            [
127
-                                {
128
-                                    title: dataset[i].title,
129
-                                    data: dataset[i].data,
130
-                                    extraData: dataset[i].extraData,
131
-                                    keyExtractor: dataset[i].keyExtractor
132
-                                }
133
-                            ]
134
-                        )}
135
-                    </Content>
118
+                     key={dataset[i].title}>
119
+                    {this.getSectionList(
120
+                        [
121
+                            {
122
+                                title: dataset[i].title,
123
+                                data: dataset[i].data,
124
+                                extraData: dataset[i].extraData,
125
+                                keyExtractor: dataset[i].keyExtractor
126
+                            }
127
+                        ]
128
+                    )}
136 129
                 </Tab>);
137 130
         }
138 131
         return tabbedView;
@@ -149,9 +142,7 @@ export default class FetchedDataSectionList extends React.Component<Props, State
149 142
                         {this.getTabbedView(dataset)}
150 143
                     </Tabs>
151 144
                     :
152
-                    <Content padder>
153
-                        {this.getSectionList(dataset)}
154
-                    </Content>
145
+                    this.getSectionList(dataset)
155 146
                 }
156 147
             </Container>
157 148
         );

+ 7
- 3
screens/HomeScreen.js View File

@@ -34,8 +34,8 @@ export default class HomeScreen extends FetchedDataSectionList {
34 34
         return i18n.t("screens.home");
35 35
     }
36 36
 
37
-    shouldShowUpdateToast(): boolean {
38
-        return false;
37
+    getUpdateToastTranslations() {
38
+        return [i18n.t("homeScreen.listUpdated"), i18n.t("homeScreen.listUpdateFail")];
39 39
     }
40 40
 
41 41
     getKeyExtractor(item: Object) {
@@ -68,7 +68,11 @@ export default class HomeScreen extends FetchedDataSectionList {
68 68
 
69 69
     getRenderItem(item: Object, section: Object, data: Object) {
70 70
         return (
71
-            <Card style={{flex: 0}}>
71
+            <Card style={{
72
+                flex: 0,
73
+                marginLeft: 10,
74
+                marginRight: 10
75
+            }}>
72 76
                 <CardItem>
73 77
                     <Left>
74 78
                         <Thumbnail source={ICON_AMICALE}/>

+ 3
- 1
screens/ProxiwashScreen.js View File

@@ -286,7 +286,9 @@ export default class ProxiwashScreen extends FetchedDataSectionList {
286 286
         return (
287 287
             <Card style={{
288 288
                 flex: 0,
289
-                height: 64
289
+                height: 64,
290
+                marginLeft: 10,
291
+                marginRight: 10
290 292
             }}>
291 293
 
292 294
                 <CardItem

Loading…
Cancel
Save