forked from vergnet/application-amicale
Fixed some Flow errors
This commit is contained in:
parent
aefbdba42a
commit
d9c07f5df0
12 changed files with 115 additions and 86 deletions
|
@ -45,12 +45,14 @@ export default class BaseContainer extends React.Component<Props, State> {
|
||||||
isHeaderVisible: true,
|
isHeaderVisible: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onDrawerPress: Function;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.toggle = this.toggle.bind(this);
|
this.onDrawerPress = this.onDrawerPress.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
toggle() {
|
onDrawerPress() {
|
||||||
this.props.navigation.toggleDrawer();
|
this.props.navigation.toggleDrawer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,7 +113,7 @@ export default class BaseContainer extends React.Component<Props, State> {
|
||||||
leftButton={
|
leftButton={
|
||||||
<Touchable
|
<Touchable
|
||||||
style={{padding: 6}}
|
style={{padding: 6}}
|
||||||
onPress={this.toggle}>
|
onPress={this.onDrawerPress}>
|
||||||
<CustomMaterialIcon
|
<CustomMaterialIcon
|
||||||
color={Platform.OS === 'ios' ? ThemeManager.getCurrentThemeVariables().brandPrimary : "#fff"}
|
color={Platform.OS === 'ios' ? ThemeManager.getCurrentThemeVariables().brandPrimary : "#fff"}
|
||||||
icon="menu"/>
|
icon="menu"/>
|
||||||
|
|
|
@ -44,6 +44,8 @@ export default class CustomHeader extends React.Component<Props> {
|
||||||
hasTabs: false,
|
hasTabs: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onPressBack: Function;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.onPressBack = this.onPressBack.bind(this);
|
this.onPressBack = this.onPressBack.bind(this);
|
||||||
|
@ -80,7 +82,7 @@ export default class CustomHeader extends React.Component<Props> {
|
||||||
color={ThemeManager.getCurrentThemeVariables().toolbarBtnColor}/>
|
color={ThemeManager.getCurrentThemeVariables().toolbarBtnColor}/>
|
||||||
<Input
|
<Input
|
||||||
ref="searchInput"
|
ref="searchInput"
|
||||||
placeholder={i18n.t('proximoScreen.search')}
|
placeholder={i18n.t('proximoScreen.onSearchStringChange')}
|
||||||
placeholderTextColor={ThemeManager.getCurrentThemeVariables().toolbarPlaceholderColor}
|
placeholderTextColor={ThemeManager.getCurrentThemeVariables().toolbarPlaceholderColor}
|
||||||
onChangeText={this.props.searchCallback}/>
|
onChangeText={this.props.searchCallback}/>
|
||||||
</Item>
|
</Item>
|
||||||
|
|
|
@ -41,12 +41,18 @@ export default class FetchedDataSectionList extends React.Component<Props, State
|
||||||
machinesWatched: [],
|
machinesWatched: [],
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onRefresh: Function;
|
||||||
|
renderSectionHeaderEmpty: Function;
|
||||||
|
renderSectionHeaderNotEmpty: Function;
|
||||||
|
renderItemEmpty: Function;
|
||||||
|
renderItemNotEmpty: Function;
|
||||||
|
|
||||||
constructor(fetchUrl: string, refreshTime: number) {
|
constructor(fetchUrl: string, refreshTime: number) {
|
||||||
super();
|
super();
|
||||||
this.webDataManager = new WebDataManager(fetchUrl);
|
this.webDataManager = new WebDataManager(fetchUrl);
|
||||||
this.refreshTime = refreshTime;
|
this.refreshTime = refreshTime;
|
||||||
// creating references to functions used in render()
|
// creating references to functions used in render()
|
||||||
this._onRefresh = this._onRefresh.bind(this);
|
this.onRefresh = this.onRefresh.bind(this);
|
||||||
this.renderSectionHeaderEmpty = this.renderSectionHeader.bind(this, true);
|
this.renderSectionHeaderEmpty = this.renderSectionHeader.bind(this, true);
|
||||||
this.renderSectionHeaderNotEmpty = this.renderSectionHeader.bind(this, false);
|
this.renderSectionHeaderNotEmpty = this.renderSectionHeader.bind(this, false);
|
||||||
this.renderItemEmpty = this.renderItem.bind(this, true);
|
this.renderItemEmpty = this.renderItem.bind(this, true);
|
||||||
|
@ -96,9 +102,9 @@ export default class FetchedDataSectionList extends React.Component<Props, State
|
||||||
* Refresh data when focusing the screen and setup a refresh interval if asked to
|
* Refresh data when focusing the screen and setup a refresh interval if asked to
|
||||||
*/
|
*/
|
||||||
onScreenFocus() {
|
onScreenFocus() {
|
||||||
this._onRefresh();
|
this.onRefresh();
|
||||||
if (this.refreshTime > 0)
|
if (this.refreshTime > 0)
|
||||||
this.refreshInterval = setInterval(this._onRefresh.bind(this), this.refreshTime)
|
this.refreshInterval = setInterval(this.onRefresh.bind(this), this.refreshTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -122,7 +128,7 @@ export default class FetchedDataSectionList extends React.Component<Props, State
|
||||||
* Refresh data and show a toast if any error occurred
|
* Refresh data and show a toast if any error occurred
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_onRefresh() {
|
onRefresh() {
|
||||||
let canRefresh;
|
let canRefresh;
|
||||||
if (this.lastRefresh !== undefined)
|
if (this.lastRefresh !== undefined)
|
||||||
canRefresh = (new Date().getTime() - this.lastRefresh.getTime()) / 1000 > this.minTimeBetweenRefresh;
|
canRefresh = (new Date().getTime() - this.lastRefresh.getTime()) / 1000 > this.minTimeBetweenRefresh;
|
||||||
|
@ -284,13 +290,13 @@ export default class FetchedDataSectionList extends React.Component<Props, State
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
renderSectionHeader(isEmpty, {section: {title}}) {
|
renderSectionHeader(isEmpty: boolean, {section: {title}} : Object) {
|
||||||
return isEmpty ?
|
return isEmpty ?
|
||||||
<View/> :
|
<View/> :
|
||||||
this.getRenderSectionHeader(title)
|
this.getRenderSectionHeader(title)
|
||||||
}
|
}
|
||||||
|
|
||||||
renderItem(isEmpty, {item, section}) {
|
renderItem(isEmpty: boolean, {item, section}: Object) {
|
||||||
return isEmpty ?
|
return isEmpty ?
|
||||||
this.getEmptyRenderItem(item.text, item.isSpinner, item.icon) :
|
this.getEmptyRenderItem(item.text, item.isSpinner, item.icon) :
|
||||||
this.getRenderItem(item, section)
|
this.getRenderItem(item, section)
|
||||||
|
@ -313,7 +319,7 @@ export default class FetchedDataSectionList extends React.Component<Props, State
|
||||||
refreshControl={
|
refreshControl={
|
||||||
<RefreshControl
|
<RefreshControl
|
||||||
refreshing={this.state.refreshing}
|
refreshing={this.state.refreshing}
|
||||||
onRefresh={this._onRefresh}
|
onRefresh={this.onRefresh}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
renderSectionHeader={isEmpty ? this.renderSectionHeaderEmpty : this.renderSectionHeaderNotEmpty}
|
renderSectionHeader={isEmpty ? this.renderSectionHeaderEmpty : this.renderSectionHeaderNotEmpty}
|
||||||
|
|
|
@ -30,6 +30,8 @@ export default class SideBar extends React.Component<Props, State> {
|
||||||
active: 'Home',
|
active: 'Home',
|
||||||
};
|
};
|
||||||
|
|
||||||
|
getRenderItem: Function;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate the datasets
|
* Generate the datasets
|
||||||
*
|
*
|
||||||
|
@ -111,7 +113,7 @@ export default class SideBar extends React.Component<Props, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
onListItemPress(item) {
|
onListItemPress(item: Object) {
|
||||||
if (item.link !== undefined)
|
if (item.link !== undefined)
|
||||||
Linking.openURL(item.link).catch((err) => console.error('Error opening link', err));
|
Linking.openURL(item.link).catch((err) => console.error('Error opening link', err));
|
||||||
else
|
else
|
||||||
|
@ -119,7 +121,7 @@ export default class SideBar extends React.Component<Props, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
listKeyExtractor(item) {
|
listKeyExtractor(item: Object) {
|
||||||
return item.route;
|
return item.route;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -210,7 +210,7 @@ export default class AboutScreen extends React.Component<Props, State> {
|
||||||
data={this.appData}
|
data={this.appData}
|
||||||
extraData={this.state}
|
extraData={this.state}
|
||||||
keyExtractor={(item) => item.icon}
|
keyExtractor={(item) => item.icon}
|
||||||
listKey={(item) => "app"}
|
listKey={"app"}
|
||||||
renderItem={({item}) =>
|
renderItem={({item}) =>
|
||||||
this.getCardItem(item.onPressCallback, item.icon, item.text, item.showChevron, item.showOnlyDebug)
|
this.getCardItem(item.onPressCallback, item.icon, item.text, item.showChevron, item.showOnlyDebug)
|
||||||
}
|
}
|
||||||
|
@ -241,7 +241,7 @@ export default class AboutScreen extends React.Component<Props, State> {
|
||||||
data={this.authorData}
|
data={this.authorData}
|
||||||
extraData={this.state}
|
extraData={this.state}
|
||||||
keyExtractor={(item) => item.icon}
|
keyExtractor={(item) => item.icon}
|
||||||
listKey={(item) => "team1"}
|
listKey={"team1"}
|
||||||
renderItem={({item}) =>
|
renderItem={({item}) =>
|
||||||
this.getCardItem(item.onPressCallback, item.icon, item.text, item.showChevron, item.showOnlyDebug)
|
this.getCardItem(item.onPressCallback, item.icon, item.text, item.showChevron, item.showOnlyDebug)
|
||||||
}
|
}
|
||||||
|
@ -253,7 +253,7 @@ export default class AboutScreen extends React.Component<Props, State> {
|
||||||
data={this.additionalDevData}
|
data={this.additionalDevData}
|
||||||
extraData={this.state}
|
extraData={this.state}
|
||||||
keyExtractor={(item) => item.icon}
|
keyExtractor={(item) => item.icon}
|
||||||
listKey={(item) => "team2"}
|
listKey={"team2"}
|
||||||
renderItem={({item}) =>
|
renderItem={({item}) =>
|
||||||
this.getCardItem(item.onPressCallback, item.icon, item.text, item.showChevron, item.showOnlyDebug)
|
this.getCardItem(item.onPressCallback, item.icon, item.text, item.showChevron, item.showOnlyDebug)
|
||||||
}
|
}
|
||||||
|
@ -272,7 +272,7 @@ export default class AboutScreen extends React.Component<Props, State> {
|
||||||
data={this.technoData}
|
data={this.technoData}
|
||||||
extraData={this.state}
|
extraData={this.state}
|
||||||
keyExtractor={(item) => item.icon}
|
keyExtractor={(item) => item.icon}
|
||||||
listKey={(item) => "techno"}
|
listKey={"techno"}
|
||||||
renderItem={({item}) =>
|
renderItem={({item}) =>
|
||||||
this.getCardItem(item.onPressCallback, item.icon, item.text, item.showChevron, item.showOnlyDebug)
|
this.getCardItem(item.onPressCallback, item.icon, item.text, item.showChevron, item.showOnlyDebug)
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,12 +38,33 @@ function openWebLink(link) {
|
||||||
*/
|
*/
|
||||||
export default class HomeScreen extends FetchedDataSectionList {
|
export default class HomeScreen extends FetchedDataSectionList {
|
||||||
|
|
||||||
|
onProxiwashClick: Function;
|
||||||
|
onTutorInsaClick: Function;
|
||||||
|
onMenuClick: Function;
|
||||||
|
onProximoClick: Function;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super(DATA_URL, REFRESH_TIME);
|
super(DATA_URL, REFRESH_TIME);
|
||||||
this.proxiwashClickAction = this.proxiwashClickAction.bind(this);
|
this.onProxiwashClick = this.onProxiwashClick.bind(this);
|
||||||
this.tutorinsaClickAction = this.tutorinsaClickAction.bind(this);
|
this.onTutorInsaClick = this.onTutorInsaClick.bind(this);
|
||||||
this.menuClickAction = this.menuClickAction.bind(this);
|
this.onMenuClick = this.onMenuClick.bind(this);
|
||||||
this.proximoClickAction = this.proximoClickAction.bind(this);
|
this.onProximoClick = this.onProximoClick.bind(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
onProxiwashClick() {
|
||||||
|
this.props.navigation.navigate('Proxiwash');
|
||||||
|
}
|
||||||
|
|
||||||
|
onTutorInsaClick() {
|
||||||
|
this.props.navigation.navigate('TutorInsaScreen');
|
||||||
|
}
|
||||||
|
|
||||||
|
onProximoClick() {
|
||||||
|
this.props.navigation.navigate('Proximo');
|
||||||
|
}
|
||||||
|
|
||||||
|
onMenuClick() {
|
||||||
|
this.props.navigation.navigate('SelfMenuScreen');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -293,7 +314,7 @@ export default class HomeScreen extends FetchedDataSectionList {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
clickAction(isAvailable, displayEvent) {
|
clickAction(isAvailable: boolean, displayEvent: Object) {
|
||||||
if (isAvailable)
|
if (isAvailable)
|
||||||
this.props.navigation.navigate('PlanningDisplayScreen', {data: displayEvent});
|
this.props.navigation.navigate('PlanningDisplayScreen', {data: displayEvent});
|
||||||
else
|
else
|
||||||
|
@ -338,14 +359,6 @@ export default class HomeScreen extends FetchedDataSectionList {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
proximoClickAction() {
|
|
||||||
this.props.navigation.navigate('Proximo');
|
|
||||||
}
|
|
||||||
|
|
||||||
menuClickAction() {
|
|
||||||
this.props.navigation.navigate('SelfMenuScreen');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
getDashboardBottomItem(content: Array<Object>) {
|
getDashboardBottomItem(content: Array<Object>) {
|
||||||
let proximoData = content[0]['data'];
|
let proximoData = content[0]['data'];
|
||||||
|
@ -391,7 +404,7 @@ export default class HomeScreen extends FetchedDataSectionList {
|
||||||
subtitle={menuSubtitle}
|
subtitle={menuSubtitle}
|
||||||
color={menuColor}
|
color={menuColor}
|
||||||
icon={menuIcon}
|
icon={menuIcon}
|
||||||
clickAction={this.menuClickAction}
|
clickAction={this.onMenuClick}
|
||||||
title={menuTitle}
|
title={menuTitle}
|
||||||
isAvailable={isMenuAvailable}
|
isAvailable={isMenuAvailable}
|
||||||
isSquareLeft={true}/>
|
isSquareLeft={true}/>
|
||||||
|
@ -400,21 +413,13 @@ export default class HomeScreen extends FetchedDataSectionList {
|
||||||
subtitle={proximoSubtitle}
|
subtitle={proximoSubtitle}
|
||||||
color={proximoColor}
|
color={proximoColor}
|
||||||
icon={proximoIcon}
|
icon={proximoIcon}
|
||||||
clickAction={this.proximoClickAction}
|
clickAction={this.onProximoClick}
|
||||||
title={proximoTitle}
|
title={proximoTitle}
|
||||||
isAvailable={isProximoAvailable}/>
|
isAvailable={isProximoAvailable}/>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
proxiwashClickAction() {
|
|
||||||
this.props.navigation.navigate('Proxiwash');
|
|
||||||
}
|
|
||||||
|
|
||||||
tutorinsaClickAction() {
|
|
||||||
this.props.navigation.navigate('TutorInsaScreen');
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
getDashboardMiddleItem(content: Array<Object>) {
|
getDashboardMiddleItem(content: Array<Object>) {
|
||||||
let proxiwashData = content[0]['data'];
|
let proxiwashData = content[0]['data'];
|
||||||
|
@ -502,7 +507,7 @@ export default class HomeScreen extends FetchedDataSectionList {
|
||||||
subtitle={proxiwashSubtitle}
|
subtitle={proxiwashSubtitle}
|
||||||
color={proxiwashColor}
|
color={proxiwashColor}
|
||||||
icon={proxiwashIcon}
|
icon={proxiwashIcon}
|
||||||
clickAction={this.proxiwashClickAction}
|
clickAction={this.onProxiwashClick}
|
||||||
title={proxiwashTitle}
|
title={proxiwashTitle}
|
||||||
isAvailable={proxiwashIsAvailable}
|
isAvailable={proxiwashIsAvailable}
|
||||||
isSquareLeft={true}/>
|
isSquareLeft={true}/>
|
||||||
|
@ -511,7 +516,7 @@ export default class HomeScreen extends FetchedDataSectionList {
|
||||||
subtitle={tutorinsaSubtitle}
|
subtitle={tutorinsaSubtitle}
|
||||||
color={tutorinsaColor}
|
color={tutorinsaColor}
|
||||||
icon={tutorinsaIcon}
|
icon={tutorinsaIcon}
|
||||||
clickAction={this.tutorinsaClickAction}
|
clickAction={this.onTutorInsaClick}
|
||||||
title={tutorinsaTitle}
|
title={tutorinsaTitle}
|
||||||
isAvailable={tutorinsaIsAvailable}/>
|
isAvailable={tutorinsaIsAvailable}/>
|
||||||
</View>
|
</View>
|
||||||
|
|
|
@ -8,7 +8,6 @@ import ThemeManager from "../utils/ThemeManager";
|
||||||
import HTML from "react-native-render-html";
|
import HTML from "react-native-render-html";
|
||||||
import {Linking} from "expo";
|
import {Linking} from "expo";
|
||||||
import PlanningEventManager from '../utils/PlanningEventManager';
|
import PlanningEventManager from '../utils/PlanningEventManager';
|
||||||
import i18n from 'i18n-js';
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
navigation: Object,
|
navigation: Object,
|
||||||
|
|
|
@ -5,7 +5,6 @@ import {BackHandler, Image} from 'react-native';
|
||||||
import {H3, Text, View} from 'native-base';
|
import {H3, Text, View} from 'native-base';
|
||||||
import i18n from "i18n-js";
|
import i18n from "i18n-js";
|
||||||
import ThemeManager from "../utils/ThemeManager";
|
import ThemeManager from "../utils/ThemeManager";
|
||||||
import {Linking} from "expo";
|
|
||||||
import BaseContainer from "../components/BaseContainer";
|
import BaseContainer from "../components/BaseContainer";
|
||||||
import {Agenda, LocaleConfig} from 'react-native-calendars';
|
import {Agenda, LocaleConfig} from 'react-native-calendars';
|
||||||
import Touchable from 'react-native-platform-touchable';
|
import Touchable from 'react-native-platform-touchable';
|
||||||
|
@ -35,14 +34,6 @@ const FETCH_URL = "https://amicale-insat.fr/event/json/list";
|
||||||
|
|
||||||
const AGENDA_MONTH_SPAN = 6;
|
const AGENDA_MONTH_SPAN = 6;
|
||||||
|
|
||||||
/**
|
|
||||||
* Opens a link in the device's browser
|
|
||||||
* @param link The link to open
|
|
||||||
*/
|
|
||||||
function openWebLink(link) {
|
|
||||||
Linking.openURL(link).catch((err) => console.error('Error opening link', err));
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class defining the app's planning screen
|
* Class defining the app's planning screen
|
||||||
*/
|
*/
|
||||||
|
@ -63,6 +54,14 @@ export default class PlanningScreen extends React.Component<Props, State> {
|
||||||
calendarShowing: false,
|
calendarShowing: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
onRefresh: Function;
|
||||||
|
onCalendarToggled: Function;
|
||||||
|
getRenderItem: Function;
|
||||||
|
getRenderEmptyDate: Function;
|
||||||
|
onAgendaRef: Function;
|
||||||
|
onCalendarToggled: Function;
|
||||||
|
onBackButtonPressAndroid: Function;
|
||||||
|
|
||||||
constructor(props: any) {
|
constructor(props: any) {
|
||||||
super(props);
|
super(props);
|
||||||
this.webDataManager = new WebDataManager(FETCH_URL);
|
this.webDataManager = new WebDataManager(FETCH_URL);
|
||||||
|
@ -79,12 +78,11 @@ export default class PlanningScreen extends React.Component<Props, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create references for functions required in the render function
|
// Create references for functions required in the render function
|
||||||
this._onRefresh = this._onRefresh.bind(this);
|
this.onRefresh = this.onRefresh.bind(this);
|
||||||
this.onCalendarToggled = this.onCalendarToggled.bind(this);
|
this.onCalendarToggled = this.onCalendarToggled.bind(this);
|
||||||
this.getRenderItem = this.getRenderItem.bind(this);
|
this.getRenderItem = this.getRenderItem.bind(this);
|
||||||
this.getRenderEmptyDate = this.getRenderEmptyDate.bind(this);
|
this.getRenderEmptyDate = this.getRenderEmptyDate.bind(this);
|
||||||
this.setAgendaRef = this.setAgendaRef.bind(this);
|
this.onAgendaRef = this.onAgendaRef.bind(this);
|
||||||
this.onCalendarToggled = this.onCalendarToggled.bind(this);
|
|
||||||
this.onCalendarToggled = this.onCalendarToggled.bind(this);
|
this.onCalendarToggled = this.onCalendarToggled.bind(this);
|
||||||
this.onBackButtonPressAndroid = this.onBackButtonPressAndroid.bind(this);
|
this.onBackButtonPressAndroid = this.onBackButtonPressAndroid.bind(this);
|
||||||
}
|
}
|
||||||
|
@ -96,7 +94,7 @@ export default class PlanningScreen extends React.Component<Props, State> {
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
this._onRefresh();
|
this.onRefresh();
|
||||||
this.willBlurSubscription = this.props.navigation.addListener(
|
this.willBlurSubscription = this.props.navigation.addListener(
|
||||||
'willBlur',
|
'willBlur',
|
||||||
() =>
|
() =>
|
||||||
|
@ -213,7 +211,7 @@ export default class PlanningScreen extends React.Component<Props, State> {
|
||||||
* Refresh data and show a toast if any error occurred
|
* Refresh data and show a toast if any error occurred
|
||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_onRefresh = () => {
|
onRefresh = () => {
|
||||||
let canRefresh;
|
let canRefresh;
|
||||||
if (this.lastRefresh !== undefined)
|
if (this.lastRefresh !== undefined)
|
||||||
canRefresh = (new Date().getTime() - this.lastRefresh.getTime()) / 1000 > this.minTimeBetweenRefresh;
|
canRefresh = (new Date().getTime() - this.lastRefresh.getTime()) / 1000 > this.minTimeBetweenRefresh;
|
||||||
|
@ -265,12 +263,12 @@ export default class PlanningScreen extends React.Component<Props, State> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setAgendaRef(ref) {
|
onAgendaRef(ref: Agenda) {
|
||||||
this.agendaRef = ref;
|
this.agendaRef = ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
onCalendarToggled(calendarOpened) {
|
onCalendarToggled(isCalendarOpened: boolean) {
|
||||||
this.setState({calendarShowing: calendarOpened});
|
this.setState({calendarShowing: isCalendarOpened});
|
||||||
}
|
}
|
||||||
|
|
||||||
currentDate = this.getCurrentDate();
|
currentDate = this.getCurrentDate();
|
||||||
|
@ -293,7 +291,7 @@ export default class PlanningScreen extends React.Component<Props, State> {
|
||||||
// Max amount of months allowed to scroll to the future. Default = 50
|
// Max amount of months allowed to scroll to the future. Default = 50
|
||||||
futureScrollRange={AGENDA_MONTH_SPAN}
|
futureScrollRange={AGENDA_MONTH_SPAN}
|
||||||
// If provided, a standard RefreshControl will be added for "Pull to Refresh" functionality. Make sure to also set the refreshing prop correctly.
|
// If provided, a standard RefreshControl will be added for "Pull to Refresh" functionality. Make sure to also set the refreshing prop correctly.
|
||||||
onRefresh={this._onRefresh}
|
onRefresh={this.onRefresh}
|
||||||
// callback that fires when the calendar is opened or closed
|
// callback that fires when the calendar is opened or closed
|
||||||
onCalendarToggled={this.onCalendarToggled}
|
onCalendarToggled={this.onCalendarToggled}
|
||||||
// Set this true while waiting for new data from a refresh
|
// Set this true while waiting for new data from a refresh
|
||||||
|
@ -304,7 +302,7 @@ export default class PlanningScreen extends React.Component<Props, State> {
|
||||||
// If firstDay=1 week starts from Monday. Note that dayNames and dayNamesShort should still start from Sunday.
|
// If firstDay=1 week starts from Monday. Note that dayNames and dayNamesShort should still start from Sunday.
|
||||||
firstDay={1}
|
firstDay={1}
|
||||||
// ref to this agenda in order to handle back button event
|
// ref to this agenda in order to handle back button event
|
||||||
ref={this.setAgendaRef}
|
ref={this.onAgendaRef}
|
||||||
// agenda theme
|
// agenda theme
|
||||||
theme={{
|
theme={{
|
||||||
backgroundColor: ThemeManager.getCurrentThemeVariables().agendaBackgroundColor,
|
backgroundColor: ThemeManager.getCurrentThemeVariables().agendaBackgroundColor,
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
// @flow
|
// @flow
|
||||||
|
|
||||||
import * as React from 'react';
|
import * as React from 'react';
|
||||||
import {Image, Linking, View} from 'react-native';
|
import {Image, View} from 'react-native';
|
||||||
import {Card, CardItem, Container, Content, H2, Left, Text} from 'native-base';
|
import {Card, CardItem, Container, Content, H2, Left, Text} from 'native-base';
|
||||||
import CustomHeader from "../../components/CustomHeader";
|
import CustomHeader from "../../components/CustomHeader";
|
||||||
import i18n from "i18n-js";
|
import i18n from "i18n-js";
|
||||||
|
|
|
@ -70,16 +70,25 @@ export default class ProximoListScreen extends React.Component<Props, State> {
|
||||||
sortNameIcon: '',
|
sortNameIcon: '',
|
||||||
modalCurrentDisplayItem: {},
|
modalCurrentDisplayItem: {},
|
||||||
};
|
};
|
||||||
_menu: Menu;
|
sortMenuRef: Menu;
|
||||||
|
|
||||||
|
onMenuRef: Function;
|
||||||
|
onSearchStringChange: Function;
|
||||||
|
onSelectSortModeName: Function;
|
||||||
|
onSelectSortModePrice: Function;
|
||||||
|
onSortMenuPress: Function;
|
||||||
|
renderItem: Function;
|
||||||
|
|
||||||
constructor(props: any) {
|
constructor(props: any) {
|
||||||
super(props);
|
super(props);
|
||||||
this.modalRef = React.createRef();
|
this.modalRef = React.createRef();
|
||||||
this.originalData = this.navData['data'];
|
this.originalData = this.navData['data'];
|
||||||
this.search = this.search.bind(this);
|
|
||||||
this.selectSortModeName = this.selectSortModeName.bind(this);
|
this.onMenuRef = this.onMenuRef.bind(this);
|
||||||
this.selectSortModePrice = this.selectSortModePrice.bind(this);
|
this.onSearchStringChange = this.onSearchStringChange.bind(this);
|
||||||
this.showMenu = this.showMenu.bind(this);
|
this.onSelectSortModeName = this.onSelectSortModeName.bind(this);
|
||||||
|
this.onSelectSortModePrice = this.onSelectSortModePrice.bind(this);
|
||||||
|
this.onSortMenuPress = this.onSortMenuPress.bind(this);
|
||||||
this.renderItem = this.renderItem.bind(this);
|
this.renderItem = this.renderItem.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,8 +97,8 @@ export default class ProximoListScreen extends React.Component<Props, State> {
|
||||||
*
|
*
|
||||||
* @param ref The menu reference
|
* @param ref The menu reference
|
||||||
*/
|
*/
|
||||||
setMenuRef = (ref: Menu) => {
|
onMenuRef(ref: Menu) {
|
||||||
this._menu = ref;
|
this.sortMenuRef = ref;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -136,7 +145,7 @@ export default class ProximoListScreen extends React.Component<Props, State> {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
this.setupSortIcons(mode, isReverse);
|
this.setupSortIcons(mode, isReverse);
|
||||||
this._menu.hide();
|
this.sortMenuRef.hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -219,7 +228,7 @@ export default class ProximoListScreen extends React.Component<Props, State> {
|
||||||
return filteredData;
|
return filteredData;
|
||||||
}
|
}
|
||||||
|
|
||||||
search(str: string) {
|
onSearchStringChange(str: string) {
|
||||||
this.setState({
|
this.setState({
|
||||||
currentlyDisplayedData: this.filterData(str)
|
currentlyDisplayedData: this.filterData(str)
|
||||||
})
|
})
|
||||||
|
@ -265,27 +274,27 @@ export default class ProximoListScreen extends React.Component<Props, State> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
selectSortModeName() {
|
onSelectSortModeName() {
|
||||||
this.sortModeSelected(sortMode.name);
|
this.sortModeSelected(sortMode.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
selectSortModePrice() {
|
onSelectSortModePrice() {
|
||||||
this.sortModeSelected(sortMode.price);
|
this.sortModeSelected(sortMode.price);
|
||||||
}
|
}
|
||||||
|
|
||||||
showMenu() {
|
onSortMenuPress() {
|
||||||
this._menu.show();
|
this.sortMenuRef.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
getSortMenu() {
|
getSortMenu() {
|
||||||
return (
|
return (
|
||||||
<Menu
|
<Menu
|
||||||
ref={this.setMenuRef}
|
ref={this.onMenuRef}
|
||||||
button={
|
button={
|
||||||
<Touchable
|
<Touchable
|
||||||
style={{padding: 6}}
|
style={{padding: 6}}
|
||||||
onPress={this.showMenu}>
|
onPress={this.onSortMenuPress}>
|
||||||
<CustomMaterialIcon
|
<CustomMaterialIcon
|
||||||
color={Platform.OS === 'ios' ? ThemeManager.getCurrentThemeVariables().brandPrimary : "#fff"}
|
color={Platform.OS === 'ios' ? ThemeManager.getCurrentThemeVariables().brandPrimary : "#fff"}
|
||||||
icon={'sort'}/>
|
icon={'sort'}/>
|
||||||
|
@ -293,12 +302,12 @@ export default class ProximoListScreen extends React.Component<Props, State> {
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
onPress={this.selectSortModeName}>
|
onPress={this.onSelectSortModeName}>
|
||||||
{this.state.sortNameIcon}
|
{this.state.sortNameIcon}
|
||||||
{i18n.t('proximoScreen.sortName')}
|
{i18n.t('proximoScreen.sortName')}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem
|
<MenuItem
|
||||||
onPress={this.selectSortModePrice}>
|
onPress={this.onSelectSortModePrice}>
|
||||||
{this.state.sortPriceIcon}
|
{this.state.sortPriceIcon}
|
||||||
{i18n.t('proximoScreen.sortPrice')}
|
{i18n.t('proximoScreen.sortPrice')}
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
|
@ -306,7 +315,8 @@ export default class ProximoListScreen extends React.Component<Props, State> {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
renderItem({item}) {
|
renderItem({item}: Object) {
|
||||||
|
console.log(item);
|
||||||
return (<ListItem
|
return (<ListItem
|
||||||
thumbnail
|
thumbnail
|
||||||
onPress={() => {
|
onPress={() => {
|
||||||
|
@ -335,7 +345,7 @@ export default class ProximoListScreen extends React.Component<Props, State> {
|
||||||
</ListItem>);
|
</ListItem>);
|
||||||
}
|
}
|
||||||
|
|
||||||
keyExtractor(item) {
|
keyExtractor(item: Object) {
|
||||||
return item.name + item.code;
|
return item.name + item.code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,7 +363,7 @@ export default class ProximoListScreen extends React.Component<Props, State> {
|
||||||
hasBackButton={true}
|
hasBackButton={true}
|
||||||
navigation={nav}
|
navigation={nav}
|
||||||
hasSearchField={true}
|
hasSearchField={true}
|
||||||
searchCallback={this.search}
|
searchCallback={this.onSearchStringChange}
|
||||||
shouldFocusSearchBar={this.shouldFocusSearchBar}
|
shouldFocusSearchBar={this.shouldFocusSearchBar}
|
||||||
rightButton={this.getSortMenu()}
|
rightButton={this.getSortMenu()}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -18,6 +18,9 @@ const DATA_URL = "https://srv-falcon.etud.insa-toulouse.fr/~proximo/data/stock-v
|
||||||
*/
|
*/
|
||||||
export default class ProximoMainScreen extends FetchedDataSectionList {
|
export default class ProximoMainScreen extends FetchedDataSectionList {
|
||||||
|
|
||||||
|
onPressSearchBtn: Function;
|
||||||
|
onPressAboutBtn: Function;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super(DATA_URL, 0);
|
super(DATA_URL, 0);
|
||||||
this.onPressSearchBtn = this.onPressSearchBtn.bind(this);
|
this.onPressSearchBtn = this.onPressSearchBtn.bind(this);
|
||||||
|
|
|
@ -36,6 +36,8 @@ const REFRESH_TIME = 1000 * 10; // Refresh every 10 seconds
|
||||||
*/
|
*/
|
||||||
export default class ProxiwashScreen extends FetchedDataSectionList {
|
export default class ProxiwashScreen extends FetchedDataSectionList {
|
||||||
|
|
||||||
|
onAboutPress: Function;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates machine state parameters using current theme and translations
|
* Creates machine state parameters using current theme and translations
|
||||||
*/
|
*/
|
||||||
|
@ -76,7 +78,7 @@ export default class ProxiwashScreen extends FetchedDataSectionList {
|
||||||
};
|
};
|
||||||
this.setMinTimeRefresh(30);
|
this.setMinTimeRefresh(30);
|
||||||
|
|
||||||
this.navigateToAboutScreen = this.navigateToAboutScreen.bind(this);
|
this.onAboutPress = this.onAboutPress.bind(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -274,7 +276,7 @@ export default class ProxiwashScreen extends FetchedDataSectionList {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
navigateToAboutScreen() {
|
onAboutPress() {
|
||||||
this.props.navigation.navigate('ProxiwashAboutScreen');
|
this.props.navigation.navigate('ProxiwashAboutScreen');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,7 +284,7 @@ export default class ProxiwashScreen extends FetchedDataSectionList {
|
||||||
return (
|
return (
|
||||||
<Touchable
|
<Touchable
|
||||||
style={{padding: 6}}
|
style={{padding: 6}}
|
||||||
onPress={this.navigateToAboutScreen}>
|
onPress={this.onAboutPress}>
|
||||||
<CustomMaterialIcon
|
<CustomMaterialIcon
|
||||||
color={Platform.OS === 'ios' ? ThemeManager.getCurrentThemeVariables().brandPrimary : "#fff"}
|
color={Platform.OS === 'ios' ? ThemeManager.getCurrentThemeVariables().brandPrimary : "#fff"}
|
||||||
icon="information"/>
|
icon="information"/>
|
||||||
|
|
Loading…
Reference in a new issue