bluejoyq

change name of ToggleLoading to loading

......@@ -5,27 +5,19 @@ import SearchBarContainer from '../SearchBar/SearchBar';
import SearchCard from '../SearchCard/SearchCard';
class Home extends React.Component {
constructor(props) {
super(props);
this.state = {
}
}
static navigationOptions={
title:'검색',
tabBarIcon: ({tintColor}) => (<Icon name="search" color={tintColor} style={{marginLeft:2}} size={20} />),
}
render() {
return(
<View style={{flex: 1, backgroundColor:'#eee', margin:0,padding:0}}>
<SearchBarContainer />
<SearchCard title={'네이버- 지식인...인간사냥꾼 니달리를ㄴㄴㅁ'} content={'문도 가고 싶은 데로 간다!'} url={'https://www.naver.com'}/>
</View>
)
}
const Home = () => {
return(
<View style={{flex: 1, backgroundColor:'#eee', margin:0,padding:0}}>
<SearchBarContainer />
<SearchCard title={'네이버- 지식인...인간사냥꾼 니달리를ㄴㄴㅁ'} content={'문도 가고 싶은 데로 간다!'} url={'https://www.naver.com'}/>
</View>
)
}
Home.navigationOptions={
title:'검색',
tabBarIcon: ({tintColor}) => (<Icon name="search" color={tintColor} style={{marginLeft:2}} size={20} />),
}
export default Home;
\ No newline at end of file
......
......@@ -3,7 +3,7 @@ import AppTabContainer from '../AppTabContainer/AppTabContainer';
import Loading from '../Loading/Loading';
import { connect } from 'react-redux';
const Main = ({ isLoading, toggleLoading}) => {
const Main = ({ isLoading}) => {
if ( isLoading ) {
return(
<>
......@@ -24,6 +24,6 @@ const MainContainer = ({isLoading}) => {
return(<Main isLoading={isLoading} />)
}
const mapStateToProps = (state) => ({isLoading : state.ToggleLoading.isLoading})
const mapStateToProps = (state) => ({isLoading : state.loading.isLoading})
export default connect(mapStateToProps)(MainContainer);
\ No newline at end of file
......
......@@ -2,27 +2,17 @@ import React from 'react';
import { View, Text} from 'react-native';
import Icon from 'react-native-vector-icons/FontAwesome';
class Rate extends React.Component {
constructor(props) {
super(props);
this.state = {
}
}
static navigationOptions={
title:'평가',
tabBarIcon: ({tintColor})=> (<Icon name="bar-chart-o" color={tintColor} style={{marginLeft:0.5}} size={20} />),
}
const Rate = () => {
return(
<View style={{flex: 1, backgroundColor:'#eee', margin:0,padding:0}}>
<Text >평가</Text>
</View>
)
}
render() {
return(
<View style={{flex: 1, backgroundColor:'#eee', margin:0,padding:0}}>
<Text >평가</Text>
</View>
)
}
Rate.navigationOptions={
title:'평가',
tabBarIcon: ({tintColor})=> (<Icon name="bar-chart-o" color={tintColor} style={{marginLeft:0.5}} size={20} />),
}
export default Rate;
\ No newline at end of file
......
......@@ -2,8 +2,17 @@ import React from 'react';
import {View,Alert} from 'react-native';
import { Searchbar } from 'react-native-paper';
import { connect } from 'react-redux';
import {toggleLoading} from '../../reducers/ToggleLoading';
import {toggle} from '../../reducers/loading';
const voiceRecognition=()=>{
Alert.alert(
'음성 인식',
'아직 구현 못함',
[
{text: '확인', onPress: () => {}},
],
)
}
class SearchBar extends React.Component {
constructor(props){
......@@ -42,7 +51,7 @@ class SearchBar extends React.Component {
onChangeText={this.queryChange}
value={this.state.query}
icon='microphone'
onIconPress={this.voiceRecognition}
onIconPress={voiceRecognition}
onSubmitEditing={this.submit}
/>
</View>
......@@ -51,10 +60,10 @@ class SearchBar extends React.Component {
}
}
const SearchBarContainer = ({toggleLoading}) => {
return(<SearchBar toggleLoading={toggleLoading} />)
const SearchBarContainer = ({toggle}) => {
return(<SearchBar toggleLoading={toggle} />)
}
const mapDispatchToProps = (dispatch) => ({toggleLoading : ()=>{ dispatch( toggleLoading() )}});
const mapDispatchToProps = (dispatch) => ({toggle : ()=>{ dispatch( toggle() )}});
export default connect(null,mapDispatchToProps)(SearchBarContainer);
\ No newline at end of file
......
import { createStore, combineReducers } from 'redux';
import ToggleLoading from './ToggleLoading'
import loading from './loading'
const store = combineReducers({ ToggleLoading });
const store = combineReducers({ loading });
export default createStore(store)
\ No newline at end of file
......
const TOGGLE_LOADING = 'ToggleLoading/TOGGLE';
const TOGGLE = 'loading/TOGGLE';
export const toggleLoading = () => ({ type: TOGGLE_LOADING,})
export const toggle = () => ({ type: TOGGLE,})
const initialState = {
isLoading: false,
};
export default ToggleLoading = (state = initialState, action) => {
export default loading = (state = initialState, action) => {
switch (action.type) {
case TOGGLE_LOADING:
case TOGGLE:
return {...state, isLoading: !state.isLoading };
default:
return state;
......
const CHANGE = 'search/CHANGE';
const SUBMIT = 'search/SUBMIT';
export const change = (text) => ({
type: CHANGE,
text,
})
export const submit = (text) => ({
type: CHANGE,
text,
})
const initialState = {
query: '',
searchResult:{},
};
export default ToggleLoading = (state = initialState, action) => {
switch (action.type) {
case CHANGE:
return {...state, query: action.text};
case SUBMIT:
return {...state, query: ''}
default:
return state;
}
}
submit=()=>{
this.props.toggleLoading();
setTimeout(()=>{this.props.toggleLoading()},1000);
this.setState({query:''});
}