Skip to content

Commit

Permalink
Merge pull request #1 from GantMan/add_basic_navigation
Browse files Browse the repository at this point in the history
basic navigation added
  • Loading branch information
GantMan authored Aug 27, 2017
2 parents a35cc9c + 79ecf01 commit 24f7384
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 16 deletions.
26 changes: 17 additions & 9 deletions App.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,23 @@
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import React from 'react'
import { StyleSheet, View } from 'react-native'
import { Provider } from 'react-redux'
import createStore from './Redux'
import AppNavigation from './Navigation/AppNavigation'
import ReduxNavigation from './Navigation/ReduxNavigation'

// create our store
const store = createStore()


export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<Text>Open up App.js to start working on your app!</Text>
<Text>Changes you make will automatically reload.</Text>
<Text>Shake your phone to open the developer menu.</Text>
</View>
);
<Provider store={store}>
<View style={styles.container}>
<ReduxNavigation />
</View>
</Provider>
)
}
}

Expand All @@ -20,4 +28,4 @@ const styles = StyleSheet.create({
alignItems: 'center',
justifyContent: 'center',
},
});
})
21 changes: 21 additions & 0 deletions Containers/LoginScreen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import React from 'react'
import { StyleSheet, Text, View } from 'react-native'

export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<Text>HIYA!!!!!</Text>
</View>
)
}
}

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
})
13 changes: 13 additions & 0 deletions Navigation/AppNavigation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { StackNavigator } from 'react-navigation'
import LoginScreen from '../Containers/LoginScreen'

// Manifest of possible screens
const PrimaryNav = StackNavigator({
LoginScreen: { screen: LoginScreen }
}, {
// Default config for all screens
headerMode: 'none',
initialRouteName: 'LoginScreen'
})

export default PrimaryNav
18 changes: 18 additions & 0 deletions Navigation/ReduxNavigation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react'
import * as ReactNavigation from 'react-navigation'
import { connect } from 'react-redux'
import AppNavigation from './AppNavigation'

// here is our redux-aware our smart component
function ReduxNavigation (props) {
const { dispatch, nav } = props
const navigation = ReactNavigation.addNavigationHelpers({
dispatch,
state: nav
})

return <AppNavigation navigation={navigation} />
}

const mapStateToProps = state => ({ nav: state.nav })
export default connect(mapStateToProps)(ReduxNavigation)
18 changes: 18 additions & 0 deletions Redux/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Wherever you build your reducers
import { combineReducers, createStore, applyMiddleware, compose } from 'redux'
import AppNavigation from '../Navigation/AppNavigation'

const navReducer = (state, action) => {
const newState = AppNavigation.router.getStateForAction(action, state)
return newState || state
}

export default () => {
/* ------------- Assemble The Reducers ------------- */
const rootReducer = combineReducers({
nav: navReducer
})

// return store
return createStore(rootReducer)
}
9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"version": "0.1.0",
"private": true,
"devDependencies": {
"react-native-scripts": "1.2.1",
"jest-expo": "~20.0.0",
"react-native-scripts": "1.2.1",
"react-test-renderer": "16.0.0-alpha.12"
},
"main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
Expand All @@ -21,6 +21,9 @@
"dependencies": {
"expo": "^20.0.0",
"react": "16.0.0-alpha.12",
"react-native": "^0.47.0"
"react-native": "^0.47.0",
"react-navigation": "^1.0.0-beta.11",
"react-redux": "^5.0.6",
"redux": "^3.7.2"
}
}
}
56 changes: 52 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1312,6 +1312,10 @@ ci-info@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-1.0.0.tgz#dc5285f2b4e251821683681c381c3388f46ec534"

clamp@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/clamp/-/clamp-1.0.1.tgz#66a0e64011816e37196828fdc8c8c147312c8634"

cli-cursor@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5"
Expand Down Expand Up @@ -2038,7 +2042,7 @@ [email protected]:
setimmediate "^1.0.5"
ua-parser-js "^0.7.9"

fbjs@^0.8.4, fbjs@^0.8.9:
fbjs@^0.8.12, fbjs@^0.8.4, fbjs@^0.8.9:
version "0.8.14"
resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.14.tgz#d1dbe2be254c35a91e09f31f9cd50a40b2a0ed1c"
dependencies:
Expand Down Expand Up @@ -2474,6 +2478,10 @@ [email protected]:
version "4.2.0"
resolved "https://registry.yarnpkg.com/hoek/-/hoek-4.2.0.tgz#72d9d0754f7fe25ca2d01ad8f8f9a9449a89526d"

hoist-non-react-statics@^1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-1.2.0.tgz#aa448cf0986d55cc40773b17174b7dd066cb7cfb"

hoist-non-react-statics@^2.2.1:
version "2.3.0"
resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-2.3.0.tgz#ede16318c2ff1f9fe3a025396ba06fd4c44608bb"
Expand Down Expand Up @@ -4074,6 +4082,12 @@ [email protected]:
version "0.1.7"
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-0.1.7.tgz#df604178005f522f15eb4490e7247a1bfaa67f8c"

path-to-regexp@^1.7.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-1.7.0.tgz#59fde0f435badacba103a84e9d3bc64e96b9937d"
dependencies:
isarray "0.0.1"

path-type@^1.0.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441"
Expand Down Expand Up @@ -4339,6 +4353,22 @@ [email protected]:
version "2.0.0-beta.3"
resolved "https://registry.yarnpkg.com/react-native-branch/-/react-native-branch-2.0.0-beta.3.tgz#2167af86bbc9f964bd45bd5f37684e5b54965e32"

[email protected]:
version "1.0.0"
resolved "https://registry.yarnpkg.com/react-native-dismiss-keyboard/-/react-native-dismiss-keyboard-1.0.0.tgz#32886242b3f2317e121f3aeb9b0a585e2b879b49"

react-native-drawer-layout-polyfill@^1.3.0:
version "1.3.2"
resolved "https://registry.yarnpkg.com/react-native-drawer-layout-polyfill/-/react-native-drawer-layout-polyfill-1.3.2.tgz#192c84d7a5a6b8a6d2be2c7daa5e4164518d0cc7"
dependencies:
react-native-drawer-layout "1.3.2"

[email protected]:
version "1.3.2"
resolved "https://registry.yarnpkg.com/react-native-drawer-layout/-/react-native-drawer-layout-1.3.2.tgz#b9740d7663a1dc4f88a61b9c6d93d2d948ea426e"
dependencies:
react-native-dismiss-keyboard "1.0.0"

react-native-gesture-handler@^1.0.0-alpha.14:
version "1.0.0-alpha.17"
resolved "https://registry.yarnpkg.com/react-native-gesture-handler/-/react-native-gesture-handler-1.0.0-alpha.17.tgz#1ae4412e1b208d175b34a14931d0635064a92e7b"
Expand Down Expand Up @@ -4379,6 +4409,12 @@ [email protected]:
color "^0.11.1"
lodash "^4.16.6"

react-native-tab-view@^0.0.65:
version "0.0.65"
resolved "https://registry.yarnpkg.com/react-native-tab-view/-/react-native-tab-view-0.0.65.tgz#b685ea3081ff7c96486cd997361026c407302c59"
dependencies:
prop-types "^15.5.8"

[email protected]:
version "4.1.1"
resolved "https://registry.yarnpkg.com/react-native-vector-icons/-/react-native-vector-icons-4.1.1.tgz#9ac75bde77d9243346668c51dca7756775428087"
Expand Down Expand Up @@ -4474,14 +4510,26 @@ react-native@^0.47.0:
xtend ">=4.0.0 <4.1.0-0"
yargs "^6.4.0"

react-navigation@^1.0.0-beta.11:
version "1.0.0-beta.11"
resolved "https://registry.yarnpkg.com/react-navigation/-/react-navigation-1.0.0-beta.11.tgz#4271edb23cdbcc6eb88602f7fde0a77f0ef7a160"
dependencies:
clamp "^1.0.1"
fbjs "^0.8.12"
hoist-non-react-statics "^1.2.0"
path-to-regexp "^1.7.0"
prop-types "^15.5.10"
react-native-drawer-layout-polyfill "^1.3.0"
react-native-tab-view "^0.0.65"

react-proxy@^1.1.7:
version "1.1.8"
resolved "https://registry.yarnpkg.com/react-proxy/-/react-proxy-1.1.8.tgz#9dbfd9d927528c3aa9f444e4558c37830ab8c26a"
dependencies:
lodash "^4.6.1"
react-deep-force-update "^1.0.0"

react-redux@^5.0.2:
react-redux@^5.0.2, react-redux@^5.0.6:
version "5.0.6"
resolved "https://registry.yarnpkg.com/react-redux/-/react-redux-5.0.6.tgz#23ed3a4f986359d68b5212eaaa681e60d6574946"
dependencies:
Expand Down Expand Up @@ -4573,7 +4621,7 @@ redux-logger@^2.7.4:
dependencies:
deep-diff "0.3.4"

redux@^3.6.0:
redux@^3.6.0, redux@^3.7.2:
version "3.7.2"
resolved "https://registry.yarnpkg.com/redux/-/redux-3.7.2.tgz#06b73123215901d25d065be342eb026bc1c8537b"
dependencies:
Expand Down Expand Up @@ -5580,7 +5628,7 @@ webidl-conversions@^4.0.0:
version "4.0.2"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-4.0.2.tgz#a855980b1f0b6b359ba1d5d9fb39ae941faa63ad"

"websql@github:expo/node-websql#18.0.0":
websql@expo/node-websql#18.0.0:
version "0.4.4"
resolved "https://codeload.github.com/expo/node-websql/tar.gz/e364fa65146a9e2157a19e5c719e7702c2b6b87a"
dependencies:
Expand Down

0 comments on commit 24f7384

Please sign in to comment.