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