Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import React, { Component } from 'react';
- import {
- View,
- Linking,Text,Alert, Image
- } from 'react-native';
- import Results from '../components/Results';
- import Header from '../components/Header';
- import styles from '../constants/styles';
- import { StackNavigator } from 'react-navigation';
- const algoliasearch = require('algoliasearch/reactnative')('*******', '**************************************');
- import AlgoliaSearchHelper from 'algoliasearch-helper';
- export default class LinksScreen extends React.Component {
- constructor(props) {
- super(props);
- this.state = { lastSearchResults: null };
- }
- static navigationOptions = {
- title: 'Preferiti',
- header: null
- };
- componentWillMount(){
- const helper = this.helper = AlgoliaSearchHelper(algoliasearch, '****************');
- helper.on('result', (res) => {
- this.setState({lastSearchResults: res});
- });
- }
- myfunc = () =>{
- const {navigate} = this.props.navigation;
- navigate('Prod_info', {prod_data: data});
- };
- render() {
- const {navigate} = this.props.navigation;
- const content = this.state.lastSearchResults &&
- <Results hits={this.state.lastSearchResults.hits} openLink={this.openLink} nav={navigate}/>;
- if(this.state.lastSearchResults==null){
- return(
- <View style={{flex: 1,
- alignItems: 'stretch',
- backgroundColor:'white'}}>
- <Header helper={this.helper} />
- {content}
- <View style={{
- flex: 1,
- flexDirection: 'column',
- justifyContent: 'center',
- alignItems: 'center',
- }}>
- <Image
- source={require('../assets/images/logo.png')}
- style={{height: 100, width: 100}}
- />
- <Text style={{color: '#46DB85', fontWeight: 'bold'}}>EFFETTUA UNA RICERCA!</Text>
- </View>
- </View>
- );
- }else{
- return (
- <View style={styles.container}>
- <Header helper={this.helper} />
- {content}
- </View>
- );}
- }
- openLink(url) {
- Linking.openURL(url);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement