Skip to content

Commit

Permalink
Initial working commit
Browse files Browse the repository at this point in the history
  • Loading branch information
amilajack committed Oct 17, 2016
1 parent 63a5a2b commit 7147391
Show file tree
Hide file tree
Showing 20 changed files with 6,156 additions and 37 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[*.md]
trim_trailing_whitespace = false
21 changes: 19 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,23 @@
{
"parser": "babel-eslint",
"extends": ["eslint:recommended", "plugin:react/recommended", "standard"],
"env": {
"jest": true
},
"plugins": [
"flowtype-errors",
"react"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true
}
},
"rules": {
"strict": 0
"flowtype-errors/show-errors": 2,
"react/prop-types": 0
},
"globals": {
"fetch": true
}
}
}
3 changes: 0 additions & 3 deletions .flowconfig
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,3 @@ suppress_type=$FixMe
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-7]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-7]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy

[version]
^0.27.0
10 changes: 8 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"parser": "babel-eslint"
},
"scripts": {
"format": "standard --fix",
"test": "./node_modules/standard/bin/cmd.js && jest",
"lint": "eslint . --fix --ignore-path .gitignore --format=node_modules/eslint-formatter-pretty",
"test": "./node_modules/standard/bin/cmd.js && jest",
"start": "react-native start",
"test:watch": "npm run test -- --watch",
"test-chrome": "node-debug --preload false --nodejs --harmony jest --runInBand",
Expand Down Expand Up @@ -61,6 +61,12 @@
"babel-jest": "14.0.0",
"babel-preset-react-native": "1.8.0",
"docker": "1.0.0",
"eslint": "^3.8.0",
"eslint-config-standard": "^6.2.0",
"eslint-plugin-flowtype-errors": "^1.4.1",
"eslint-plugin-promise": "^3.0.0",
"eslint-plugin-react": "^6.4.1",
"eslint-plugin-standard": "^2.0.1",
"istanbul": "0.4.3",
"jest": "14.1.0",
"jest-react-native": "14.1.3",
Expand Down
6 changes: 2 additions & 4 deletions src/components/Header.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* # Header.js
*
* # Header.js
*
* This component initially displays a image. But when clicked, things
* get interesting.
*
Expand Down Expand Up @@ -136,8 +136,6 @@ var Header = React.createClass({
let displayText
if (this.props.showState) {
displayText = JSON.stringify(this.props.currentState)

console.log(displayText)
}

return (
Expand Down
2 changes: 1 addition & 1 deletion src/components/__tests__/LoginForm-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jest.mock('tcomb-form-native', () => {
const React = require('React')
const t = require.requireActual('tcomb-form-native')
// Patch the base Component class to make rendering possible.
t.form.Component.prototype.render = function () {
t.form.Component.prototype.render = function render () {
return React.createElement(this.getTemplate().name, this.props)
}
return t
Expand Down
2 changes: 1 addition & 1 deletion src/containers/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function mapStateToProps (state) {
showState: state.global.showState
}
}
};
}

/**
* Bind all the actions from authActions, deviceActions and globalActions
Expand Down
2 changes: 1 addition & 1 deletion src/containers/Logout.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ function mapStateToProps (state) {
showState: state.global.showState
}
}
};
}

function mapDispatchToProps (dispatch) {
return {
Expand Down
4 changes: 2 additions & 2 deletions src/containers/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ function mapStateToProps (state) {
showState: state.global.showState
}
}
};
}

/*
* Bind all the actions
Expand Down Expand Up @@ -125,7 +125,7 @@ class Main extends Component {
</View>
)
}
};
}

/**
* Connect the properties
Expand Down
2 changes: 1 addition & 1 deletion src/containers/Subview.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ function mapStateToProps (state) {
return {
deviceVersion: state.device.version
}
};
}

/*
* Bind all the actions in deviceActions
Expand Down
2 changes: 1 addition & 1 deletion src/lib/configureStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ const createStoreWithMiddleware = applyMiddleware(
*/
export default function configureStore (initialState) {
return createStoreWithMiddleware(reducer, initialState)
};
}
9 changes: 6 additions & 3 deletions src/lib/fieldValidation.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default function fieldValidation (state, action) {
* ### username validation
* set the form field error
*/
case ('username'):
case ('username'): {
let validUsername = _.isUndefined(validate({username: value},
usernameConstraints))
if (validUsername) {
Expand All @@ -92,12 +92,13 @@ export default function fieldValidation (state, action) {
.setIn(['form', 'fields', 'usernameErrorMsg'],
I18n.t('FieldValidation.valid_user_name'))
}
}

/**
* ### email validation
* set the form field error
*/
case ('email'):
case ('email'): {
let validEmail = _.isUndefined(validate({from: value},
emailConstraints))
if (validEmail) {
Expand All @@ -107,12 +108,13 @@ export default function fieldValidation (state, action) {
.setIn(['form', 'fields', 'emailErrorMsg'],
I18n.t('FieldValidation.valid_email'))
}
}

/**
* ### password validation
* set the form field error
*/
case ('password'):
case ('password'): {
let validPassword = _.isUndefined(validate({password: value},
passwordConstraints))
if (validPassword) {
Expand All @@ -125,6 +127,7 @@ export default function fieldValidation (state, action) {
.setIn(['form', 'fields', 'passwordErrorMsg'],
I18n.t('FieldValidation.valid_password'))
}
}

/**
* ### passwordAgain validation
Expand Down
2 changes: 1 addition & 1 deletion src/reducers/auth/authInitialState.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const Form = Record({
passwordAgainHasError: false,
passwordAgainErrorMsg: '',
showPassword: false
}))
}))()
})

/**
Expand Down
8 changes: 5 additions & 3 deletions src/reducers/auth/authReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,12 @@ export default function authReducer (state = initialState, action) {
case SIGNUP_REQUEST:
case LOGOUT_REQUEST:
case LOGIN_REQUEST:
case RESET_PASSWORD_REQUEST:
let nextState = state.setIn(['form', 'isFetching'], true)
.setIn(['form', 'error'], null)
case RESET_PASSWORD_REQUEST: {
let nextState = state
.setIn(['form', 'isFetching'], true)
.setIn(['form', 'error'], null)
return nextState
}

/**
* ### Logout state
Expand Down
6 changes: 4 additions & 2 deletions src/reducers/device/deviceReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,19 @@ export default function deviceReducer (state = initialState, action) {
* ### set the platform in the state
*
*/
case SET_PLATFORM:
case SET_PLATFORM: {
const platform = action.payload
return state.set('platform', platform)
}

/**
* ### set the version in the state
*
*/
case SET_VERSION:
case SET_VERSION: {
const version = action.payload
return state.set('version', version)
}
}

return state
Expand Down
3 changes: 2 additions & 1 deletion src/reducers/global/globalReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export default function globalReducer (state = initialState, action) {
* *Note*: the global state removes the ```store```, otherwise,
* when trying to convert to JSON, it will be recursive and fail
*/
case GET_STATE:
case GET_STATE: {
let _state = state.store.getState()

if (action.payload) {
Expand All @@ -109,6 +109,7 @@ export default function globalReducer (state = initialState, action) {
} else {
return state.set('showState', action.payload)
}
}

/**
* ### Set the state
Expand Down
4 changes: 2 additions & 2 deletions src/reducers/profile/profileInitialState.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const Form = Record({
email: null,
objectId: null,
emailVerified: null
})),
}))(),
disabled: false,
error: null,
isValid: false,
Expand All @@ -39,7 +39,7 @@ const Form = Record({
emailHasError: false,
emailErrorMsg: '',
emailVerified: false
}))
}))()
})

var InitialState = Record({
Expand Down
11 changes: 7 additions & 4 deletions src/reducers/profile/profileReducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,17 @@ export default function profileReducer (state = initialState, action) {
* Set the state with the fields, clear the form error
* and perform field and form validation
*/
case ON_PROFILE_FORM_FIELD_CHANGE:
case ON_PROFILE_FORM_FIELD_CHANGE: {
const {field, value} = action.payload
let nextState = state.setIn(['form', 'fields', field], value)
let nextState = state
.setIn(['form', 'fields', field], value)
.setIn(['form', 'error'], null)

return formValidation(
fieldValidation(nextState, action)
, action)
fieldValidation(nextState, action),
action
)
}

/**
* ### set the state
Expand Down
6 changes: 3 additions & 3 deletions src/snowflake.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,13 @@ export default function native (platform) {
<Scene key='Logout'
title={I18n.t('Snowflake.logout')}
icon={TabIcon}
iconName={"sign-out"}
iconName={'sign-out'}
hideNavBar
component={Logout} />

<Scene key='Main'
title={I18n.t('Snowflake.main')}
iconName={"home"}
iconName={'home'}
icon={TabIcon}
hideNavBar
component={Main}
Expand All @@ -216,7 +216,7 @@ export default function native (platform) {
<Scene key='Profile'
title={I18n.t('Snowflake.profile')}
icon={TabIcon}
iconName={"gear"}
iconName={'gear'}
hideNavBar
component={Profile} />
</Scene>
Expand Down
Loading

0 comments on commit 7147391

Please sign in to comment.