Skip to content

Commit

Permalink
push test
Browse files Browse the repository at this point in the history
  • Loading branch information
parkerdan committed Feb 5, 2017
1 parent 6deebbb commit 5373c6b
Show file tree
Hide file tree
Showing 9 changed files with 87 additions and 36 deletions.
15 changes: 5 additions & 10 deletions app/tabBar/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import findRouteIndexByName from '../helperFunctions/findRouteIndexByName'

const defaultState = {
index:0,
routes: routeStack
routes: routeStack,
}
const reducer = (state=defaultState,action) => {
switch (action.type) {
case 'Navigate':
case 'Navigation/NAVIGATE':
var index = findRouteIndexByName(routeStack,action.routeName)
if ( index !== -1 ) {
return { ...state, index: index }
Expand All @@ -18,14 +18,9 @@ const reducer = (state=defaultState,action) => {
}
break;

case 'Back':
if (action.key === 'TabBarBack') {
var currentIndex = state.index
return { ...state, index: currentIndex - 1 }
} else {
return state
}

case 'Navigation/BACK':
var currentIndex = state.index
return { ...state, index: currentIndex - 1 }
break;
}
return state
Expand Down
45 changes: 28 additions & 17 deletions app/tabBar/views/TabBarNavigation.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use strict'
// React
import React from 'react'
import { BackAndroid } from 'react-native'
import { BackAndroid, View } from 'react-native'
// Navigation
import { TabNavigator, addNavigationHelpers } from 'react-navigation'
import { routeConfiguration, tabBarConfiguration } from '../navigationConfiguration'
Expand All @@ -10,7 +10,10 @@ import { connect } from 'react-redux'
const TabBar = TabNavigator(routeConfiguration,tabBarConfiguration)
const mapStateToProps = (state) => {
return {
navigationState: state.tabBar
navigationState: state.tabBar,
// tabOneIndex: state.tabOne.index,
// tabTwoIndex: state.tabTwo.index,
// tabThreeIndex: state.tabThree.index,
}
}
const mapDispatchToProps = (dispatch) => {
Expand All @@ -27,26 +30,34 @@ class TabBarNavigation extends React.Component {
}

handleBackAction = () => {
if (this.props.navigationState.index === 0) {
return false
} else {
this.navigator.props.navigation.goBack('TabBarBack')
return true
}
// const { navigationState: {index: tabIndex}, tabOneIndex, tabTwoIndex, tabThreeIndex } = this.props
//
// const tabIndexArray = [ tabOneIndex, tabTwoIndex, tabThreeIndex ]
//
// if ( tabIndex === 0 && tabIndexArray[tabIndex] === 0) {
// return false
// } else if ( tabIndexArray[tabIndex] === 0 ) {
// this.navigator.props.navigation.goBack()
// return true
// } else {
// return true
// }
}

render(){
const { dispatch, navigationState } = this.props
return (
<TabBar
ref={ (ref) => this.navigator = ref }
navigation={
addNavigationHelpers({
dispatch: dispatch,
state: navigationState,
})
}
/>
<View style={{flex:1}}>
<TabBar
ref={ (ref) => this.navigator = ref }
navigation={
addNavigationHelpers({
dispatch: dispatch,
state: navigationState,
})
}
/>
</View>
)
}
}
Expand Down
4 changes: 2 additions & 2 deletions app/tabOne/views/TabOneNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { connect } from 'react-redux'
// Icon
import Icon from 'react-native-vector-icons/FontAwesome'

const Navigator = StackNavigator(routeConfiguration,stackNavigatorConfiguration)
const NavigatorTabOne = StackNavigator(routeConfiguration,stackNavigatorConfiguration)

const mapStateToProps = (state) => {
return {
Expand All @@ -36,7 +36,7 @@ class TabOneNavigation extends React.Component {
render(){
const { dispatch, navigationState} = this.props
return (
<Navigator
<NavigatorTabOne
navigation={
addNavigationHelpers({
dispatch: dispatch,
Expand Down
10 changes: 9 additions & 1 deletion app/tabOne/views/TabOneScreenOne.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'
import React from 'react'
import { View, Text } from 'react-native'
import { View, Text, TouchableOpacity } from 'react-native'
export default class TabOneScreenOne extends React.Component {
render(){
return(
Expand All @@ -10,6 +10,14 @@ export default class TabOneScreenOne extends React.Component {
alignItems:'center',
justifyContent:'center'
}}>
<TouchableOpacity
onPress={ () => console.log('pressed!') }
style={{
padding:20,
backgroundColor:'yellow'
}}>
<Text>{ 'Hi' }</Text>
</TouchableOpacity>
<Text>{ 'Tab One Screen One' }</Text>
</View>
)
Expand Down
10 changes: 10 additions & 0 deletions app/tabThree/reducer.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
'use strict'
import { routeStack } from './navigationConfiguration'
import findRouteIndexByName from '../helperFunctions/findRouteIndexByName'
const defaultState = {
index: 0,
previousIndex:0,
routes: routeStack
}
const reducer = (state=defaultState,action) => {
switch (action.type) {
case 'Navigation/NAVIGATE':
var newIndex = findRouteIndexByName(routeStack,action.routeName)
if ( newIndex !== -1 ) {
var previousIndex = state.index
return { ...state, index: newIndex, previousIndex: previousIndex }
} else {
return state
}
break;
}
return state
}
Expand Down
4 changes: 2 additions & 2 deletions app/tabThree/views/TabThreeNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { StackNavigator, addNavigationHelpers } from 'react-navigation'
import { routeConfiguration, stackNavigatorConfiguration } from '../navigationConfiguration'
//Redux
import { connect } from 'react-redux'
const Navigator = StackNavigator(routeConfiguration,stackNavigatorConfiguration)
const NavigatorTabThree = StackNavigator(routeConfiguration,stackNavigatorConfiguration)
const mapStateToProps = (state) => {
return {
navigationState: state.tabThree
Expand All @@ -19,7 +19,7 @@ class TabThreeNavigation extends React.Component {
render(){
const { dispatch, navigationState} = this.props
return (
<Navigator
<NavigatorTabThree
navigation={addNavigationHelpers({
dispatch: dispatch,
state: navigationState
Expand Down
29 changes: 28 additions & 1 deletion app/tabThree/views/TabThreeScreenOne.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict'
import React from 'react'
import { View, Text } from 'react-native'
import { View, Text, TouchableOpacity, TouchableHighlight } from 'react-native'
export default class TabThreeScreenOne extends React.Component {
render(){
return(
Expand All @@ -10,6 +10,33 @@ export default class TabThreeScreenOne extends React.Component {
alignItems:'center',
justifyContent:'center'
}}>
<TouchableHighlight
onPress={ () => console.log('hi') }
style={{
padding:30,
backgroundColor:'deeppink'
}}>
<Text>
{'TouchableHighlight'}
</Text>
</TouchableHighlight>

<TouchableOpacity
onPress={
() => {
console.log('hi, new screen please')
// this.props.navigation.navigate('TabThreeScreenTwo')
}
}
style={{
padding:20,
backgroundColor:'red',
borderRadius:20,
marginBottom:50,
zIndex:99
}}>
<Text>{' Go to Screen Two '}</Text>
</TouchableOpacity>
<Text>{ 'Tab Three Screen One' }</Text>
</View>
)
Expand Down
4 changes: 2 additions & 2 deletions app/tabTwo/views/TabTwoNavigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { StackNavigator, addNavigationHelpers } from 'react-navigation'
import { routeConfiguration, stackNavigatorConfiguration } from '../navigationConfiguration'
//Redux
import { connect } from 'react-redux'
const Navigator = StackNavigator(routeConfiguration,stackNavigatorConfiguration)
const NavigatorTabTwo = StackNavigator(routeConfiguration,stackNavigatorConfiguration)
const mapStateToProps = (state) => {
return {
navigationState: state.tabTwo
Expand All @@ -19,7 +19,7 @@ class TabTwoNavigation extends React.Component {
render(){
const { dispatch, navigationState} = this.props
return (
<Navigator
<NavigatorTabTwo
navigation={
addNavigationHelpers({
dispatch: dispatch,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"react": "15.4.2",
"react-native": "0.41.0",
"react-native-vector-icons": "^4.0.0",
"react-navigation": "^1.0.0-beta.1",
"react-navigation": "https://github.com/react-community/react-navigation/tarball/master",
"react-redux": "^5.0.2",
"redux": "^3.6.0",
"redux-logger": "^2.8.1"
Expand Down

0 comments on commit 5373c6b

Please sign in to comment.