diff --git a/App.js b/App.js index 5de5714..7c5ac2d 100644 --- a/App.js +++ b/App.js @@ -31,9 +31,16 @@ export default class App extends React.Component { currentTheme: null, }; + onIntroDone: Function; + loadAssetsAsync: Function; + onLoadFinished: Function; + constructor(props: Object) { super(props); LocaleManager.initTranslations(); + this.onIntroDone = this.onIntroDone.bind(this); + this.loadAssetsAsync = this.loadAssetsAsync.bind(this); + this.onLoadFinished = this.onLoadFinished.bind(this); } /** @@ -102,14 +109,14 @@ export default class App extends React.Component { if (this.state.isLoading) { return ( this.loadAssetsAsync()} - onFinish={() => this.onLoadFinished()} + startAsync={this.loadAssetsAsync} + onFinish={this.onLoadFinished} onError={console.warn} /> ); } if (this.state.showIntro || this.state.showUpdate) { - return this.onIntroDone()} + return ; } else { const AppNavigator = createAppContainerWithInitialRoute(AsyncStorageManager.getInstance().preferences.defaultStartScreen.current); diff --git a/components/BaseContainer.js b/components/BaseContainer.js index 1e4fa85..c0b5bd0 100644 --- a/components/BaseContainer.js +++ b/components/BaseContainer.js @@ -30,7 +30,6 @@ type State = { export default class BaseContainer extends React.Component { - static defaultProps = { headerRightButton: , hasTabs: false, @@ -46,40 +45,61 @@ export default class BaseContainer extends React.Component { isHeaderVisible: true, }; - toggle() { + onDrawerPress: Function; + onWillFocus: Function; + onWillBlur: Function; + onChangeOrientation: Function; + + constructor() { + super(); + this.onDrawerPress = this.onDrawerPress.bind(this); + this.onWillFocus = this.onWillFocus.bind(this); + this.onWillBlur = this.onWillBlur.bind(this); + this.onChangeOrientation = this.onChangeOrientation.bind(this); + } + + onDrawerPress() { this.props.navigation.toggleDrawer(); } + + onWillFocus() { + if (this.props.enableRotation) { + ScreenOrientation.unlockAsync(); + ScreenOrientation.addOrientationChangeListener(this.onChangeOrientation); + } + } + + onWillBlur() { + if (this.props.enableRotation) + ScreenOrientation.lockAsync(ScreenOrientation.Orientation.PORTRAIT); + } + + onChangeOrientation(OrientationChangeEvent) { + if (this.props.hideHeaderOnLandscape) { + let isLandscape = OrientationChangeEvent.orientationInfo.orientation === ScreenOrientation.Orientation.LANDSCAPE || + OrientationChangeEvent.orientationInfo.orientation === ScreenOrientation.Orientation.LANDSCAPE_LEFT || + OrientationChangeEvent.orientationInfo.orientation === ScreenOrientation.Orientation.LANDSCAPE_RIGHT; + this.setState({isHeaderVisible: !isLandscape}); + const setParamsAction = NavigationActions.setParams({ + params: {showTabBar: !isLandscape}, + key: this.props.navigation.state.key, + }); + this.props.navigation.dispatch(setParamsAction); + StatusBar.setHidden(isLandscape); + } + } + /** * Register for blur event to close side menu on screen change */ componentDidMount() { this.willFocusSubscription = this.props.navigation.addListener( 'willFocus', - () => { - if (this.props.enableRotation) { - ScreenOrientation.unlockAsync(); - ScreenOrientation.addOrientationChangeListener((OrientationChangeEvent) => { - if (this.props.hideHeaderOnLandscape) { - let isLandscape = OrientationChangeEvent.orientationInfo.orientation === ScreenOrientation.Orientation.LANDSCAPE || - OrientationChangeEvent.orientationInfo.orientation === ScreenOrientation.Orientation.LANDSCAPE_LEFT || - OrientationChangeEvent.orientationInfo.orientation === ScreenOrientation.Orientation.LANDSCAPE_RIGHT; - this.setState({isHeaderVisible: !isLandscape}); - const setParamsAction = NavigationActions.setParams({ - params: {showTabBar: !isLandscape}, - key: this.props.navigation.state.key, - }); - this.props.navigation.dispatch(setParamsAction); - StatusBar.setHidden(isLandscape); - } - }); - } - }); + this.onWillFocus + ); this.willBlurSubscription = this.props.navigation.addListener( 'willBlur', - () => { - if (this.props.enableRotation) - ScreenOrientation.lockAsync(ScreenOrientation.Orientation.PORTRAIT); - } + this.onWillBlur ); } @@ -93,7 +113,9 @@ export default class BaseContainer extends React.Component { this.willFocusSubscription.remove(); } - getMainContainer() { + + render() { + // console.log("rendering BaseContainer"); return ( {this.state.isHeaderVisible ? @@ -104,7 +126,7 @@ export default class BaseContainer extends React.Component { leftButton={ this.toggle()}> + onPress={this.onDrawerPress}> @@ -118,9 +140,4 @@ export default class BaseContainer extends React.Component { ); } - - - render() { - return (this.getMainContainer()); - } } diff --git a/components/CustomHeader.js b/components/CustomHeader.js index 0290c89..c72e46f 100644 --- a/components/CustomHeader.js +++ b/components/CustomHeader.js @@ -32,11 +32,10 @@ type Props = { * @prop navigation {Object} The navigation object from react navigation */ export default class CustomHeader extends React.Component { - static defaultProps = { hasBackButton: false, hasSearchField: false, - searchCallback: () => null, + searchCallback: null, shouldFocusSearchBar: false, title: '', subtitle: '', @@ -45,10 +44,28 @@ export default class CustomHeader extends React.Component { hasTabs: false, }; + onPressBack: Function; + + constructor() { + super(); + this.onPressBack = this.onPressBack.bind(this); + } + + shouldComponentUpdate(nextProps: Props): boolean { + return nextProps.title !== this.props.title || + nextProps.subtitle !== this.props.subtitle || + nextProps.hasBackButton !== this.props.hasBackButton || + nextProps.hasSearchField !== this.props.hasSearchField || + nextProps.shouldFocusSearchBar !== this.props.shouldFocusSearchBar || + nextProps.hasTabs !== this.props.hasTabs || + nextProps.rightButton !== this.props.rightButton || + nextProps.leftButton !== this.props.leftButton; + } + componentDidMount() { if (this.refs.searchInput !== undefined && this.refs.searchInput._root !== undefined && this.props.shouldFocusSearchBar) { - // does not work if called to early for some reason... - setTimeout(() => this.refs.searchInput._root.focus(), 500); + // does not work if called too early for some reason... + setTimeout(this.refs.searchInput._root.focus, 500); } } @@ -67,7 +84,7 @@ export default class CustomHeader extends React.Component { ref="searchInput" placeholder={i18n.t('proximoScreen.search')} placeholderTextColor={ThemeManager.getCurrentThemeVariables().toolbarPlaceholderColor} - onChangeText={(text) => this.props.searchCallback(text)}/> + onChangeText={this.props.searchCallback}/> ); @@ -87,17 +104,20 @@ export default class CustomHeader extends React.Component { } + onPressBack() { + const backAction = NavigationActions.back(); + this.props.navigation.dispatch(backAction); + } + render() { + // console.log("rendering CustomHeader"); let button; // Does the app have a back button or a burger menu ? if (this.props.hasBackButton) button = { - const backAction = NavigationActions.back(); - this.props.navigation.dispatch(backAction); - }}> + onPress={this.onPressBack}> diff --git a/components/CustomIntroSlider.js b/components/CustomIntroSlider.js index 6e430e3..1ad4221 100644 --- a/components/CustomIntroSlider.js +++ b/components/CustomIntroSlider.js @@ -117,7 +117,7 @@ export default class CustomIntroSlider extends React.Component { * @param item * @param dimensions */ - static getIntroRenderItem(item: Object, dimensions: Object) { + static getIntroRenderItem({item, dimensions}: Object) { return ( { render() { return ( CustomIntroSlider.getIntroRenderItem(item, dimensions)} + renderItem={CustomIntroSlider.getIntroRenderItem} slides={this.props.isUpdate ? this.updateSlides : this.introSlides} - onDone={() => this.props.onDone()} + onDone={this.props.onDone} bottomButton showSkipButton skipLabel={i18n.t('intro.buttons.skip')} diff --git a/components/CustomMaterialIcon.js b/components/CustomMaterialIcon.js index e6919f2..4792b81 100644 --- a/components/CustomMaterialIcon.js +++ b/components/CustomMaterialIcon.js @@ -30,7 +30,16 @@ export default class CustomMaterialIcon extends React.Component { width: 30, }; + shouldComponentUpdate(nextProps: Props): boolean { + return nextProps.icon !== this.props.icon || + nextProps.active !== this.props.active || + nextProps.width !== this.props.width || + nextProps.fontSize !== this.props.fontSize || + nextProps.color !== this.props.color; + } + render() { + // console.log("rendering icon " + this.props.icon); return ( { - static defaultProps = { isSquare: false, isSquareLeft: true, displayEvent: undefined, }; + shouldComponentUpdate(nextProps: Props): boolean { + return nextProps.isAvailable !== this.props.isAvailable || + nextProps.subtitle !== this.props.subtitle; + } + + /** * Convert the date string given by in the event list json to a date object * @param dateString @@ -203,6 +208,7 @@ export default class DashboardItem extends React.Component { render() { + // console.log("rendering DashboardItem " + this.props.title); let marginRight = 10; if (this.props.isSquare) { if (this.props.isSquareLeft) diff --git a/components/FetchedDataSectionList.js b/components/FetchedDataSectionList.js index 65f6e7a..413eb25 100644 --- a/components/FetchedDataSectionList.js +++ b/components/FetchedDataSectionList.js @@ -25,7 +25,6 @@ type State = { * Used by inheriting from it and redefining getters. */ export default class FetchedDataSectionList extends React.Component { - webDataManager: WebDataManager; willFocusSubscription: function; @@ -42,12 +41,36 @@ export default class FetchedDataSectionList extends React.Component { - this.onScreenFocus(); - } - ); + 'willFocus', this.onScreenFocus.bind(this)); this.willBlurSubscription = this.props.navigation.addListener( - 'willBlur', - () => { - this.onScreenBlur(); - } - ); + 'willBlur', this.onScreenBlur.bind(this)); } /** * Refresh data when focusing the screen and setup a refresh interval if asked to */ onScreenFocus() { - this._onRefresh(); + this.onRefresh(); if (this.refreshTime > 0) - this.refreshInterval = setInterval(() => this._onRefresh(), this.refreshTime) + this.refreshInterval = setInterval(this.onRefresh.bind(this), this.refreshTime) } /** @@ -113,11 +128,29 @@ export default class FetchedDataSectionList extends React.Component { + onRefresh() { let canRefresh; if (this.lastRefresh !== undefined) canRefresh = (new Date().getTime() - this.lastRefresh.getTime()) / 1000 > this.minTimeBetweenRefresh; @@ -127,25 +160,10 @@ export default class FetchedDataSectionList extends React.Component { - this.setState({ - fetchedData: fetchedData, - refreshing: false, - firstLoading: false - }); - this.lastRefresh = new Date(); - }) - .catch(() => { - this.setState({ - fetchedData: {}, - refreshing: false, - firstLoading: false - }); - this.webDataManager.showUpdateToast(this.getUpdateToastTranslations()[0], this.getUpdateToastTranslations()[1]); - }); + .then(this.onFetchSuccess) + .catch(this.onFetchError); } - - }; + } /** * Get the render item to be used for display in the list. @@ -153,10 +171,9 @@ export default class FetchedDataSectionList extends React.Component; } @@ -222,6 +239,11 @@ export default class FetchedDataSectionList extends React.Component item.text, + keyExtractor: this.datasetKeyExtractor, } ]; } @@ -275,6 +297,19 @@ export default class FetchedDataSectionList extends React.Component : + this.getRenderSectionHeader(title) + } + + renderItem(isEmpty: boolean, {item, section}: Object) { + return isEmpty ? + this.getEmptyRenderItem(item.text, item.isSpinner, item.icon) : + this.getRenderItem(item, section) + } + /** * Get the section list render using the generated dataset * @@ -292,19 +327,11 @@ export default class FetchedDataSectionList extends React.Component } - renderSectionHeader={({section: {title}}) => - isEmpty ? - : - this.getRenderSectionHeader(title) - } - renderItem={({item, section}) => - isEmpty ? - this.getEmptyRenderItem(item.text, item.isSpinner, item.icon) : - this.getRenderItem(item, section, dataset) - } + renderSectionHeader={isEmpty ? this.renderSectionHeaderEmpty : this.renderSectionHeaderNotEmpty} + renderItem={isEmpty ? this.renderItemEmpty : this.renderItemNotEmpty} style={{minHeight: 300, width: '100%'}} contentContainerStyle={ isEmpty ? @@ -351,11 +378,12 @@ export default class FetchedDataSectionList extends React.Component ); } - } diff --git a/components/Sidebar.js b/components/Sidebar.js index 2edcc0c..cac9553 100644 --- a/components/Sidebar.js +++ b/components/Sidebar.js @@ -30,6 +30,8 @@ export default class SideBar extends React.Component { active: 'Home', }; + getRenderItem: Function; + /** * Generate the datasets * @@ -38,7 +40,6 @@ export default class SideBar extends React.Component { constructor(props: Props) { super(props); // Dataset used to render the drawer - // If the link field is defined, clicking on the item will open the link this.dataSet = [ { name: i18n.t('sidenav.divider1'), @@ -103,21 +104,34 @@ export default class SideBar extends React.Component { icon: "information", }, ]; + this.getRenderItem = this.getRenderItem.bind(this); } - getRenderItem(item: Object) { + shouldComponentUpdate(nextProps: Props, nextState: State): boolean { + return nextState.active !== this.state.active; + } + + + onListItemPress(route: string) { + this.props.navigation.navigate(route); + } + + + listKeyExtractor(item: Object) { + return item.route; + } + + + getRenderItem({item}: Object) { + const onListItemPress = this.onListItemPress.bind(this, item.route); + if (item.icon !== undefined) { return ( { - if (item.link !== undefined) - Linking.openURL(item.link).catch((err) => console.error('Error opening link', err)); - else - this.navigateToScreen(item.route); - }} + onPress={onListItemPress} > { } - /** - * Navigate to the selected route - * @param route {string} The route name to navigate to - */ - navigateToScreen(route: string) { - this.props.navigation.navigate(route); - }; - render() { + // console.log("rendering SideBar"); return ( { item.route} - renderItem={({item}) => this.getRenderItem(item)} + keyExtractor={this.listKeyExtractor} + renderItem={this.getRenderItem} /> ); diff --git a/components/WebViewScreen.js b/components/WebViewScreen.js index 480c425..69aa465 100644 --- a/components/WebViewScreen.js +++ b/components/WebViewScreen.js @@ -35,6 +35,21 @@ export default class WebViewScreen extends React.Component { }; webviewArray: Array = []; + onRefreshClicked: Function; + onWebviewRef: Function; + onGoBackWebview: Function; + onGoForwardWebview: Function; + onOpenWebLink: Function; + + constructor() { + super(); + this.onRefreshClicked = this.onRefreshClicked.bind(this); + this.onWebviewRef = this.onWebviewRef.bind(this); + this.onGoBackWebview = this.onGoBackWebview.bind(this); + this.onGoForwardWebview = this.onGoForwardWebview.bind(this); + this.onOpenWebLink = this.onOpenWebLink.bind(this); + } + openWebLink(url: string) { Linking.openURL(url).catch((err) => console.error('Error opening link', err)); } @@ -43,7 +58,7 @@ export default class WebViewScreen extends React.Component { return ( clickAction()}> + onPress={clickAction}> @@ -54,36 +69,62 @@ export default class WebViewScreen extends React.Component { getRefreshButton() { return ( - {this.getHeaderButton(() => this.refreshWebview(), 'refresh')} + {this.getHeaderButton(this.onRefreshClicked, 'refresh')} ); }; - refreshWebview() { + onRefreshClicked() { for (let view of this.webviewArray) { if (view !== null) view.reload(); } } - goBackWebview() { + onGoBackWebview() { for (let view of this.webviewArray) { if (view !== null) view.goBack(); } } - goForwardWebview() { + onGoForwardWebview() { for (let view of this.webviewArray) { if (view !== null) view.goForward(); } } + onOpenWebLink() { + this.openWebLink(this.props.data[0]['url']) + } + + onWebviewRef(ref: WebView) { + this.webviewArray.push(ref) + } + + getRenderLoading() { + return ( + + + + ); + } + getWebview(obj: Object) { return ( (this.webviewArray.push(ref))} + ref={this.onWebviewRef} source={{uri: obj['url']}} style={{ width: '100%', @@ -92,21 +133,7 @@ export default class WebViewScreen extends React.Component { startInLoadingState={true} injectedJavaScript={obj['customJS']} javaScriptEnabled={true} - renderLoading={() => - - - - } + renderLoading={this.getRenderLoading} /> ); } @@ -133,6 +160,7 @@ export default class WebViewScreen extends React.Component { } render() { + // console.log("rendering WebViewScreen"); const nav = this.props.navigation; this.webviewArray = []; return ( @@ -166,7 +194,7 @@ export default class WebViewScreen extends React.Component { - {this.getHeaderButton(() => this.openWebLink(this.props.data[0]['url']), 'open-in-new')} + {this.getHeaderButton(this.onOpenWebLink, 'open-in-new')} { marginRight: 0, marginLeft: 'auto' }}> - {this.getHeaderButton(() => this.goBackWebview(), 'chevron-left')} - {this.getHeaderButton(() => this.goForwardWebview(), 'chevron-right')} + {this.getHeaderButton(this.onGoBackWebview, 'chevron-left')} + {this.getHeaderButton(this.onGoForwardWebview, 'chevron-right')} : } diff --git a/screens/About/AboutScreen.js b/screens/About/AboutScreen.js index 0f2a8f1..098d4a5 100644 --- a/screens/About/AboutScreen.js +++ b/screens/About/AboutScreen.js @@ -187,9 +187,14 @@ export default class AboutScreen extends React.Component { }, ]; + getCardItem: Function; + getMainCard: Function; + constructor(props: any) { super(props); this.modalRef = React.createRef(); + this.getCardItem = this.getCardItem.bind(this); + this.getMainCard = this.getMainCard.bind(this); } getAppCard() { @@ -210,10 +215,8 @@ export default class AboutScreen extends React.Component { data={this.appData} extraData={this.state} keyExtractor={(item) => item.icon} - listKey={(item) => "app"} - renderItem={({item}) => - this.getCardItem(item.onPressCallback, item.icon, item.text, item.showChevron, item.showOnlyDebug) - } + listKey={"app"} + renderItem={this.getCardItem} /> ); @@ -241,10 +244,8 @@ export default class AboutScreen extends React.Component { data={this.authorData} extraData={this.state} keyExtractor={(item) => item.icon} - listKey={(item) => "team1"} - renderItem={({item}) => - this.getCardItem(item.onPressCallback, item.icon, item.text, item.showChevron, item.showOnlyDebug) - } + listKey={"team1"} + renderItem={this.getCardItem} /> {i18n.t('aboutScreen.additionalDev')} @@ -253,10 +254,8 @@ export default class AboutScreen extends React.Component { data={this.additionalDevData} extraData={this.state} keyExtractor={(item) => item.icon} - listKey={(item) => "team2"} - renderItem={({item}) => - this.getCardItem(item.onPressCallback, item.icon, item.text, item.showChevron, item.showOnlyDebug) - } + listKey={"team2"} + renderItem={this.getCardItem} /> ); @@ -272,10 +271,8 @@ export default class AboutScreen extends React.Component { data={this.technoData} extraData={this.state} keyExtractor={(item) => item.icon} - listKey={(item) => "techno"} - renderItem={({item}) => - this.getCardItem(item.onPressCallback, item.icon, item.text, item.showChevron, item.showOnlyDebug) - } + listKey={"techno"} + renderItem={this.getCardItem} /> ); @@ -284,24 +281,19 @@ export default class AboutScreen extends React.Component { /** * Get a clickable card item to be rendered inside a card. * - * @param onPressCallback The callback to use when the item is clicked - * @param icon The icon name to use from MaterialCommunityIcons - * @param text The text to show - * @param showChevron Whether to show a chevron indicating this button will change screen - * @param showOnlyInDebug Should we show te current item only in debug mode? * @returns {React.Node} */ - getCardItem(onPressCallback: Function, icon: string, text: string, showChevron: boolean, showOnlyInDebug: boolean) { - let shouldShow = !showOnlyInDebug || (showOnlyInDebug && this.state.isDebugUnlocked); + getCardItem({item}: Object) { + let shouldShow = !item.showOnlyInDebug || (item.showOnlyInDebug && this.state.isDebugUnlocked); if (shouldShow) { return ( + onPress={item.onPressCallback}> - - {text} + + {item.text} - {showChevron ? + {item.showChevron ? @@ -331,6 +323,8 @@ export default class AboutScreen extends React.Component { } getBugReportModal() { + const onPressMail = openWebLink.bind(this, links.bugsMail); + const onPressGit = openWebLink.bind(this, links.bugsGit); return ( { marginLeft: 'auto', marginRight: 'auto', }} - onPress={() => openWebLink(links.bugsMail)}> + onPress={onPressMail}> @@ -361,7 +355,7 @@ export default class AboutScreen extends React.Component { marginLeft: 'auto', marginRight: 'auto', }} - onPress={() => openWebLink(links.bugsGit)}> + onPress={onPressGit}> @@ -378,7 +372,7 @@ export default class AboutScreen extends React.Component { } } - getMainCard(item: Object) { + getMainCard({item}: Object) { switch (item.id) { case 'app': return this.getAppCard(); @@ -401,9 +395,7 @@ export default class AboutScreen extends React.Component { data={this.dataOrder} extraData={this.state} keyExtractor={(item) => item.id} - renderItem={({item}) => - this.getMainCard(item) - } + renderItem={this.getMainCard} /> ); diff --git a/screens/HomeScreen.js b/screens/HomeScreen.js index 2980cf7..2640ef5 100644 --- a/screens/HomeScreen.js +++ b/screens/HomeScreen.js @@ -38,8 +38,33 @@ function openWebLink(link) { */ export default class HomeScreen extends FetchedDataSectionList { + onProxiwashClick: Function; + onTutorInsaClick: Function; + onMenuClick: Function; + onProximoClick: Function; + constructor() { super(DATA_URL, REFRESH_TIME); + this.onProxiwashClick = this.onProxiwashClick.bind(this); + this.onTutorInsaClick = this.onTutorInsaClick.bind(this); + this.onMenuClick = this.onMenuClick.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'); } /** @@ -289,6 +314,14 @@ export default class HomeScreen extends FetchedDataSectionList { } + clickAction(isAvailable: boolean, displayEvent: Object) { + if (isAvailable) + this.props.navigation.navigate('PlanningDisplayScreen', {data: displayEvent}); + else + this.props.navigation.navigate('PlanningScreen'); + }; + + getDashboardEventItem(content: Array) { let icon = 'calendar-range'; let color = ThemeManager.getCurrentThemeVariables().planningColor; @@ -310,12 +343,6 @@ export default class HomeScreen extends FetchedDataSectionList { ; } else subtitle = i18n.t('homeScreen.dashboard.todayEventsSubtitleNA'); - let clickAction = () => { - if (isAvailable) - this.props.navigation.navigate('PlanningDisplayScreen', {data: displayEvent}); - else - this.props.navigation.navigate('PlanningScreen'); - }; let displayEvent = this.getDisplayEvent(futureEvents); @@ -324,7 +351,7 @@ export default class HomeScreen extends FetchedDataSectionList { subtitle={subtitle} color={color} icon={icon} - clickAction={() => clickAction()} + clickAction={this.clickAction.bind(this, isAvailable, displayEvent)} title={title} isAvailable={isAvailable} displayEvent={displayEvent} @@ -355,7 +382,6 @@ export default class HomeScreen extends FetchedDataSectionList { ; } else proximoSubtitle = i18n.t('homeScreen.dashboard.proximoSubtitleNA'); - let proximoClickAction = () => this.props.navigation.navigate('Proximo'); let menuIcon = 'silverware-fork-knife'; @@ -367,7 +393,6 @@ export default class HomeScreen extends FetchedDataSectionList { menuSubtitle = i18n.t('homeScreen.dashboard.menuSubtitle'); } else menuSubtitle = i18n.t('homeScreen.dashboard.menuSubtitleNA'); - let menuClickAction = () => this.props.navigation.navigate('SelfMenuScreen'); return ( menuClickAction()} + clickAction={this.onMenuClick} title={menuTitle} isAvailable={isMenuAvailable} isSquareLeft={true}/> @@ -388,13 +413,14 @@ export default class HomeScreen extends FetchedDataSectionList { subtitle={proximoSubtitle} color={proximoColor} icon={proximoIcon} - clickAction={() => proximoClickAction()} + clickAction={this.onProximoClick} title={proximoTitle} isAvailable={isProximoAvailable}/> ); } + getDashboardMiddleItem(content: Array) { let proxiwashData = content[0]['data']; let tutorinsaData = content[1]['data']; @@ -449,7 +475,6 @@ export default class HomeScreen extends FetchedDataSectionList { ; } else proxiwashSubtitle = i18n.t('homeScreen.dashboard.proxiwashSubtitleNA'); - let proxiwashClickAction = () => this.props.navigation.navigate('Proxiwash'); let tutorinsaIcon = 'school'; let tutorinsaColor = ThemeManager.getCurrentThemeVariables().tutorinsaColor; @@ -470,7 +495,6 @@ export default class HomeScreen extends FetchedDataSectionList { ; } else tutorinsaSubtitle = i18n.t('homeScreen.dashboard.tutorinsaSubtitleNA'); - let tutorinsaClickAction = () => this.props.navigation.navigate('TutorInsaScreen'); return ( proxiwashClickAction()} + clickAction={this.onProxiwashClick} title={proxiwashTitle} isAvailable={proxiwashIsAvailable} isSquareLeft={true}/> @@ -492,7 +516,7 @@ export default class HomeScreen extends FetchedDataSectionList { subtitle={tutorinsaSubtitle} color={tutorinsaColor} icon={tutorinsaIcon} - clickAction={() => tutorinsaClickAction()} + clickAction={this.onTutorInsaClick} title={tutorinsaTitle} isAvailable={tutorinsaIsAvailable}/> @@ -500,7 +524,7 @@ export default class HomeScreen extends FetchedDataSectionList { } - getRenderItem(item: Object, section: Object, data: Object) { + getRenderItem(item: Object, section: Object) { return ( section['id'] === SECTIONS_ID[0] ? this.getDashboardItem(item) : {item.full_picture !== '' && item.full_picture !== undefined ? - openWebLink(item.full_picture)} +