-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from tomoima525/introduce_router_flux
Introduce router flux
- Loading branch information
Showing
14 changed files
with
533 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from 'react'; | ||
import {View, Text, StyleSheet} from "react-native"; | ||
//import Button from "react-native-button"; | ||
//import {Actions} from "react-native-router-flux"; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
alignItems: 'center', | ||
backgroundColor: 'white', | ||
marginTop: 10, | ||
}, | ||
textLayout: { | ||
padding: 10, | ||
backgroundColor: 'white', | ||
}, | ||
}); | ||
|
||
const DetailComponent = (props) => { | ||
return ( | ||
<View style={styles.container}> | ||
<Text style={styles.textLayout}> | ||
{props.item} | ||
</Text> | ||
</View> | ||
); | ||
} | ||
export default DetailComponent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import React from 'react'; | ||
import { HeaderBackButton } from 'react-navigation'; | ||
import PropTypes from 'prop-types'; | ||
import { View, StyleSheet, TouchableHighlight, TouchableNativeFeedback, Text } from 'react-native'; | ||
|
||
// Component for Back Buttons | ||
|
||
const styles = StyleSheet.create({ | ||
barBackButtonText: { | ||
color: 'rgb(0, 122, 255)', | ||
textAlign: 'left', | ||
fontSize: 17, | ||
paddingLeft: 6, | ||
}, | ||
}); | ||
|
||
const BaseBackButton = props => ( | ||
<HeaderBackButton | ||
onPress={() => props.onPress()} | ||
title={props.backTitle} | ||
titleStyle={styles.barBackButtonText} | ||
/> | ||
); | ||
|
||
BaseBackButton.propTypes = { | ||
onPress: PropTypes.func.isRequired, | ||
backTitle: PropTypes.string.isRequired, | ||
}; | ||
|
||
export const BackButton = props => ( | ||
<BaseBackButton | ||
onPress={ | ||
props.onPress ? props.onPress : Actions.pop | ||
} | ||
backTitle={props.backTitle} | ||
/> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import React, { Component } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { View } from 'react-native'; | ||
import { connect } from 'react-redux'; | ||
import DetailComponent from '../components/DetailComponent'; | ||
|
||
//Container for detail | ||
const Detail = (props) => { | ||
console.log(props.item); | ||
return ( | ||
<View> | ||
<DetailComponent | ||
item={props.item} | ||
/> | ||
</View> | ||
); | ||
} | ||
|
||
Detail.propTypes = { | ||
item: PropTypes.string, | ||
} | ||
|
||
export default connect()(Detail); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import React from 'react'; | ||
import { View } from 'react-native'; | ||
import Detail from '../containers/Detail'; | ||
|
||
const DetailScene = props => { | ||
return ( | ||
<View> | ||
<Detail {...props}/> | ||
</View> | ||
); | ||
} | ||
|
||
export default DetailScene; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import React from 'react'; | ||
import { View, StyleSheet } from 'react-native'; | ||
import Input from '../containers/Input'; | ||
import ResultList from '../containers/ResultList'; | ||
|
||
const styles = StyleSheet.create({ | ||
container: { | ||
alignItems: 'center', | ||
backgroundColor: '#F5FCFF', | ||
}, | ||
}); | ||
|
||
const SearchScene = () => { | ||
return ( | ||
<View style={styles.container}> | ||
<Input/> | ||
<ResultList/> | ||
</View> | ||
); | ||
} | ||
|
||
export default SearchScene; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { Router, Scene, Actions } from 'react-native-router-flux'; | ||
import { connect } from 'react-redux'; | ||
import map from 'lodash.map'; | ||
import { BackButton } from '../components/common/BackButton'; | ||
import * as scenes from './scenes'; | ||
|
||
const RouterWithRedux = connect()(Router); | ||
|
||
const Scenes = (props, context) => ( | ||
<RouterWithRedux> | ||
<Scene key="root"> | ||
{ map(scenes, (component, name) => ( | ||
<Scene | ||
key={name} | ||
title={name} | ||
component={component} | ||
renderBackButton={() => | ||
<BackButton backTitle='back' onPress={() => Actions.pop() }/>} | ||
/> | ||
))} | ||
</Scene> | ||
</RouterWithRedux> | ||
); | ||
|
||
Scenes.contextTypes = { | ||
initialScene: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default connect()(Scenes); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { default as Search } from './SearchScene'; | ||
export { default as Detail } from './DetailScene'; |
Oops, something went wrong.