diff --git a/components/CustomHeader.js b/components/CustomHeader.js index 0a6e4f9..837e8d6 100644 --- a/components/CustomHeader.js +++ b/components/CustomHeader.js @@ -1,7 +1,7 @@ // @flow import * as React from "react"; -import {Body, Header, Input, Item, Left, Right, Title} from "native-base"; +import {Body, Header, Input, Item, Left, Right, Title, Form} from "native-base"; import {Platform, StyleSheet, View} from "react-native"; import {getStatusBarHeight} from "react-native-status-bar-height"; import Touchable from 'react-native-platform-touchable'; @@ -42,15 +42,16 @@ export default class CustomHeader extends React.Component { hasTabs: false, }; - searchBarRef: Input; - componentDidMount() { - if (this.searchBarRef !== undefined && this.props.shouldFocusSearchBar) - this.searchBarRef.focus(); + if (this.refs.searchInput !== undefined && this.props.shouldFocusSearchBar) { + // does not work if called to early for some reason... + setInterval(() => this.refs.searchInput._root.focus(), 500); + } } getSearchBar() { return ( +
{ icon={'magnify'} color={ThemeManager.getCurrentThemeVariables().toolbarBtnColor}/> this.searchBarRef = ref} + ref="searchInput" placeholder={i18n.t('proximoScreen.search')} placeholderTextColor={ThemeManager.getCurrentThemeVariables().toolbarPlaceholderColor} onChangeText={(text) => this.props.searchCallback(text)}/> +
); } diff --git a/screens/Proximo/ProximoListScreen.js b/screens/Proximo/ProximoListScreen.js index cea1dae..7575f8c 100644 --- a/screens/Proximo/ProximoListScreen.js +++ b/screens/Proximo/ProximoListScreen.js @@ -45,7 +45,6 @@ type Props = { } type State = { - navData: Array, currentSortMode: string, isSortReversed: boolean, sortPriceIcon: React.Node, @@ -62,13 +61,12 @@ export default class ProximoListScreen extends React.Component { modalRef: { current: null | Modalize }; originalData: Array; navData = this.props.navigation.getParam('data', []); - shouldFocusSearchBar = this.navData['shouldFocusSearchBar']; + shouldFocusSearchBar = this.props.navigation.getParam('shouldFocusSearchBar', false); constructor(props: any) { super(props); this.modalRef = React.createRef(); this.originalData = this.navData['data']; - } state = { @@ -300,7 +298,6 @@ export default class ProximoListScreen extends React.Component { render() { const nav = this.props.navigation; const navType = nav.getParam('type', '{name: "Error"}'); - return ( , type: ?Object) { + getAvailableArticles(articles: Array, type: ?Object) { let availableArticles = []; for (let k = 0; k < articles.length; k++) { if ((type !== undefined && type !== null && articles[k]['type'].includes(type['id']) @@ -109,7 +109,8 @@ export default class ProximoMainScreen extends FetchedDataSectionList { name: i18n.t('proximoScreen.all'), icon: 'star' }, - data: this.getAvailableArticles(this.state.fetchedData.articles, undefined) + data: this.state.fetchedData.articles !== undefined ? + this.getAvailableArticles(this.state.fetchedData.articles, undefined) : [] }, };