bluejoyq

add search result map

......@@ -2,8 +2,8 @@
"devToolsPort": 19002,
"expoServerPort": 19000,
"packagerPort": 19001,
"packagerPid": 24884,
"packagerPid": 12024,
"expoServerNgrokUrl": "https://s4-47j.anonymous.searchguide.exp.direct",
"packagerNgrokUrl": "https://packager.s4-47j.anonymous.searchguide.exp.direct",
"ngrokPid": 25980
"ngrokPid": 22188
}
......
import React from 'react';
import { View} from 'react-native';
import {connect} from 'react-redux'
import Icon from 'react-native-vector-icons/FontAwesome';
import SearchBarContainer from '../SearchBar/SearchBar';
import SearchBar from '../SearchBar/SearchBar';
import SearchCard from '../SearchCard/SearchCard';
const Home = () => {
const Home = ({searchResults}) => {
return(
<View style={{flex: 1, backgroundColor:'#eee', margin:0,padding:0}}>
<SearchBarContainer />
<SearchCard title={'네이버- 지식인...인간사냥꾼 니달리를ㄴㄴㅁ'} content={'문도 가고 싶은 데로 간다!'} url={'https://www.naver.com'}/>
<SearchBar />
{ searchResults && searchResults.map((searchResult, index) => (
<SearchCard key={index} title={searchResult.title} content={searchResult.passage} url={searchResult.url}/>
))}
</View>
)
}
Home.navigationOptions={
const HomeContainer = ({searchResults}) => {
return(<Home searchResults={searchResults} />)
}
HomeContainer.navigationOptions={
title:'검색',
tabBarIcon: ({tintColor}) => (<Icon name="search" color={tintColor} style={{marginLeft:2}} size={20} />),
}
export default Home;
\ No newline at end of file
export default connect(
({search})=>({
searchResults:search.result.return_data.searchResults
})
)(HomeContainer);
\ No newline at end of file
......
......@@ -6,9 +6,7 @@ import {Linking } from 'react-native';
const SearchCard = (props) => (
<Card style={{margin:10}}>
<Card.Title title={props.title}
left={ (props) => (
<Avatar.Icon {...props} icon="folder" color={WHITE_MAIN}style={{backgroundColor:LIGHT_MAIN}} /> ) }
/>
left={ (props) => ( <Avatar.Icon {...props} icon="folder" color={WHITE_MAIN}style={{backgroundColor:LIGHT_MAIN}} /> ) } />
<Card.Content>
<Paragraph>{props.content}</Paragraph>
</Card.Content>
......
......@@ -16,7 +16,8 @@ export const submit = (text) => async (dispatch) => {
try{
/*const response = await sendSearch(text);*/
const response = await readTest(); // 테스트용입니당~
setTimeout(()=>dispatch( { type:SUCCESS, result:response }),1000); // 셋타임아웃도 테스트용
dispatch( { type:SUCCESS, result:response })
//setTimeout(()=>,1000); // 셋타임아웃도 테스트용
}
catch(err){
dispatch({ type:FAILURE, result:response })
......@@ -26,7 +27,11 @@ export const submit = (text) => async (dispatch) => {
const initialState = {
query: '',
searchResult:{},
result: {
return_data: {
searchResults: []
}
},
isLoading: false,
};
......@@ -35,7 +40,7 @@ export default ToggleLoading = (state = initialState, action) => {
case CHANGE:
return {...state, query: action.text};
case SUCCESS:
return {...state, isLoading:false,searchResult: action.response};
return {...state, isLoading:false,result: action.result};
case FAILURE:
return {...state, isLoading:false};
case START:
......