Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
ChauVV committed Sep 3, 2019
0 parents commit be562d2
Show file tree
Hide file tree
Showing 84 changed files with 9,539 additions and 0 deletions.
35 changes: 35 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"presets": ["module:metro-react-native-babel-preset"],

"plugins": [
["@babel/plugin-transform-flow-strip-types"],
["@babel/plugin-proposal-decorators", { "legacy": true }],
["@babel/plugin-proposal-class-properties", { "loose": true }],
[
"module-resolver",
{
"root": [
"./"
],
"extensions": [
".js",
".ios.js",
".android.js"
],
"alias": {
"utils": "./src/utils",
"mobxStore": "./src/mobxStore",
"assets": "./src/assets",
"screens": "./src/screens"
}
}
]
],
"env": {
"production": {
"plugins": [
"transform-remove-console"
]
}
}
}
6 changes: 6 additions & 0 deletions .buckconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

[android]
target = Google Inc.:Google APIs:23

[maven_repositories]
central = https://repo1.maven.org/maven2
1 change: 1 addition & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ENV=prod
45 changes: 45 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"parser": "babel-eslint",
"extends": [
"eslint:recommended",
"plugin:react/recommended",
"standard"
],
"env": {
"jest": true
},
"plugins": [
"flowtype-errors",
"react",
"react-native"
],
"parserOptions": {
"ecmaFeatures": {
"jsx": true,
"legacyDecorators": true
}
},
"rules": {
"react-native/no-unused-styles": 2,
"react-native/split-platform-components": 2,
"react-native/no-inline-styles": 0,
"flowtype-errors/show-errors": 2,
"react/prop-types": 0,
"no-console": 0,
"react/sort-comp": 2,
"react/no-string-refs": 0,
"no-undef": 0,
"indent": [
2,
2
],
"template-tag-spacing": ["error", "never"]
},
"globals": {
"fetch": true,
"enquire": true,
"FontFaceObserver": true,
"imagesloaded": true,
"Modernizr": true
}
}
99 changes: 99 additions & 0 deletions .flowconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
[ignore]
; We fork some components by platform
.*/*[.]android.js

; Ignore "BUCK" generated dirs
<PROJECT_ROOT>/\.buckd/

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

; Ignore duplicate module providers
; For RN Apps installed via npm, "Libraries" folder is inside
; "node_modules/react-native" but in the source repo it is in the root
node_modules/react-native/Libraries/react-native/React.js

; Ignore polyfills
node_modules/react-native/Libraries/polyfills/.*

; These should not be required directly
; require from fbjs/lib instead: require('fbjs/lib/warning')
node_modules/warning/.*

; Flow doesn't support platforms
.*/Libraries/Utilities/HMRLoadingView.js

[untyped]
.*/node_modules/@react-native-community/cli/.*/.*

[include]

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

[options]
emoji=true

esproposal.optional_chaining=enable
esproposal.nullish_coalescing=enable

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

module.system=haste
module.system.haste.use_name_reducers=true
# get basename
module.system.haste.name_reducers='^.*/\([a-zA-Z0-9$_.-]+\.js\(\.flow\)?\)$' -> '\1'
# strip .js or .js.flow suffix
module.system.haste.name_reducers='^\(.*\)\.js\(\.flow\)?$' -> '\1'
# strip .ios suffix
module.system.haste.name_reducers='^\(.*\)\.ios$' -> '\1'
module.system.haste.name_reducers='^\(.*\)\.android$' -> '\1'
module.system.haste.name_reducers='^\(.*\)\.native$' -> '\1'
module.system.haste.paths.blacklist=.*/__tests__/.*
module.system.haste.paths.blacklist=.*/__mocks__/.*
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/Libraries/.*
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/RNTester/.*
module.system.haste.paths.whitelist=<PROJECT_ROOT>/node_modules/react-native/IntegrationTests/.*
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/react-native/react-native-implementation.js
module.system.haste.paths.blacklist=<PROJECT_ROOT>/node_modules/react-native/Libraries/Animated/src/polyfills/.*

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_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError

[lints]
sketchy-null-number=warn
sketchy-null-mixed=warn
sketchy-number=warn
untyped-type-import=warn
nonstrict-import=warn
deprecated-type=warn
unsafe-getters-setters=warn
inexact-spread=warn
unnecessary-invariant=warn
signature-verification-failure=warn
deprecated-utility=error

[strict]
deprecated-type
nonstrict-import
sketchy-null
unclear-type
unsafe-getters-setters
untyped-import
untyped-type-import

[version]
^0.98.0
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.pbxproj -text
59 changes: 59 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# OSX
#
.DS_Store

# Xcode
#
build/
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
*.xccheckout
*.moved-aside
DerivedData
*.hmap
*.ipa
*.xcuserstate
project.xcworkspace

# Android/IntelliJ
#
build/
.idea
.gradle
local.properties
*.iml

# node.js
#
node_modules/
npm-debug.log
yarn-error.log

# BUCK
buck-out/
\.buckd/
*.keystore

# fastlane
#
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
# screenshots whenever they are needed.
# For more information about the recommended setup visit:
# https://docs.fastlane.tools/best-practices/source-control/

*/fastlane/report.xml
*/fastlane/Preview.html
*/fastlane/screenshots

# Bundle artifact
*.jsbundle

# CocoaPods
/ios/Pods/
1 change: 1 addition & 0 deletions .watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
98 changes: 98 additions & 0 deletions App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
import React from 'react'
import { observer } from 'mobx-react'
import {
StyleSheet, View
} from 'react-native'
import { enableLogging } from 'mobx-logger'
import { createSwitchNavigator, createStackNavigator, createAppContainer } from 'react-navigation'
import Home from 'screens/Home'
import Detail from 'screens/Detail'
import LoginScreen from 'screens/Login'

import UserStore from 'mobxStore/UserStore'
import NaviStore from 'mobxStore/NaviStore'

/** ------------------------------------------*
* Activities:
* 1. BackHandler
* 2. checkUpdate
* 3. configPushNotification
* 4. AppState (background, inactive, active)
* ------------------------------------------- */

/** ------------------------------------------*
* Group Code: Debug
* ------------------------------------------- */
console.disableYellowBox = true
const config = {
predicate: () => __DEV__,
action: true,
reaction: true,
transaction: true,
compute: true
}
enableLogging(config)

/** ------------------------------------------*
* Group Code: Navigation
* ------------------------------------------- */
const stack1 = createStackNavigator(
{
Home: Home,
Detail: Detail
}
)
const SwitchNavigator = (isLogin) => createSwitchNavigator(
{
LoggedOut: {
screen: LoginScreen
},
LoggedIn: {
screen: stack1
}
},
{
initialRouteName: isLogin ? 'LoggedIn' : 'LoggedOut'
}
)
const getRootNavigation = (isLogin) => createAppContainer(SwitchNavigator(isLogin))
// import PropTypes from 'prop-types'
@observer
class App extends React.PureComponent {
constructor (props) {
super(props)
this.state = ({
isLogin: false
})
}

async componentDidMount () {
const isLogin = await UserStore.getLogin()
this.setState({ isLogin })
}

render () {
const RootNavigator = getRootNavigation(this.state.isLogin)
return (
<View style={styles.container}>
<RootNavigator
onNavigationStateChange={(prev, next) => NaviStore.onNavigationStateChange(prev, next)}
// eslint-disable-next-line no-return-assign
ref={nav => NaviStore.navigator = nav}
/>
</View>
)
}
}
export default App

App.defaultProps = {
}
App.propTypes = {
}

const styles = StyleSheet.create({
container: {
flex: 1
}
})
17 changes: 17 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
ENV ?= uat
MODE ?= Debug
PROJECT_NAME = initMobX

setup-env:
cp ./src/env/$(ENV)/.env .env

start:
make setup-env
react-native start --reset-cache

run-ios:
ENVFILE=.env react-native run-ios --simulator="iPhone X" --scheme="${PROJECT_NAME}.$(ENV)"

run-android:
react-native run-android --variant="$(ENV)$(MODE)"

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# initMobX
14 changes: 14 additions & 0 deletions __tests__/App-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* @format
*/

import 'react-native';
import React from 'react';
import App from '../App';

// Note: test renderer must be required after react-native.
import renderer from 'react-test-renderer';

it('renders correctly', () => {
renderer.create(<App />);
});
Loading

0 comments on commit be562d2

Please sign in to comment.