Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"presets": ["babel-preset-expo"],
"env": {
"development": {
"plugins": ["transform-react-jsx-source"]
}
}
}
75 changes: 75 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
[ignore]
; We fork some components by platform
.*/*[.]android.js

; Ignore templates for 'react-native init'
<PROJECT_ROOT>/node_modules/react-native/local-cli/templates/.*

; Ignore RN jest
<PROJECT_ROOT>/node_modules/react-native/jest/.*

; Ignore RNTester
<PROJECT_ROOT>/node_modules/react-native/RNTester/.*

; Ignore the website subdir
<PROJECT_ROOT>/node_modules/react-native/website/.*

; Ignore the Dangerfile
<PROJECT_ROOT>/node_modules/react-native/danger/dangerfile.js

; Ignore Fbemitter
<PROJECT_ROOT>/node_modules/fbemitter/.*

; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/node_modules/react-native/\.buckd/

; Ignore unexpected extra "@providesModule"
.*/node_modules/.*/node_modules/fbjs/.*

; Ignore polyfills
<PROJECT_ROOT>/node_modules/react-native/Libraries/polyfills/.*

; Ignore various node_modules
<PROJECT_ROOT>/node_modules/react-native-gesture-handler/.*
<PROJECT_ROOT>/node_modules/expo/.*
<PROJECT_ROOT>/node_modules/react-navigation/.*
<PROJECT_ROOT>/node_modules/xdl/.*
<PROJECT_ROOT>/node_modules/reqwest/.*
<PROJECT_ROOT>/node_modules/metro-bundler/.*

[include]

[libs]
node_modules/react-native/Libraries/react-native/react-native-interface.js
node_modules/react-native/flow/
node_modules/expo/flow/

[options]
emoji=true

module.system=haste

module.file_ext=.js
module.file_ext=.jsx
module.file_ext=.json
module.file_ext=.ios.js

munge_underscores=true

module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub'

suppress_type=$FlowIssue
suppress_type=$FlowFixMe
suppress_type=$FlowFixMeProps
suppress_type=$FlowFixMeState
suppress_type=$FixMe

suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(5[0-6]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native_oss[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(5[0-6]\\|[1-4][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native_oss[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError

unsafe.enable_getters_and_setters=true

[version]
^0.56.0
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# See https://help.github.com/ignore-files/ for more about ignoring files.

# expo
.expo/

# dependencies
/node_modules

# misc
.env.local
.env.development.local
.env.test.local
.env.production.local

npm-debug.log*
yarn-debug.log*
yarn-error.log*
1 change: 1 addition & 0 deletions .watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
41 changes: 41 additions & 0 deletions App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { StackNavigator } from 'react-navigation';
import HomeScreen from './screens/HomeScreen'
import GameScreen from './screens/GameScreen'
import GameOverScreen from './screens/GameOverScreen'
import store from './store'

import { createStore } from 'redux'
import { Provider } from 'react-redux'

const AppNavigator = StackNavigator({
Home: {
screen: HomeScreen,
},
Game: {
screen: GameScreen
},
GameOver: {
screen: GameOverScreen
},
})

export default class App extends React.Component {
render() {
return (
<Provider store={store}>
<AppNavigator />
</Provider>
);
}
}

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
9 changes: 9 additions & 0 deletions App.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';
import App from './App';

import renderer from 'react-test-renderer';

it('renders without crashing', () => {
const rendered = renderer.create(<App />).toJSON();
expect(rendered).toBeTruthy();
});
23 changes: 23 additions & 0 deletions actions/gameAction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

export const fetchRandomWords = (randomWords) => {
return (dispatch) => {
dispatch({
type: 'FETCH_RANDOM_WORDS',
payload: {
randomWords: randomWords,
}
})
}
}


export const addInputWord = (word) => {
return (dispatch) => {
dispatch({
type: 'ADD_INPUT_WORDS',
payload: {
word: word,
}
})
}
}
5 changes: 5 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"expo": {
"sdkVersion": "23.0.0"
}
}
35 changes: 35 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "liveproject",
"version": "0.1.0",
"private": true,
"devDependencies": {
"jest-expo": "23.0.0",
"react-native-scripts": "1.8.1",
"react-test-renderer": "16.0.0"
},
"main": "./node_modules/react-native-scripts/build/bin/crna-entry.js",
"scripts": {
"start": "react-native-scripts start",
"eject": "react-native-scripts eject",
"android": "react-native-scripts android",
"ios": "react-native-scripts ios",
"test": "node node_modules/jest/bin/jest.js --watch"
},
"jest": {
"preset": "jest-expo"
},
"dependencies": {
"axios": "^0.17.1",
"expo": "^23.0.4",
"firebase": "^4.8.1",
"lodash": "^4.17.4",
"react": "16.0.0",
"react-native": "0.50.3",
"react-navigation": "^1.0.0-beta.22",
"react-redux": "^5.0.6",
"redux": "^3.7.2",
"redux-logger": "^3.0.6",
"redux-thunk": "^2.2.0",
"thunk": "^0.0.1"
}
}
29 changes: 29 additions & 0 deletions reducers/gameReducer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import _ from 'lodash'

const initialState = {
randomWords: [],
usedWords: [],
turnLeft: 5,
gameOver: false
}

export const gameReducer = (state = initialState, action) => {
switch (action.type) {
case 'FETCH_RANDOM_WORDS':
const loadRandomWords = state.randomWords.concat(action.payload.randomWords)
return { ...state, randomWords: loadRandomWords }

case 'ADD_INPUT_WORDS':
let newUsed = []
newUsed.push(action.payload.word)

let newTurn = state.turnLeft--
console.log(`-----------TURN LEFT ${action.payload.word}`)

const newUsedWords = state.usedWords.concat(newUsed)
return { ...state, usedWords: newUsedWords, turnLeft: state.turnLeft - 1 }

default:
return state
}
}
8 changes: 8 additions & 0 deletions reducers/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { combineReducers } from 'redux'
import { gameReducer } from './gameReducer'

const rootReducer = combineReducers({
gameReducer
})

export default rootReducer
44 changes: 44 additions & 0 deletions screens/GameOverScreen.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React, { Component } from 'react'
import { StyleSheet, View, Text, TouchableOpacity } from 'react-native'

class GameOverScreen extends Component {
constructor(props) {
super(props)

this.state = {

}
}

render() {
const { navigate, state } = this.props.navigation
const gameStatus = state.params.win;
console.log(`~~~gameStatus: `, gameStatus)
return (
<View style={styles.container}>
<Text>Guess CSS Props</Text>

<Text style={styles.title}>You {gameStatus}</Text>

<TouchableOpacity>
<Text>Play Again</Text>
</TouchableOpacity>
</View>
)
}
}

const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},

title: {
fontSize: 20,
},
});

export default GameOverScreen
Loading