forked from vergnet/application-amicale
Changed fb data url to use etud, changed proxiwash display to use a tab system
This commit is contained in:
parent
d2c3d1908b
commit
5bda2825c5
5 changed files with 83 additions and 39 deletions
|
@ -11,6 +11,7 @@ type Props = {
|
||||||
rightMenu: React.Node,
|
rightMenu: React.Node,
|
||||||
title: string,
|
title: string,
|
||||||
navigation: Object,
|
navigation: Object,
|
||||||
|
hasTabs: boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,6 +27,7 @@ export default class CustomHeader extends React.Component<Props> {
|
||||||
static defaultProps = {
|
static defaultProps = {
|
||||||
backButton: false,
|
backButton: false,
|
||||||
rightMenu: <Right/>,
|
rightMenu: <Right/>,
|
||||||
|
hasTabs: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
|
|
@ -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, H2} from "native-base";
|
import {Container, Content, Tab, TabHeading, Tabs, Text} from "native-base";
|
||||||
import CustomHeader from "./CustomHeader";
|
import CustomHeader from "./CustomHeader";
|
||||||
import {SectionList, RefreshControl, View} from "react-native";
|
import {RefreshControl, SectionList, View} from "react-native";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
navigation: Object,
|
navigation: Object,
|
||||||
|
@ -90,13 +90,12 @@ export default class FetchedDataSectionList extends React.Component<Props, State
|
||||||
return item.id;
|
return item.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
hasTabs() {
|
||||||
const nav = this.props.navigation;
|
return false;
|
||||||
const dataset = this.createDataset(this.state.fetchedData);
|
}
|
||||||
|
|
||||||
|
getSectionList(dataset: Array<Object>) {
|
||||||
return (
|
return (
|
||||||
<Container>
|
|
||||||
<CustomHeader navigation={nav} title={this.getHeaderTranslation()}/>
|
|
||||||
<Content padder>
|
|
||||||
<SectionList
|
<SectionList
|
||||||
sections={dataset}
|
sections={dataset}
|
||||||
keyExtractor={(item) => this.getKeyExtractor(item)}
|
keyExtractor={(item) => this.getKeyExtractor(item)}
|
||||||
|
@ -114,7 +113,45 @@ export default class FetchedDataSectionList extends React.Component<Props, State
|
||||||
}
|
}
|
||||||
style={{minHeight: 300, width: '100%'}}
|
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>
|
</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>
|
</Container>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,8 @@ import FetchedDataSectionList from "../components/FetchedDataSectionList";
|
||||||
|
|
||||||
const ICON_AMICALE = require('../assets/amicale.png');
|
const ICON_AMICALE = require('../assets/amicale.png');
|
||||||
const NAME_AMICALE = 'Amicale INSA Toulouse';
|
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
|
* Opens a link in the device's browser
|
||||||
|
@ -33,7 +34,7 @@ export default class HomeScreen extends FetchedDataSectionList {
|
||||||
}
|
}
|
||||||
|
|
||||||
getKeyExtractor(item : Object) {
|
getKeyExtractor(item : Object) {
|
||||||
return item.id;
|
return item !== undefined ? item.id : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
createDataset(fetchedData : Object) {
|
createDataset(fetchedData : Object) {
|
||||||
|
|
|
@ -36,7 +36,7 @@ export default class ProximoMainScreen extends FetchedDataSectionList {
|
||||||
}
|
}
|
||||||
|
|
||||||
getKeyExtractor(item: Object) {
|
getKeyExtractor(item: Object) {
|
||||||
return item.type;
|
return item !== undefined ? item.type : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
createDataset(fetchedData: Object) {
|
createDataset(fetchedData: Object) {
|
||||||
|
|
|
@ -78,7 +78,7 @@ export default class ProxiwashScreen extends FetchedDataSectionList {
|
||||||
}
|
}
|
||||||
|
|
||||||
getKeyExtractor(item: Object) {
|
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
|
* Get list item to be rendered
|
||||||
*
|
*
|
||||||
|
@ -233,12 +237,12 @@ export default class ProxiwashScreen extends FetchedDataSectionList {
|
||||||
backgroundColor: ThemeManager.getInstance().getCurrentThemeVariables().containerBgColor
|
backgroundColor: ThemeManager.getInstance().getCurrentThemeVariables().containerBgColor
|
||||||
}}/>
|
}}/>
|
||||||
<Left>
|
<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}
|
fontSize={30}
|
||||||
/>
|
/>
|
||||||
<Body>
|
<Body>
|
||||||
<Text>
|
<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>
|
||||||
<Text note>
|
<Text note>
|
||||||
{item.startTime !== '' ? item.startTime + '/' + item.endTime : ''}
|
{item.startTime !== '' ? item.startTime + '/' + item.endTime : ''}
|
||||||
|
@ -280,7 +284,7 @@ export default class ProxiwashScreen extends FetchedDataSectionList {
|
||||||
</Card>);
|
</Card>);
|
||||||
}
|
}
|
||||||
|
|
||||||
getRenderSectionHeader(title: String) {
|
// getRenderSectionHeader(title: String) {
|
||||||
return <H2 style={{textAlign: 'center', paddingVertical: 10}}>{title}</H2>;
|
// return <H2 style={{textAlign: 'center', paddingVertical: 10}}>{title}</H2>;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue