Changed fb data url to use etud, changed proxiwash display to use a tab system

This commit is contained in:
keplyx 2019-07-28 12:40:35 +02:00
parent d2c3d1908b
commit 5bda2825c5
5 changed files with 83 additions and 39 deletions

View file

@ -11,6 +11,7 @@ type Props = {
rightMenu: React.Node,
title: string,
navigation: Object,
hasTabs: boolean,
};
/**
@ -26,6 +27,7 @@ export default class CustomHeader extends React.Component<Props> {
static defaultProps = {
backButton: false,
rightMenu: <Right/>,
hasTabs: false,
};
render() {

View file

@ -2,9 +2,9 @@
import * as React from 'react';
import WebDataManager from "../utils/WebDataManager";
import {Container, Content, H2} from "native-base";
import {Container, Content, Tab, TabHeading, Tabs, Text} from "native-base";
import CustomHeader from "./CustomHeader";
import {SectionList, RefreshControl, View} from "react-native";
import {RefreshControl, SectionList, View} from "react-native";
type Props = {
navigation: Object,
@ -90,13 +90,12 @@ export default class FetchedDataSectionList extends React.Component<Props, State
return item.id;
}
render() {
const nav = this.props.navigation;
const dataset = this.createDataset(this.state.fetchedData);
hasTabs() {
return false;
}
getSectionList(dataset: Array<Object>) {
return (
<Container>
<CustomHeader navigation={nav} title={this.getHeaderTranslation()}/>
<Content padder>
<SectionList
sections={dataset}
keyExtractor={(item) => this.getKeyExtractor(item)}
@ -114,7 +113,45 @@ export default class FetchedDataSectionList extends React.Component<Props, State
}
style={{minHeight: 300, width: '100%'}}
/>
);
}
getTabbedView(dataset: Array<Object>) {
let tabbedView = [];
for (let i = 0; i < dataset.length; i++) {
tabbedView.push(
<Tab heading={<TabHeading><Text>{dataset[i].title}</Text></TabHeading>}>
<Content padder>
{this.getSectionList(
[
{
title: dataset[i].title,
data: dataset[i].data,
extraData: dataset[i].extraData,
}
]
)}
</Content>
</Tab>);
}
return tabbedView;
}
render() {
const nav = this.props.navigation;
const dataset = this.createDataset(this.state.fetchedData);
return (
<Container>
<CustomHeader navigation={nav} title={this.getHeaderTranslation()}/>
{this.hasTabs() ?
<Tabs>
{this.getTabbedView(dataset)}
</Tabs>
:
<Content padder>
{this.getSectionList(dataset)}
</Content>
}
</Container>
);
}

View file

@ -9,7 +9,8 @@ import FetchedDataSectionList from "../components/FetchedDataSectionList";
const ICON_AMICALE = require('../assets/amicale.png');
const NAME_AMICALE = 'Amicale INSA Toulouse';
const FB_URL = "https://graph.facebook.com/v3.3/amicale.deseleves/posts?fields=message%2Cfull_picture%2Ccreated_time%2Cpermalink_url&&date_format=U&access_token=EAAGliUs4Ei8BAGwHmg7SNnosoEDMuDhP3i5lYOGrIGzZBNeMeGzGhpUigJt167cKXEIM0GiurSgaC0PS4Xg2GBzOVNiZCfr8u48VVB15a9YbOsuhjBqhHAMb2sz6ibwOuDhHSvwRZCUpBZCjmAW12e7RjWJp0jvyNoYYvIQbfaLWi3Nk2mBc";
const FB_URL = "https://etud.insa-toulouse.fr/~vergnet/appli-amicale/facebook_data.json";
/**
* Opens a link in the device's browser
@ -33,7 +34,7 @@ export default class HomeScreen extends FetchedDataSectionList {
}
getKeyExtractor(item : Object) {
return item.id;
return item !== undefined ? item.id : undefined;
}
createDataset(fetchedData : Object) {

View file

@ -36,7 +36,7 @@ export default class ProximoMainScreen extends FetchedDataSectionList {
}
getKeyExtractor(item: Object) {
return item.type;
return item !== undefined ? item.type : undefined;
}
createDataset(fetchedData: Object) {

View file

@ -78,7 +78,7 @@ export default class ProxiwashScreen extends FetchedDataSectionList {
}
getKeyExtractor(item: Object) {
return item.number;
return item !== undefined ? item.number : undefined;
}
/**
@ -204,6 +204,10 @@ export default class ProxiwashScreen extends FetchedDataSectionList {
];
}
hasTabs(): boolean {
return true;
}
/**
* Get list item to be rendered
*
@ -233,12 +237,12 @@ export default class ProxiwashScreen extends FetchedDataSectionList {
backgroundColor: ThemeManager.getInstance().getCurrentThemeVariables().containerBgColor
}}/>
<Left>
<CustomMaterialIcon icon={section.title === data[0].title ? 'tumble-dryer' : 'washing-machine'}
<CustomMaterialIcon icon={section.title === i18n.t('proxiwashScreen.dryers') ? 'tumble-dryer' : 'washing-machine'}
fontSize={30}
/>
<Body>
<Text>
{section.title === data[0].title ? i18n.t('proxiwashScreen.dryer') : i18n.t('proxiwashScreen.washer')} n°{item.number}
{section.title === i18n.t('proxiwashScreen.dryers') ? i18n.t('proxiwashScreen.dryer') : i18n.t('proxiwashScreen.washer')} n°{item.number}
</Text>
<Text note>
{item.startTime !== '' ? item.startTime + '/' + item.endTime : ''}
@ -280,7 +284,7 @@ export default class ProxiwashScreen extends FetchedDataSectionList {
</Card>);
}
getRenderSectionHeader(title: String) {
return <H2 style={{textAlign: 'center', paddingVertical: 10}}>{title}</H2>;
}
// getRenderSectionHeader(title: String) {
// return <H2 style={{textAlign: 'center', paddingVertical: 10}}>{title}</H2>;
// }
}