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

This commit is contained in:
keplyx 2019-07-31 14:34:38 +02:00
parent 0cbf60e6cc
commit bba237abe1
3 changed files with 26 additions and 29 deletions

View file

@ -2,9 +2,9 @@
import * as React from 'react'; import * as React from 'react';
import WebDataManager from "../utils/WebDataManager"; import WebDataManager from "../utils/WebDataManager";
import {Container, Content, Tab, TabHeading, Tabs, Text} from "native-base"; import {Container, Tab, TabHeading, Tabs, Text} from "native-base";
import CustomHeader from "./CustomHeader"; import CustomHeader from "./CustomHeader";
import {RefreshControl, SectionList, View, TouchableHighlight} from "react-native"; import {RefreshControl, SectionList, View} from "react-native";
import CustomMaterialIcon from "./CustomMaterialIcon"; import CustomMaterialIcon from "./CustomMaterialIcon";
type Props = { type Props = {
@ -42,10 +42,6 @@ export default class FetchedDataSectionList extends React.Component<Props, State
return ["whoa", "nah"]; return ["whoa", "nah"];
} }
shouldShowUpdateToast() {
return true;
}
/** /**
* Refresh the FetchedData on first screen load * Refresh the FetchedData on first screen load
*/ */
@ -61,8 +57,7 @@ export default class FetchedDataSectionList extends React.Component<Props, State
refreshing: false, refreshing: false,
firstLoading: false firstLoading: false
}); });
if (this.shouldShowUpdateToast()) this.webDataManager.showUpdateToast(this.getUpdateToastTranslations()[0], this.getUpdateToastTranslations()[1]);
this.webDataManager.showUpdateToast(this.getUpdateToastTranslations()[0], this.getUpdateToastTranslations()[1]);
}); });
}; };
@ -111,7 +106,7 @@ export default class FetchedDataSectionList extends React.Component<Props, State
getTabbedView(dataset: Array<Object>) { getTabbedView(dataset: Array<Object>) {
let tabbedView = []; let tabbedView = [];
for (let i = 0; i < dataset.length; i++) { for (let i = 0; i < dataset.length; i++) {
tabbedView.push( tabbedView.push(
<Tab heading={ <Tab heading={
<TabHeading> <TabHeading>
<CustomMaterialIcon icon={dataset[i].icon} <CustomMaterialIcon icon={dataset[i].icon}
@ -120,19 +115,17 @@ export default class FetchedDataSectionList extends React.Component<Props, State
/> />
<Text>{dataset[i].title}</Text> <Text>{dataset[i].title}</Text>
</TabHeading>} </TabHeading>}
key={dataset[i].title}> key={dataset[i].title}>
<Content padder> {this.getSectionList(
{this.getSectionList( [
[ {
{ title: dataset[i].title,
title: dataset[i].title, data: dataset[i].data,
data: dataset[i].data, extraData: dataset[i].extraData,
extraData: dataset[i].extraData, keyExtractor: dataset[i].keyExtractor
keyExtractor: dataset[i].keyExtractor }
} ]
] )}
)}
</Content>
</Tab>); </Tab>);
} }
return tabbedView; return tabbedView;
@ -149,9 +142,7 @@ export default class FetchedDataSectionList extends React.Component<Props, State
{this.getTabbedView(dataset)} {this.getTabbedView(dataset)}
</Tabs> </Tabs>
: :
<Content padder> this.getSectionList(dataset)
{this.getSectionList(dataset)}
</Content>
} }
</Container> </Container>
); );

View file

@ -34,8 +34,8 @@ export default class HomeScreen extends FetchedDataSectionList {
return i18n.t("screens.home"); return i18n.t("screens.home");
} }
shouldShowUpdateToast(): boolean { getUpdateToastTranslations() {
return false; return [i18n.t("homeScreen.listUpdated"), i18n.t("homeScreen.listUpdateFail")];
} }
getKeyExtractor(item: Object) { getKeyExtractor(item: Object) {
@ -68,7 +68,11 @@ export default class HomeScreen extends FetchedDataSectionList {
getRenderItem(item: Object, section: Object, data: Object) { getRenderItem(item: Object, section: Object, data: Object) {
return ( return (
<Card style={{flex: 0}}> <Card style={{
flex: 0,
marginLeft: 10,
marginRight: 10
}}>
<CardItem> <CardItem>
<Left> <Left>
<Thumbnail source={ICON_AMICALE}/> <Thumbnail source={ICON_AMICALE}/>

View file

@ -286,7 +286,9 @@ export default class ProxiwashScreen extends FetchedDataSectionList {
return ( return (
<Card style={{ <Card style={{
flex: 0, flex: 0,
height: 64 height: 64,
marginLeft: 10,
marginRight: 10
}}> }}>
<CardItem <CardItem