├── .babelrc ├── .eslintrc ├── .gitignore ├── .npmignore ├── Examples ├── BasicExample │ ├── .babelrc │ ├── .buckconfig │ ├── .flowconfig │ ├── .gitattributes │ ├── .gitignore │ ├── .watchmanconfig │ ├── README.md │ ├── __tests__ │ │ ├── index.android.js │ │ └── index.ios.js │ ├── android │ │ ├── app │ │ │ ├── BUCK │ │ │ ├── build.gradle │ │ │ ├── proguard-rules.pro │ │ │ └── src │ │ │ │ └── main │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── basicexample │ │ │ │ │ ├── MainActivity.java │ │ │ │ │ └── MainApplication.java │ │ │ │ └── res │ │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ └── values │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ ├── build.gradle │ │ ├── gradle.properties │ │ ├── gradle │ │ │ └── wrapper │ │ │ │ ├── gradle-wrapper.jar │ │ │ │ └── gradle-wrapper.properties │ │ ├── gradlew │ │ ├── gradlew.bat │ │ ├── keystores │ │ │ ├── BUCK │ │ │ └── debug.keystore.properties │ │ └── settings.gradle │ ├── assets │ │ └── renavigate.gif │ ├── index.android.js │ ├── index.ios.js │ ├── ios │ │ ├── BasicExample.xcodeproj │ │ │ ├── project.pbxproj │ │ │ └── xcshareddata │ │ │ │ └── xcschemes │ │ │ │ └── BasicExample.xcscheme │ │ ├── BasicExample │ │ │ ├── AppDelegate.h │ │ │ ├── AppDelegate.m │ │ │ ├── Base.lproj │ │ │ │ └── LaunchScreen.xib │ │ │ ├── Images.xcassets │ │ │ │ └── AppIcon.appiconset │ │ │ │ │ └── Contents.json │ │ │ ├── Info.plist │ │ │ └── main.m │ │ └── BasicExampleTests │ │ │ ├── BasicExampleTests.m │ │ │ └── Info.plist │ ├── main.js │ ├── package.json │ ├── reset-renavigate.sh │ ├── src │ │ ├── App.js │ │ ├── PostDetail.js │ │ ├── PostsList.js │ │ ├── redux │ │ │ └── store.js │ │ └── routes.js │ └── yarn.lock ├── CustomTabBar │ ├── .babelrc │ ├── .buckconfig │ ├── .flowconfig │ ├── .gitattributes │ ├── .gitignore │ ├── .watchmanconfig │ ├── __tests__ │ │ ├── index.android.js │ │ └── index.ios.js │ ├── android │ │ ├── app │ │ │ ├── BUCK │ │ │ ├── build.gradle │ │ │ ├── proguard-rules.pro │ │ │ └── src │ │ │ │ └── main │ │ │ │ ├── AndroidManifest.xml │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── customtabbar │ │ │ │ │ ├── MainActivity.java │ │ │ │ │ └── MainApplication.java │ │ │ │ └── res │ │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ │ └── values │ │ │ │ ├── strings.xml │ │ │ │ └── styles.xml │ │ ├── build.gradle │ │ ├── gradle.properties │ │ ├── gradle │ │ │ └── wrapper │ │ │ │ ├── gradle-wrapper.jar │ │ │ │ └── gradle-wrapper.properties │ │ ├── gradlew │ │ ├── gradlew.bat │ │ ├── keystores │ │ │ ├── BUCK │ │ │ └── debug.keystore.properties │ │ └── settings.gradle │ ├── index.android.js │ ├── index.ios.js │ ├── ios │ │ ├── CustomTabBar.xcodeproj │ │ │ ├── project.pbxproj │ │ │ └── xcshareddata │ │ │ │ └── xcschemes │ │ │ │ └── CustomTabBar.xcscheme │ │ ├── CustomTabBar │ │ │ ├── AppDelegate.h │ │ │ ├── AppDelegate.m │ │ │ ├── Base.lproj │ │ │ │ └── LaunchScreen.xib │ │ │ ├── Images.xcassets │ │ │ │ └── AppIcon.appiconset │ │ │ │ │ └── Contents.json │ │ │ ├── Info.plist │ │ │ └── main.m │ │ └── CustomTabBarTests │ │ │ ├── CustomTabBarTests.m │ │ │ └── Info.plist │ ├── main.js │ ├── package.json │ ├── reset-renavigate.sh │ ├── src │ │ ├── App.js │ │ ├── PostDetailContainer.js │ │ ├── PostListContainer.js │ │ ├── TabBar.js │ │ ├── TabBar.styles.js │ │ ├── TabBarItem.js │ │ ├── TabBarItem.styles.js │ │ ├── assets │ │ │ ├── tabbar_customer_support_off.png │ │ │ ├── tabbar_customer_support_off@2x.png │ │ │ ├── tabbar_customer_support_off@3x.png │ │ │ ├── tabbar_customer_support_on.png │ │ │ ├── tabbar_customer_support_on@2x.png │ │ │ ├── tabbar_customer_support_on@3x.png │ │ │ ├── tabbar_dashboard_off.png │ │ │ ├── tabbar_dashboard_off@2x.png │ │ │ ├── tabbar_dashboard_off@3x.png │ │ │ ├── tabbar_dashboard_on.png │ │ │ ├── tabbar_dashboard_on@2x.png │ │ │ ├── tabbar_dashboard_on@3x.png │ │ │ ├── tabbar_energy_advisor_off.png │ │ │ ├── tabbar_energy_advisor_off@2x.png │ │ │ ├── tabbar_energy_advisor_off@3x.png │ │ │ ├── tabbar_energy_advisor_on.png │ │ │ ├── tabbar_energy_advisor_on@2x.png │ │ │ └── tabbar_energy_advisor_on@3x.png │ │ ├── redux │ │ │ └── store.js │ │ └── routes.js │ └── yarn.lock ├── README.md └── TabsExample │ ├── .babelrc │ ├── .buckconfig │ ├── .flowconfig │ ├── .gitattributes │ ├── .gitignore │ ├── .watchmanconfig │ ├── __tests__ │ ├── index.android.js │ └── index.ios.js │ ├── android │ ├── app │ │ ├── BUCK │ │ ├── build.gradle │ │ ├── proguard-rules.pro │ │ └── src │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── java │ │ │ └── com │ │ │ │ └── tabsexample │ │ │ │ ├── MainActivity.java │ │ │ │ └── MainApplication.java │ │ │ └── res │ │ │ ├── mipmap-hdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ └── ic_launcher.png │ │ │ └── values │ │ │ ├── strings.xml │ │ │ └── styles.xml │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ ├── keystores │ │ ├── BUCK │ │ └── debug.keystore.properties │ └── settings.gradle │ ├── index.android.js │ ├── index.ios.js │ ├── ios │ ├── TabsExample.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── TabsExample.xcscheme │ ├── TabsExample │ │ ├── AppDelegate.h │ │ ├── AppDelegate.m │ │ ├── Base.lproj │ │ │ └── LaunchScreen.xib │ │ ├── Images.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ ├── Info.plist │ │ └── main.m │ └── TabsExampleTests │ │ ├── Info.plist │ │ └── TabsExampleTests.m │ ├── main.js │ ├── package.json │ ├── reset-renavigate.sh │ ├── src │ ├── App.js │ ├── EmptyView.js │ ├── PostDetailContainer.js │ ├── PostListContainer.js │ ├── redux │ │ └── store.js │ └── routes.js │ └── yarn.lock ├── LICENSE.md ├── README.md ├── circle.yml ├── docs └── API.md ├── index.js ├── package.json ├── src ├── RootScene.js ├── RootSceneContainer.js ├── TabContainer.js ├── TabsContainer.js ├── actions.js ├── navigationBarRouteMapper.js └── reducer.js ├── test ├── .eslintrc ├── actions.spec.js └── reducer.spec.js └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["react-native"] 3 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | npm-debug.log 3 | .DS_Store 4 | yarn-error.log 5 | lib 6 | coverage 7 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | Examples 2 | /src 3 | index.js 4 | yarn.lock 5 | -------------------------------------------------------------------------------- /Examples/BasicExample/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["react-native"] 3 | } -------------------------------------------------------------------------------- /Examples/BasicExample/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /Examples/BasicExample/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | ; We fork some components by platform 3 | .*/*[.]android.js 4 | 5 | ; Ignore "BUCK" generated dirs 6 | /\.buckd/ 7 | 8 | ; Ignore unexpected extra "@providesModule" 9 | .*/node_modules/.*/node_modules/fbjs/.* 10 | 11 | ; Ignore duplicate module providers 12 | ; For RN Apps installed via npm, "Libraries" folder is inside 13 | ; "node_modules/react-native" but in the source repo it is in the root 14 | .*/Libraries/react-native/React.js 15 | .*/Libraries/react-native/ReactNative.js 16 | 17 | [include] 18 | 19 | [libs] 20 | node_modules/react-native/Libraries/react-native/react-native-interface.js 21 | node_modules/react-native/flow 22 | flow/ 23 | 24 | [options] 25 | module.system=haste 26 | 27 | experimental.strict_type_args=true 28 | 29 | munge_underscores=true 30 | 31 | 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' 32 | 33 | suppress_type=$FlowIssue 34 | suppress_type=$FlowFixMe 35 | suppress_type=$FixMe 36 | 37 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-6]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) 38 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-6]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ 39 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy 40 | 41 | unsafe.enable_getters_and_setters=true 42 | 43 | [version] 44 | ^0.36.0 45 | -------------------------------------------------------------------------------- /Examples/BasicExample/.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | -------------------------------------------------------------------------------- /Examples/BasicExample/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | project.xcworkspace 24 | 25 | # Android/IntelliJ 26 | # 27 | build/ 28 | .idea 29 | .gradle 30 | local.properties 31 | *.iml 32 | 33 | # node.js 34 | # 35 | node_modules/ 36 | npm-debug.log 37 | 38 | # BUCK 39 | buck-out/ 40 | \.buckd/ 41 | android/app/libs 42 | *.keystore 43 | 44 | # fastlane 45 | # 46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 47 | # screenshots whenever they are needed. 48 | # For more information about the recommended setup visit: 49 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 50 | 51 | fastlane/report.xml 52 | fastlane/Preview.html 53 | fastlane/screenshots 54 | -------------------------------------------------------------------------------- /Examples/BasicExample/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /Examples/BasicExample/README.md: -------------------------------------------------------------------------------- 1 | ![assets/renavigate.gif](assets/renavigate.gif) 2 | 3 | **App.js** 4 | ```js 5 | import React from 'react'; 6 | import { Provider } from 'react-redux'; 7 | import { RootSceneContainer } from 'react-native-renavigate'; 8 | 9 | import store from './store'; 10 | import routeDefs from './routes'; 11 | 12 | const posts = [ 13 | { 14 | id: 1, 15 | text: 'Lorem ipsum dolor sit amet', 16 | title: 'Lorem Ipsum' 17 | }, 18 | { 19 | id: 2, 20 | text: 'Sed ut perspiciatis unde omnis iste natus error', 21 | title: 'de Finibus Bonorum et Malorum 1.10.32' 22 | }, 23 | { 24 | id: 3, 25 | text: 'At vero eos et accusamus et iusto odio', 26 | title: 'de Finibus Bonorum et Malorum 1.10.33' 27 | } 28 | ]; 29 | 30 | export default function index() { 31 | return ( 32 | 33 | 37 | 38 | ); 39 | } 40 | ``` 41 | 42 | **Store.js** 43 | ```js 44 | import { createStore, combineReducers } from 'redux'; 45 | import { reducer as navigation } from 'react-native-renavigate'; 46 | 47 | const reducers = combineReducers({ 48 | navigation 49 | }); 50 | 51 | export default createStore(reducers); 52 | 53 | ``` 54 | 55 | **Routes.js** 56 | ```js 57 | import PostDetailContainer from './PostDetailContainer'; 58 | import PostListContainer from './PostListContainer'; 59 | 60 | export default { 61 | DETAIL: (params) => ({ 62 | component: PostDetailContainer, 63 | params 64 | }), 65 | LIST: (params) => ({ 66 | component: PostListContainer, 67 | params 68 | }) 69 | }; 70 | 71 | ``` 72 | 73 | **PostListContainer** 74 | ```js 75 | import React, { Component } from 'react'; 76 | import { ScrollView, TouchableOpacity, Text } from 'react-native'; 77 | import { connect } from 'react-redux'; 78 | import { actionCreators } from 'react-native-renavigate'; 79 | 80 | class PostListContainer extends Component { 81 | 82 | renderPostDetail = (post) => { 83 | this.props.dispatch(actionCreators.push.DETAIL(post)); 84 | } 85 | 86 | render() { 87 | return ( 88 | 89 | { 90 | this.props.posts.map((post) => { 91 | return ( 92 | this.renderPostDetail(post)}> 93 | { post.title } 94 | 95 | ); 96 | }) 97 | } 98 | 99 | ); 100 | } 101 | } 102 | 103 | export default connect()(PostListContainer); 104 | ``` 105 | 106 | **PostDetailContainer.js** 107 | ```js 108 | import React, { Component } from 'react'; 109 | import { Text, TouchableOpacity, View } from 'react-native'; 110 | import { connect } from 'react-redux'; 111 | import { actionCreators } from 'react-native-renavigate'; 112 | 113 | class PostDetailContainer extends Component { 114 | 115 | backToList = () => { 116 | this.props.dispatch(actionCreators.pop()); 117 | } 118 | 119 | render() { 120 | return ( 121 | 122 | 123 | Go back to list 124 | 125 | 126 | { this.props.text } 127 | 128 | 129 | ); 130 | } 131 | } 132 | 133 | export default connect()(PostDetailContainer); 134 | ``` 135 | -------------------------------------------------------------------------------- /Examples/BasicExample/__tests__/index.android.js: -------------------------------------------------------------------------------- 1 | import 'react-native'; 2 | import React from 'react'; 3 | import Index from '../index.android.js'; 4 | 5 | // Note: test renderer must be required after react-native. 6 | import renderer from 'react-test-renderer'; 7 | 8 | it('renders correctly', () => { 9 | const tree = renderer.create( 10 | 11 | ); 12 | }); 13 | -------------------------------------------------------------------------------- /Examples/BasicExample/__tests__/index.ios.js: -------------------------------------------------------------------------------- 1 | import 'react-native'; 2 | import React from 'react'; 3 | import Index from '../index.ios.js'; 4 | 5 | // Note: test renderer must be required after react-native. 6 | import renderer from 'react-test-renderer'; 7 | 8 | it('renders correctly', () => { 9 | const tree = renderer.create( 10 | 11 | ); 12 | }); 13 | -------------------------------------------------------------------------------- /Examples/BasicExample/android/app/BUCK: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | # To learn about Buck see [Docs](https://buckbuild.com/). 4 | # To run your application with Buck: 5 | # - install Buck 6 | # - `npm start` - to start the packager 7 | # - `cd android` 8 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 9 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 10 | # - `buck install -r android/app` - compile, install and run application 11 | # 12 | 13 | lib_deps = [] 14 | for jarfile in glob(['libs/*.jar']): 15 | name = 'jars__' + re.sub(r'^.*/([^/]+)\.jar$', r'\1', jarfile) 16 | lib_deps.append(':' + name) 17 | prebuilt_jar( 18 | name = name, 19 | binary_jar = jarfile, 20 | ) 21 | 22 | for aarfile in glob(['libs/*.aar']): 23 | name = 'aars__' + re.sub(r'^.*/([^/]+)\.aar$', r'\1', aarfile) 24 | lib_deps.append(':' + name) 25 | android_prebuilt_aar( 26 | name = name, 27 | aar = aarfile, 28 | ) 29 | 30 | android_library( 31 | name = 'all-libs', 32 | exported_deps = lib_deps 33 | ) 34 | 35 | android_library( 36 | name = 'app-code', 37 | srcs = glob([ 38 | 'src/main/java/**/*.java', 39 | ]), 40 | deps = [ 41 | ':all-libs', 42 | ':build_config', 43 | ':res', 44 | ], 45 | ) 46 | 47 | android_build_config( 48 | name = 'build_config', 49 | package = 'com.basicexample', 50 | ) 51 | 52 | android_resource( 53 | name = 'res', 54 | res = 'src/main/res', 55 | package = 'com.basicexample', 56 | ) 57 | 58 | android_binary( 59 | name = 'app', 60 | package_type = 'debug', 61 | manifest = 'src/main/AndroidManifest.xml', 62 | keystore = '//android/keystores:debug', 63 | deps = [ 64 | ':app-code', 65 | ], 66 | ) 67 | -------------------------------------------------------------------------------- /Examples/BasicExample/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | 3 | import com.android.build.OutputFile 4 | 5 | /** 6 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets 7 | * and bundleReleaseJsAndAssets). 8 | * These basically call `react-native bundle` with the correct arguments during the Android build 9 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the 10 | * bundle directly from the development server. Below you can see all the possible configurations 11 | * and their defaults. If you decide to add a configuration block, make sure to add it before the 12 | * `apply from: "../../node_modules/react-native/react.gradle"` line. 13 | * 14 | * project.ext.react = [ 15 | * // the name of the generated asset file containing your JS bundle 16 | * bundleAssetName: "index.android.bundle", 17 | * 18 | * // the entry file for bundle generation 19 | * entryFile: "index.android.js", 20 | * 21 | * // whether to bundle JS and assets in debug mode 22 | * bundleInDebug: false, 23 | * 24 | * // whether to bundle JS and assets in release mode 25 | * bundleInRelease: true, 26 | * 27 | * // whether to bundle JS and assets in another build variant (if configured). 28 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants 29 | * // The configuration property can be in the following formats 30 | * // 'bundleIn${productFlavor}${buildType}' 31 | * // 'bundleIn${buildType}' 32 | * // bundleInFreeDebug: true, 33 | * // bundleInPaidRelease: true, 34 | * // bundleInBeta: true, 35 | * 36 | * // the root of your project, i.e. where "package.json" lives 37 | * root: "../../", 38 | * 39 | * // where to put the JS bundle asset in debug mode 40 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", 41 | * 42 | * // where to put the JS bundle asset in release mode 43 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release", 44 | * 45 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 46 | * // require('./image.png')), in debug mode 47 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", 48 | * 49 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 50 | * // require('./image.png')), in release mode 51 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", 52 | * 53 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means 54 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to 55 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle 56 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ 57 | * // for example, you might want to remove it from here. 58 | * inputExcludes: ["android/**", "ios/**"], 59 | * 60 | * // override which node gets called and with what additional arguments 61 | * nodeExecutableAndArgs: ["node"] 62 | * 63 | * // supply additional arguments to the packager 64 | * extraPackagerArgs: [] 65 | * ] 66 | */ 67 | 68 | apply from: "../../node_modules/react-native/react.gradle" 69 | 70 | /** 71 | * Set this to true to create two separate APKs instead of one: 72 | * - An APK that only works on ARM devices 73 | * - An APK that only works on x86 devices 74 | * The advantage is the size of the APK is reduced by about 4MB. 75 | * Upload all the APKs to the Play Store and people will download 76 | * the correct one based on the CPU architecture of their device. 77 | */ 78 | def enableSeparateBuildPerCPUArchitecture = false 79 | 80 | /** 81 | * Run Proguard to shrink the Java bytecode in release builds. 82 | */ 83 | def enableProguardInReleaseBuilds = false 84 | 85 | android { 86 | compileSdkVersion 23 87 | buildToolsVersion "23.0.1" 88 | 89 | defaultConfig { 90 | applicationId "com.basicexample" 91 | minSdkVersion 16 92 | targetSdkVersion 22 93 | versionCode 1 94 | versionName "1.0" 95 | ndk { 96 | abiFilters "armeabi-v7a", "x86" 97 | } 98 | } 99 | splits { 100 | abi { 101 | reset() 102 | enable enableSeparateBuildPerCPUArchitecture 103 | universalApk false // If true, also generate a universal APK 104 | include "armeabi-v7a", "x86" 105 | } 106 | } 107 | buildTypes { 108 | release { 109 | minifyEnabled enableProguardInReleaseBuilds 110 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 111 | } 112 | } 113 | // applicationVariants are e.g. debug, release 114 | applicationVariants.all { variant -> 115 | variant.outputs.each { output -> 116 | // For each separate APK per architecture, set a unique version code as described here: 117 | // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits 118 | def versionCodes = ["armeabi-v7a":1, "x86":2] 119 | def abi = output.getFilter(OutputFile.ABI) 120 | if (abi != null) { // null for the universal-debug, universal-release variants 121 | output.versionCodeOverride = 122 | versionCodes.get(abi) * 1048576 + defaultConfig.versionCode 123 | } 124 | } 125 | } 126 | } 127 | 128 | dependencies { 129 | compile fileTree(dir: "libs", include: ["*.jar"]) 130 | compile "com.android.support:appcompat-v7:23.0.1" 131 | compile "com.facebook.react:react-native:+" // From node_modules 132 | } 133 | 134 | // Run this once to be able to run the application with BUCK 135 | // puts all compile dependencies into folder libs for BUCK to use 136 | task copyDownloadableDepsToLibs(type: Copy) { 137 | from configurations.compile 138 | into 'libs' 139 | } 140 | -------------------------------------------------------------------------------- /Examples/BasicExample/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Disabling obfuscation is useful if you collect stack traces from production crashes 20 | # (unless you are using a system that supports de-obfuscate the stack traces). 21 | -dontobfuscate 22 | 23 | # React Native 24 | 25 | # Keep our interfaces so they can be used by other ProGuard rules. 26 | # See http://sourceforge.net/p/proguard/bugs/466/ 27 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip 28 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters 29 | -keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip 30 | 31 | # Do not strip any method/class that is annotated with @DoNotStrip 32 | -keep @com.facebook.proguard.annotations.DoNotStrip class * 33 | -keep @com.facebook.common.internal.DoNotStrip class * 34 | -keepclassmembers class * { 35 | @com.facebook.proguard.annotations.DoNotStrip *; 36 | @com.facebook.common.internal.DoNotStrip *; 37 | } 38 | 39 | -keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * { 40 | void set*(***); 41 | *** get*(); 42 | } 43 | 44 | -keep class * extends com.facebook.react.bridge.JavaScriptModule { *; } 45 | -keep class * extends com.facebook.react.bridge.NativeModule { *; } 46 | -keepclassmembers,includedescriptorclasses class * { native ; } 47 | -keepclassmembers class * { @com.facebook.react.uimanager.UIProp ; } 48 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp ; } 49 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup ; } 50 | 51 | -dontwarn com.facebook.react.** 52 | 53 | # okhttp 54 | 55 | -keepattributes Signature 56 | -keepattributes *Annotation* 57 | -keep class okhttp3.** { *; } 58 | -keep interface okhttp3.** { *; } 59 | -dontwarn okhttp3.** 60 | 61 | # okio 62 | 63 | -keep class sun.misc.Unsafe { *; } 64 | -dontwarn java.nio.file.* 65 | -dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement 66 | -dontwarn okio.** 67 | -------------------------------------------------------------------------------- /Examples/BasicExample/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /Examples/BasicExample/android/app/src/main/java/com/basicexample/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.basicexample; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. 9 | * This is used to schedule rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "BasicExample"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Examples/BasicExample/android/app/src/main/java/com/basicexample/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.basicexample; 2 | 3 | import android.app.Application; 4 | import android.util.Log; 5 | 6 | import com.facebook.react.ReactApplication; 7 | import com.facebook.react.ReactInstanceManager; 8 | import com.facebook.react.ReactNativeHost; 9 | import com.facebook.react.ReactPackage; 10 | import com.facebook.react.shell.MainReactPackage; 11 | import com.facebook.soloader.SoLoader; 12 | 13 | import java.util.Arrays; 14 | import java.util.List; 15 | 16 | public class MainApplication extends Application implements ReactApplication { 17 | 18 | private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { 19 | @Override 20 | protected boolean getUseDeveloperSupport() { 21 | return BuildConfig.DEBUG; 22 | } 23 | 24 | @Override 25 | protected List getPackages() { 26 | return Arrays.asList( 27 | new MainReactPackage() 28 | ); 29 | } 30 | }; 31 | 32 | @Override 33 | public ReactNativeHost getReactNativeHost() { 34 | return mReactNativeHost; 35 | } 36 | 37 | @Override 38 | public void onCreate() { 39 | super.onCreate(); 40 | SoLoader.init(this, /* native exopackage */ false); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Examples/BasicExample/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/BasicExample/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /Examples/BasicExample/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/BasicExample/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /Examples/BasicExample/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/BasicExample/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Examples/BasicExample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/BasicExample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Examples/BasicExample/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | BasicExample 3 | 4 | -------------------------------------------------------------------------------- /Examples/BasicExample/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Examples/BasicExample/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:1.3.1' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | mavenLocal() 18 | jcenter() 19 | maven { 20 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 21 | url "$rootDir/../node_modules/react-native/android" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Examples/BasicExample/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | android.useDeprecatedNdk=true 21 | -------------------------------------------------------------------------------- /Examples/BasicExample/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/BasicExample/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /Examples/BasicExample/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip 6 | -------------------------------------------------------------------------------- /Examples/BasicExample/android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /Examples/BasicExample/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /Examples/BasicExample/android/keystores/BUCK: -------------------------------------------------------------------------------- 1 | keystore( 2 | name = 'debug', 3 | store = 'debug.keystore', 4 | properties = 'debug.keystore.properties', 5 | visibility = [ 6 | 'PUBLIC', 7 | ], 8 | ) 9 | -------------------------------------------------------------------------------- /Examples/BasicExample/android/keystores/debug.keystore.properties: -------------------------------------------------------------------------------- 1 | key.store=debug.keystore 2 | key.alias=androiddebugkey 3 | key.store.password=android 4 | key.alias.password=android 5 | -------------------------------------------------------------------------------- /Examples/BasicExample/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'BasicExample' 2 | 3 | include ':app' 4 | -------------------------------------------------------------------------------- /Examples/BasicExample/assets/renavigate.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/BasicExample/assets/renavigate.gif -------------------------------------------------------------------------------- /Examples/BasicExample/index.android.js: -------------------------------------------------------------------------------- 1 | import { AppRegistry } from 'react-native'; 2 | 3 | import Main from './main'; 4 | 5 | AppRegistry.registerComponent('BasicExample', () => Main); 6 | -------------------------------------------------------------------------------- /Examples/BasicExample/index.ios.js: -------------------------------------------------------------------------------- 1 | import { AppRegistry } from 'react-native'; 2 | 3 | import Main from './main'; 4 | 5 | AppRegistry.registerComponent('BasicExample', () => Main); 6 | -------------------------------------------------------------------------------- /Examples/BasicExample/ios/BasicExample.xcodeproj/xcshareddata/xcschemes/BasicExample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 43 | 49 | 50 | 51 | 52 | 53 | 58 | 59 | 61 | 67 | 68 | 69 | 70 | 71 | 77 | 78 | 79 | 80 | 81 | 82 | 92 | 94 | 100 | 101 | 102 | 103 | 104 | 105 | 111 | 113 | 119 | 120 | 121 | 122 | 124 | 125 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /Examples/BasicExample/ios/BasicExample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | @interface AppDelegate : UIResponder 13 | 14 | @property (nonatomic, strong) UIWindow *window; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Examples/BasicExample/ios/BasicExample/AppDelegate.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "AppDelegate.h" 11 | 12 | #import 13 | #import 14 | 15 | @implementation AppDelegate 16 | 17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 18 | { 19 | NSURL *jsCodeLocation; 20 | 21 | jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil]; 22 | 23 | RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation 24 | moduleName:@"BasicExample" 25 | initialProperties:nil 26 | launchOptions:launchOptions]; 27 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; 28 | 29 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 30 | UIViewController *rootViewController = [UIViewController new]; 31 | rootViewController.view = rootView; 32 | self.window.rootViewController = rootViewController; 33 | [self.window makeKeyAndVisible]; 34 | return YES; 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /Examples/BasicExample/ios/BasicExample/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Examples/BasicExample/ios/BasicExample/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /Examples/BasicExample/ios/BasicExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UIViewControllerBasedStatusBarAppearance 38 | 39 | NSLocationWhenInUseUsageDescription 40 | 41 | NSAppTransportSecurity 42 | 43 | 44 | NSExceptionDomains 45 | 46 | localhost 47 | 48 | NSExceptionAllowsInsecureHTTPLoads 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /Examples/BasicExample/ios/BasicExample/main.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | #import "AppDelegate.h" 13 | 14 | int main(int argc, char * argv[]) { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Examples/BasicExample/ios/BasicExampleTests/BasicExampleTests.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | #import 12 | 13 | #import 14 | #import 15 | 16 | #define TIMEOUT_SECONDS 600 17 | #define TEXT_TO_LOOK_FOR @"Welcome to React Native!" 18 | 19 | @interface BasicExampleTests : XCTestCase 20 | 21 | @end 22 | 23 | @implementation BasicExampleTests 24 | 25 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test 26 | { 27 | if (test(view)) { 28 | return YES; 29 | } 30 | for (UIView *subview in [view subviews]) { 31 | if ([self findSubviewInView:subview matching:test]) { 32 | return YES; 33 | } 34 | } 35 | return NO; 36 | } 37 | 38 | - (void)testRendersWelcomeScreen 39 | { 40 | UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController]; 41 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; 42 | BOOL foundElement = NO; 43 | 44 | __block NSString *redboxError = nil; 45 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { 46 | if (level >= RCTLogLevelError) { 47 | redboxError = message; 48 | } 49 | }); 50 | 51 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { 52 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 53 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 54 | 55 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { 56 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { 57 | return YES; 58 | } 59 | return NO; 60 | }]; 61 | } 62 | 63 | RCTSetLogFunction(RCTDefaultLogFunction); 64 | 65 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); 66 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); 67 | } 68 | 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /Examples/BasicExample/ios/BasicExampleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Examples/BasicExample/main.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Provider } from 'react-redux'; 3 | 4 | import store from './src/redux/store'; 5 | import App from './src/App'; 6 | 7 | export default function main() { 8 | return ( 9 | 10 | 11 | 12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /Examples/BasicExample/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "BasicExample", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "start": "node node_modules/react-native/local-cli/cli.js start", 7 | "test": "jest" 8 | }, 9 | "dependencies": { 10 | "react": "~15.4.0-rc.4", 11 | "react-native": "0.40.0", 12 | "react-native-renavigate": "file:../../", 13 | "react-redux": "^5.0.2", 14 | "redux": "^3.6.0" 15 | }, 16 | "devDependencies": { 17 | "babel-eslint": "^7.1.1", 18 | "babel-jest": "18.0.0", 19 | "babel-preset-react-native": "1.9.1", 20 | "eslint": "^3.13.1", 21 | "eslint-plugin-react": "^6.9.0", 22 | "jest": "18.1.0", 23 | "react-test-renderer": "~15.4.0-rc.4" 24 | }, 25 | "jest": { 26 | "preset": "react-native" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Examples/BasicExample/reset-renavigate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rm -rf node_modules/react-native-renavigate/ 3 | npm i react-native-renavigate 4 | npm start -- --reset-cache 5 | -------------------------------------------------------------------------------- /Examples/BasicExample/src/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { RootSceneContainer } from 'react-native-renavigate'; 3 | 4 | import routeDefs from './routes'; 5 | 6 | export default function index() { 7 | return ( 8 | 12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /Examples/BasicExample/src/PostDetail.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { Text, TouchableOpacity, View, StyleSheet } from 'react-native'; 3 | import { connect } from 'react-redux'; 4 | import { actionCreators } from 'react-native-renavigate'; 5 | 6 | const styles = StyleSheet.create({ 7 | container: { 8 | marginTop: 60, 9 | backgroundColor: 'white' 10 | }, 11 | goBackButton: { 12 | padding: 30, 13 | fontWeight: 'bold' 14 | }, 15 | postContent: { 16 | margin: 30 17 | } 18 | }); 19 | 20 | 21 | class PostDetail extends Component { 22 | 23 | backToList = () => { 24 | this.props.dispatch(actionCreators.pop()); 25 | } 26 | 27 | render() { 28 | return ( 29 | 30 | 31 | Go back to list 32 | 33 | 34 | { this.props.post.text } 35 | 36 | 37 | ); 38 | } 39 | } 40 | 41 | PostDetail.propTypes = { 42 | post: React.PropTypes.shape({ 43 | id: React.PropTypes.number.isRequired, 44 | text: React.PropTypes.string.isRequired, 45 | title: React.PropTypes.string.isRequired 46 | }).isRequired 47 | }; 48 | 49 | export default connect()(PostDetail); 50 | -------------------------------------------------------------------------------- /Examples/BasicExample/src/PostsList.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { ScrollView, TouchableOpacity, Text, StyleSheet } from 'react-native'; 3 | import { connect } from 'react-redux'; 4 | import { actionCreators } from 'react-native-renavigate'; 5 | 6 | /* eslint-disable max-len */ 7 | const posts = [ 8 | { 9 | id: 1, 10 | text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', 11 | title: 'Lorem Ipsum' 12 | }, 13 | { 14 | id: 2, 15 | text: 'Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?', 16 | title: 'de Finibus Bonorum et Malorum 1.10.32' 17 | }, 18 | { 19 | id: 3, 20 | text: 'At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.', 21 | title: 'de Finibus Bonorum et Malorum 1.10.33' 22 | } 23 | ]; 24 | /* eslint-enable max-len */ 25 | 26 | const styles = StyleSheet.create({ 27 | container: { 28 | marginTop: 60, 29 | backgroundColor: 'white' 30 | }, 31 | postTitle: { 32 | borderColor: 'blue', 33 | borderRadius: 3, 34 | borderWidth: 1, 35 | padding: 8, 36 | margin: 20 37 | } 38 | }); 39 | 40 | 41 | class PostsList extends Component { 42 | 43 | renderPostDetail = (post) => { 44 | this.props.dispatch(actionCreators.push.DETAIL(post)); 45 | } 46 | 47 | render() { 48 | return ( 49 | 50 | { 51 | posts.map((post) => { 52 | return ( 53 | this.renderPostDetail(post)} 56 | style={styles.postTitle} 57 | > 58 | { post.title } 59 | 60 | ); 61 | }) 62 | } 63 | 64 | ); 65 | } 66 | } 67 | 68 | export default connect()(PostsList); 69 | -------------------------------------------------------------------------------- /Examples/BasicExample/src/redux/store.js: -------------------------------------------------------------------------------- 1 | import { createStore, combineReducers } from 'redux'; 2 | import { reducer as navigation } from 'react-native-renavigate'; 3 | 4 | const reducers = combineReducers({ 5 | navigation 6 | }); 7 | 8 | export default createStore(reducers); 9 | -------------------------------------------------------------------------------- /Examples/BasicExample/src/routes.js: -------------------------------------------------------------------------------- 1 | import PostsList from './PostsList'; 2 | import PostDetail from './PostDetail'; 3 | 4 | export default { 5 | DETAIL: (post) => ({ 6 | component: PostDetail, 7 | params: { post } 8 | }), 9 | LIST: () => ({ 10 | component: PostsList 11 | }) 12 | }; 13 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["react-native"] 3 | } -------------------------------------------------------------------------------- /Examples/CustomTabBar/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | ; We fork some components by platform 3 | .*/*[.]android.js 4 | 5 | ; Ignore "BUCK" generated dirs 6 | /\.buckd/ 7 | 8 | ; Ignore unexpected extra "@providesModule" 9 | .*/node_modules/.*/node_modules/fbjs/.* 10 | 11 | ; Ignore duplicate module providers 12 | ; For RN Apps installed via npm, "Libraries" folder is inside 13 | ; "node_modules/react-native" but in the source repo it is in the root 14 | .*/Libraries/react-native/React.js 15 | .*/Libraries/react-native/ReactNative.js 16 | 17 | [include] 18 | 19 | [libs] 20 | node_modules/react-native/Libraries/react-native/react-native-interface.js 21 | node_modules/react-native/flow 22 | flow/ 23 | 24 | [options] 25 | module.system=haste 26 | 27 | experimental.strict_type_args=true 28 | 29 | munge_underscores=true 30 | 31 | 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' 32 | 33 | suppress_type=$FlowIssue 34 | suppress_type=$FlowFixMe 35 | suppress_type=$FixMe 36 | 37 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-6]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) 38 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-6]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ 39 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy 40 | 41 | unsafe.enable_getters_and_setters=true 42 | 43 | [version] 44 | ^0.36.0 45 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | project.xcworkspace 24 | 25 | # Android/IntelliJ 26 | # 27 | build/ 28 | .idea 29 | .gradle 30 | local.properties 31 | *.iml 32 | 33 | # node.js 34 | # 35 | node_modules/ 36 | npm-debug.log 37 | 38 | # BUCK 39 | buck-out/ 40 | \.buckd/ 41 | android/app/libs 42 | *.keystore 43 | 44 | # fastlane 45 | # 46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 47 | # screenshots whenever they are needed. 48 | # For more information about the recommended setup visit: 49 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 50 | 51 | fastlane/report.xml 52 | fastlane/Preview.html 53 | fastlane/screenshots 54 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /Examples/CustomTabBar/__tests__/index.android.js: -------------------------------------------------------------------------------- 1 | import 'react-native'; 2 | import React from 'react'; 3 | import Index from '../index.android.js'; 4 | 5 | // Note: test renderer must be required after react-native. 6 | import renderer from 'react-test-renderer'; 7 | 8 | it('renders correctly', () => { 9 | const tree = renderer.create( 10 | 11 | ); 12 | }); 13 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/__tests__/index.ios.js: -------------------------------------------------------------------------------- 1 | import 'react-native'; 2 | import React from 'react'; 3 | import Index from '../index.ios.js'; 4 | 5 | // Note: test renderer must be required after react-native. 6 | import renderer from 'react-test-renderer'; 7 | 8 | it('renders correctly', () => { 9 | const tree = renderer.create( 10 | 11 | ); 12 | }); 13 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/android/app/BUCK: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | # To learn about Buck see [Docs](https://buckbuild.com/). 4 | # To run your application with Buck: 5 | # - install Buck 6 | # - `npm start` - to start the packager 7 | # - `cd android` 8 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 9 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 10 | # - `buck install -r android/app` - compile, install and run application 11 | # 12 | 13 | lib_deps = [] 14 | for jarfile in glob(['libs/*.jar']): 15 | name = 'jars__' + re.sub(r'^.*/([^/]+)\.jar$', r'\1', jarfile) 16 | lib_deps.append(':' + name) 17 | prebuilt_jar( 18 | name = name, 19 | binary_jar = jarfile, 20 | ) 21 | 22 | for aarfile in glob(['libs/*.aar']): 23 | name = 'aars__' + re.sub(r'^.*/([^/]+)\.aar$', r'\1', aarfile) 24 | lib_deps.append(':' + name) 25 | android_prebuilt_aar( 26 | name = name, 27 | aar = aarfile, 28 | ) 29 | 30 | android_library( 31 | name = 'all-libs', 32 | exported_deps = lib_deps 33 | ) 34 | 35 | android_library( 36 | name = 'app-code', 37 | srcs = glob([ 38 | 'src/main/java/**/*.java', 39 | ]), 40 | deps = [ 41 | ':all-libs', 42 | ':build_config', 43 | ':res', 44 | ], 45 | ) 46 | 47 | android_build_config( 48 | name = 'build_config', 49 | package = 'com.customtabbar', 50 | ) 51 | 52 | android_resource( 53 | name = 'res', 54 | res = 'src/main/res', 55 | package = 'com.customtabbar', 56 | ) 57 | 58 | android_binary( 59 | name = 'app', 60 | package_type = 'debug', 61 | manifest = 'src/main/AndroidManifest.xml', 62 | keystore = '//android/keystores:debug', 63 | deps = [ 64 | ':app-code', 65 | ], 66 | ) 67 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | 3 | import com.android.build.OutputFile 4 | 5 | /** 6 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets 7 | * and bundleReleaseJsAndAssets). 8 | * These basically call `react-native bundle` with the correct arguments during the Android build 9 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the 10 | * bundle directly from the development server. Below you can see all the possible configurations 11 | * and their defaults. If you decide to add a configuration block, make sure to add it before the 12 | * `apply from: "../../node_modules/react-native/react.gradle"` line. 13 | * 14 | * project.ext.react = [ 15 | * // the name of the generated asset file containing your JS bundle 16 | * bundleAssetName: "index.android.bundle", 17 | * 18 | * // the entry file for bundle generation 19 | * entryFile: "index.android.js", 20 | * 21 | * // whether to bundle JS and assets in debug mode 22 | * bundleInDebug: false, 23 | * 24 | * // whether to bundle JS and assets in release mode 25 | * bundleInRelease: true, 26 | * 27 | * // whether to bundle JS and assets in another build variant (if configured). 28 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants 29 | * // The configuration property can be in the following formats 30 | * // 'bundleIn${productFlavor}${buildType}' 31 | * // 'bundleIn${buildType}' 32 | * // bundleInFreeDebug: true, 33 | * // bundleInPaidRelease: true, 34 | * // bundleInBeta: true, 35 | * 36 | * // the root of your project, i.e. where "package.json" lives 37 | * root: "../../", 38 | * 39 | * // where to put the JS bundle asset in debug mode 40 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", 41 | * 42 | * // where to put the JS bundle asset in release mode 43 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release", 44 | * 45 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 46 | * // require('./image.png')), in debug mode 47 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", 48 | * 49 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 50 | * // require('./image.png')), in release mode 51 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", 52 | * 53 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means 54 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to 55 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle 56 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ 57 | * // for example, you might want to remove it from here. 58 | * inputExcludes: ["android/**", "ios/**"], 59 | * 60 | * // override which node gets called and with what additional arguments 61 | * nodeExecutableAndArgs: ["node"] 62 | * 63 | * // supply additional arguments to the packager 64 | * extraPackagerArgs: [] 65 | * ] 66 | */ 67 | 68 | apply from: "../../node_modules/react-native/react.gradle" 69 | 70 | /** 71 | * Set this to true to create two separate APKs instead of one: 72 | * - An APK that only works on ARM devices 73 | * - An APK that only works on x86 devices 74 | * The advantage is the size of the APK is reduced by about 4MB. 75 | * Upload all the APKs to the Play Store and people will download 76 | * the correct one based on the CPU architecture of their device. 77 | */ 78 | def enableSeparateBuildPerCPUArchitecture = false 79 | 80 | /** 81 | * Run Proguard to shrink the Java bytecode in release builds. 82 | */ 83 | def enableProguardInReleaseBuilds = false 84 | 85 | android { 86 | compileSdkVersion 23 87 | buildToolsVersion "23.0.1" 88 | 89 | defaultConfig { 90 | applicationId "com.customtabbar" 91 | minSdkVersion 16 92 | targetSdkVersion 22 93 | versionCode 1 94 | versionName "1.0" 95 | ndk { 96 | abiFilters "armeabi-v7a", "x86" 97 | } 98 | } 99 | splits { 100 | abi { 101 | reset() 102 | enable enableSeparateBuildPerCPUArchitecture 103 | universalApk false // If true, also generate a universal APK 104 | include "armeabi-v7a", "x86" 105 | } 106 | } 107 | buildTypes { 108 | release { 109 | minifyEnabled enableProguardInReleaseBuilds 110 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 111 | } 112 | } 113 | // applicationVariants are e.g. debug, release 114 | applicationVariants.all { variant -> 115 | variant.outputs.each { output -> 116 | // For each separate APK per architecture, set a unique version code as described here: 117 | // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits 118 | def versionCodes = ["armeabi-v7a":1, "x86":2] 119 | def abi = output.getFilter(OutputFile.ABI) 120 | if (abi != null) { // null for the universal-debug, universal-release variants 121 | output.versionCodeOverride = 122 | versionCodes.get(abi) * 1048576 + defaultConfig.versionCode 123 | } 124 | } 125 | } 126 | } 127 | 128 | dependencies { 129 | compile fileTree(dir: "libs", include: ["*.jar"]) 130 | compile "com.android.support:appcompat-v7:23.0.1" 131 | compile "com.facebook.react:react-native:+" // From node_modules 132 | } 133 | 134 | // Run this once to be able to run the application with BUCK 135 | // puts all compile dependencies into folder libs for BUCK to use 136 | task copyDownloadableDepsToLibs(type: Copy) { 137 | from configurations.compile 138 | into 'libs' 139 | } 140 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Disabling obfuscation is useful if you collect stack traces from production crashes 20 | # (unless you are using a system that supports de-obfuscate the stack traces). 21 | -dontobfuscate 22 | 23 | # React Native 24 | 25 | # Keep our interfaces so they can be used by other ProGuard rules. 26 | # See http://sourceforge.net/p/proguard/bugs/466/ 27 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip 28 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters 29 | -keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip 30 | 31 | # Do not strip any method/class that is annotated with @DoNotStrip 32 | -keep @com.facebook.proguard.annotations.DoNotStrip class * 33 | -keep @com.facebook.common.internal.DoNotStrip class * 34 | -keepclassmembers class * { 35 | @com.facebook.proguard.annotations.DoNotStrip *; 36 | @com.facebook.common.internal.DoNotStrip *; 37 | } 38 | 39 | -keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * { 40 | void set*(***); 41 | *** get*(); 42 | } 43 | 44 | -keep class * extends com.facebook.react.bridge.JavaScriptModule { *; } 45 | -keep class * extends com.facebook.react.bridge.NativeModule { *; } 46 | -keepclassmembers,includedescriptorclasses class * { native ; } 47 | -keepclassmembers class * { @com.facebook.react.uimanager.UIProp ; } 48 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp ; } 49 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup ; } 50 | 51 | -dontwarn com.facebook.react.** 52 | 53 | # okhttp 54 | 55 | -keepattributes Signature 56 | -keepattributes *Annotation* 57 | -keep class okhttp3.** { *; } 58 | -keep interface okhttp3.** { *; } 59 | -dontwarn okhttp3.** 60 | 61 | # okio 62 | 63 | -keep class sun.misc.Unsafe { *; } 64 | -dontwarn java.nio.file.* 65 | -dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement 66 | -dontwarn okio.** 67 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/android/app/src/main/java/com/customtabbar/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.customtabbar; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. 9 | * This is used to schedule rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "CustomTabBar"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/android/app/src/main/java/com/customtabbar/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.customtabbar; 2 | 3 | import android.app.Application; 4 | import android.util.Log; 5 | 6 | import com.facebook.react.ReactApplication; 7 | import com.facebook.react.ReactInstanceManager; 8 | import com.facebook.react.ReactNativeHost; 9 | import com.facebook.react.ReactPackage; 10 | import com.facebook.react.shell.MainReactPackage; 11 | import com.facebook.soloader.SoLoader; 12 | 13 | import java.util.Arrays; 14 | import java.util.List; 15 | 16 | public class MainApplication extends Application implements ReactApplication { 17 | 18 | private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { 19 | @Override 20 | protected boolean getUseDeveloperSupport() { 21 | return BuildConfig.DEBUG; 22 | } 23 | 24 | @Override 25 | protected List getPackages() { 26 | return Arrays.asList( 27 | new MainReactPackage() 28 | ); 29 | } 30 | }; 31 | 32 | @Override 33 | public ReactNativeHost getReactNativeHost() { 34 | return mReactNativeHost; 35 | } 36 | 37 | @Override 38 | public void onCreate() { 39 | super.onCreate(); 40 | SoLoader.init(this, /* native exopackage */ false); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/CustomTabBar/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /Examples/CustomTabBar/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/CustomTabBar/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /Examples/CustomTabBar/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/CustomTabBar/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Examples/CustomTabBar/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/CustomTabBar/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Examples/CustomTabBar/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | CustomTabBar 3 | 4 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:1.3.1' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | mavenLocal() 18 | jcenter() 19 | maven { 20 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 21 | url "$rootDir/../node_modules/react-native/android" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | android.useDeprecatedNdk=true 21 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/CustomTabBar/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /Examples/CustomTabBar/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip 6 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/android/keystores/BUCK: -------------------------------------------------------------------------------- 1 | keystore( 2 | name = 'debug', 3 | store = 'debug.keystore', 4 | properties = 'debug.keystore.properties', 5 | visibility = [ 6 | 'PUBLIC', 7 | ], 8 | ) 9 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/android/keystores/debug.keystore.properties: -------------------------------------------------------------------------------- 1 | key.store=debug.keystore 2 | key.alias=androiddebugkey 3 | key.store.password=android 4 | key.alias.password=android 5 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'CustomTabBar' 2 | 3 | include ':app' 4 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/index.android.js: -------------------------------------------------------------------------------- 1 | import { AppRegistry } from 'react-native'; 2 | 3 | import Main from './main'; 4 | 5 | AppRegistry.registerComponent('CustomTabBar', () => Main); 6 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/index.ios.js: -------------------------------------------------------------------------------- 1 | import { AppRegistry } from 'react-native'; 2 | 3 | import Main from './main'; 4 | 5 | AppRegistry.registerComponent('CustomTabBar', () => Main); 6 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/ios/CustomTabBar.xcodeproj/xcshareddata/xcschemes/CustomTabBar.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 43 | 49 | 50 | 51 | 52 | 53 | 58 | 59 | 61 | 67 | 68 | 69 | 70 | 71 | 77 | 78 | 79 | 80 | 81 | 82 | 92 | 94 | 100 | 101 | 102 | 103 | 104 | 105 | 111 | 113 | 119 | 120 | 121 | 122 | 124 | 125 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/ios/CustomTabBar/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | @interface AppDelegate : UIResponder 13 | 14 | @property (nonatomic, strong) UIWindow *window; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/ios/CustomTabBar/AppDelegate.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "AppDelegate.h" 11 | 12 | #import 13 | #import 14 | 15 | @implementation AppDelegate 16 | 17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 18 | { 19 | NSURL *jsCodeLocation; 20 | 21 | jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil]; 22 | 23 | RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation 24 | moduleName:@"CustomTabBar" 25 | initialProperties:nil 26 | launchOptions:launchOptions]; 27 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; 28 | 29 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 30 | UIViewController *rootViewController = [UIViewController new]; 31 | rootViewController.view = rootView; 32 | self.window.rootViewController = rootViewController; 33 | [self.window makeKeyAndVisible]; 34 | return YES; 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/ios/CustomTabBar/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/ios/CustomTabBar/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /Examples/CustomTabBar/ios/CustomTabBar/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UIViewControllerBasedStatusBarAppearance 38 | 39 | NSLocationWhenInUseUsageDescription 40 | 41 | NSAppTransportSecurity 42 | 43 | 44 | NSExceptionDomains 45 | 46 | localhost 47 | 48 | NSExceptionAllowsInsecureHTTPLoads 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/ios/CustomTabBar/main.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | #import "AppDelegate.h" 13 | 14 | int main(int argc, char * argv[]) { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/ios/CustomTabBarTests/CustomTabBarTests.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | #import 12 | 13 | #import 14 | #import 15 | 16 | #define TIMEOUT_SECONDS 600 17 | #define TEXT_TO_LOOK_FOR @"Welcome to React Native!" 18 | 19 | @interface CustomTabBarTests : XCTestCase 20 | 21 | @end 22 | 23 | @implementation CustomTabBarTests 24 | 25 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test 26 | { 27 | if (test(view)) { 28 | return YES; 29 | } 30 | for (UIView *subview in [view subviews]) { 31 | if ([self findSubviewInView:subview matching:test]) { 32 | return YES; 33 | } 34 | } 35 | return NO; 36 | } 37 | 38 | - (void)testRendersWelcomeScreen 39 | { 40 | UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController]; 41 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; 42 | BOOL foundElement = NO; 43 | 44 | __block NSString *redboxError = nil; 45 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { 46 | if (level >= RCTLogLevelError) { 47 | redboxError = message; 48 | } 49 | }); 50 | 51 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { 52 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 53 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 54 | 55 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { 56 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { 57 | return YES; 58 | } 59 | return NO; 60 | }]; 61 | } 62 | 63 | RCTSetLogFunction(RCTDefaultLogFunction); 64 | 65 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); 66 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); 67 | } 68 | 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/ios/CustomTabBarTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/main.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Provider } from 'react-redux'; 3 | 4 | import store from './src/redux/store'; 5 | import App from './src/App'; 6 | 7 | export default function main() { 8 | return ( 9 | 10 | 11 | 12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "CustomTabBar", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "start": "node node_modules/react-native/local-cli/cli.js start", 7 | "test": "jest" 8 | }, 9 | "dependencies": { 10 | "react": "~15.4.0-rc.4", 11 | "react-native": "0.40.0", 12 | "react-native-renavigate": "file:../../", 13 | "react-redux": "^5.0.2", 14 | "redux": "^3.6.0" 15 | }, 16 | "devDependencies": { 17 | "babel-eslint": "^7.1.1", 18 | "babel-jest": "18.0.0", 19 | "babel-preset-react-native": "1.9.1", 20 | "eslint": "^3.13.1", 21 | "eslint-plugin-react": "^6.9.0", 22 | "jest": "18.1.0", 23 | "react-test-renderer": "~15.4.0-rc.4" 24 | }, 25 | "jest": { 26 | "preset": "react-native" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/reset-renavigate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rm -rf node_modules/react-native-renavigate/ 3 | npm i react-native-renavigate 4 | npm start -- --reset-cache 5 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/src/App.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { TabsContainer } from 'react-native-renavigate'; 3 | 4 | import routeDefs from './routes'; 5 | import TabBar from './TabBar'; 6 | 7 | import Tab1OnImg from './assets/tabbar_dashboard_on.png'; 8 | import Tab1OffImg from './assets/tabbar_dashboard_off.png'; 9 | import Tab2OnImg from './assets/tabbar_customer_support_on.png'; 10 | import Tab2OffImage from './assets/tabbar_customer_support_off.png'; 11 | import Tab3OnImg from './assets/tabbar_energy_advisor_on.png'; 12 | import Tab3OffImg from './assets/tabbar_energy_advisor_off.png'; 13 | 14 | /* eslint-disable max-len */ 15 | const posts = [ 16 | { 17 | id: 1, 18 | text: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.', 19 | title: 'Lorem Ipsum' 20 | }, 21 | { 22 | id: 2, 23 | text: 'Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?', 24 | title: 'de Finibus Bonorum et Malorum 1.10.32' 25 | }, 26 | { 27 | id: 3, 28 | text: 'At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.', 29 | title: 'de Finibus Bonorum et Malorum 1.10.33' 30 | } 31 | ]; 32 | /* eslint-enable max-len */ 33 | 34 | const TABS = [ 35 | { 36 | label: 'Tab 1', 37 | initialRoute: routeDefs.LIST({ posts }), 38 | imageOff: Tab1OffImg, 39 | imageOn: Tab1OnImg 40 | }, 41 | { 42 | label: 'Tab 2', 43 | initialRoute: routeDefs.LIST({ posts }), 44 | imageOff: Tab2OffImage, 45 | imageOn: Tab2OnImg 46 | }, 47 | { 48 | label: 'Tab 3', 49 | initialRoute: routeDefs.LIST({ posts }), 50 | imageOff: Tab3OffImg, 51 | imageOn: Tab3OnImg 52 | } 53 | ]; 54 | 55 | export default function app() { 56 | const scrollableTabsProps = { 57 | tabBarPosition: 'bottom', 58 | locked: true, 59 | contentProps: { keyboardShouldPersistTaps: 'always' }, 60 | prerenderingSiblingsNumber: 1, 61 | scrollWithoutAnimation: true, 62 | renderTabBar: (props) => { 63 | return ( 64 | ({ imageOff: tab.imageOff, imageOn: tab.imageOn }))} 66 | {...props} 67 | /> 68 | ); 69 | } 70 | }; 71 | 72 | return ( 73 | 79 | ); 80 | } 81 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/src/PostDetailContainer.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { Text, TouchableOpacity, View } from 'react-native'; 3 | import { connect } from 'react-redux'; 4 | import { actionCreators } from 'react-native-renavigate'; 5 | 6 | class PostDetailContainer extends Component { 7 | 8 | componentDidMount() { 9 | console.log('mount detail'); 10 | } 11 | 12 | componentWillUnmount() { 13 | console.log('unmount detail'); 14 | } 15 | 16 | backToList = () => { 17 | this.props.dispatch(actionCreators.pop()); 18 | } 19 | 20 | render() { 21 | return ( 22 | 23 | 27 | Go back to list 28 | 29 | 30 | { this.props.text } 31 | 32 | 33 | ); 34 | } 35 | } 36 | 37 | PostDetailContainer.propTypes = { 38 | text: React.PropTypes.string.isRequired 39 | }; 40 | 41 | export default connect()(PostDetailContainer); 42 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/src/PostListContainer.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { ScrollView, TouchableOpacity, Text } from 'react-native'; 3 | import { connect } from 'react-redux'; 4 | import { actionCreators } from 'react-native-renavigate'; 5 | 6 | class PostListContainer extends Component { 7 | 8 | renderPostDetail = (post) => { 9 | this.props.dispatch(actionCreators.push.DETAIL(post)); 10 | } 11 | 12 | render() { 13 | return ( 14 | 15 | { 16 | this.props.posts.map((post) => { 17 | return ( 18 | this.renderPostDetail(post)} 22 | > 23 | { post.title } 24 | 25 | ); 26 | }) 27 | } 28 | 29 | ); 30 | } 31 | } 32 | 33 | PostListContainer.propTypes = { 34 | posts: React.PropTypes.array.isRequired 35 | }; 36 | 37 | export default connect()(PostListContainer); 38 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/src/TabBar.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { View } from 'react-native'; 3 | 4 | import TabBarItem from './TabBarItem'; 5 | import styles from './TabBar.styles'; 6 | 7 | export default function TabBar ({ style, tabIcons, activeTab, goToPage, tabs, hidden }) { 8 | return hidden ? null : ( 9 | 10 | { 11 | tabs.map((tab, i) => { 12 | const tabImage = activeTab === i 13 | ? tabIcons[i].imageOn 14 | : tabIcons[i].imageOff; 15 | 16 | return ( 17 | goToPage(i)} 22 | image={tabImage} 23 | /> 24 | ); 25 | }) 26 | } 27 | 28 | ); 29 | } 30 | 31 | TabBar.propTypes = { 32 | activeTab: React.PropTypes.number.isRequired, 33 | goToPage: React.PropTypes.func.isRequired, 34 | hidden: React.PropTypes.bool, 35 | tabIcons: React.PropTypes.arrayOf( 36 | React.PropTypes.shape({ 37 | imageOff: React.PropTypes.any.isRequired, 38 | imageOn: React.PropTypes.any.isRequired 39 | }).isRequired 40 | ).isRequired, 41 | tabs: React.PropTypes.arrayOf(React.PropTypes.string).isRequired 42 | }; 43 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/src/TabBar.styles.js: -------------------------------------------------------------------------------- 1 | import { StyleSheet } from 'react-native'; 2 | 3 | export default StyleSheet.create({ 4 | tabs: { 5 | backgroundColor: 'white', 6 | flexDirection: 'row', 7 | height: 50, 8 | justifyContent: 'space-between', 9 | paddingHorizontal: 10, 10 | elevation: 10, 11 | shadowColor: 'black', 12 | shadowOpacity: 0.5, 13 | shadowRadius: 1, 14 | shadowOffset: { 15 | height: 0, 16 | width: 0 17 | } 18 | } 19 | }); 20 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/src/TabBarItem.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { TouchableOpacity, Image, Text } from 'react-native'; 3 | 4 | import styles from './TabBarItem.styles'; 5 | 6 | export default function TabBarItem({ active, label, image, onTabItemPressed }) { 7 | return ( 8 | 12 | 16 | 17 | { label } 18 | 19 | 20 | ); 21 | } 22 | 23 | TabBarItem.propTypes = { 24 | active: React.PropTypes.bool.isRequired, 25 | image: React.PropTypes.any.isRequired, 26 | label: React.PropTypes.string.isRequired, 27 | onTabItemPressed: React.PropTypes.func.isRequired 28 | }; 29 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/src/TabBarItem.styles.js: -------------------------------------------------------------------------------- 1 | import { StyleSheet } from 'react-native'; 2 | 3 | export default StyleSheet.create({ 4 | tab: { 5 | flex: 1, 6 | alignItems: 'center', 7 | justifyContent: 'center' 8 | }, 9 | tabImage: { 10 | height: 24, 11 | resizeMode: 'contain', 12 | width: 24 13 | } 14 | }); 15 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/src/assets/tabbar_customer_support_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/CustomTabBar/src/assets/tabbar_customer_support_off.png -------------------------------------------------------------------------------- /Examples/CustomTabBar/src/assets/tabbar_customer_support_off@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/CustomTabBar/src/assets/tabbar_customer_support_off@2x.png -------------------------------------------------------------------------------- /Examples/CustomTabBar/src/assets/tabbar_customer_support_off@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/CustomTabBar/src/assets/tabbar_customer_support_off@3x.png -------------------------------------------------------------------------------- /Examples/CustomTabBar/src/assets/tabbar_customer_support_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/CustomTabBar/src/assets/tabbar_customer_support_on.png -------------------------------------------------------------------------------- /Examples/CustomTabBar/src/assets/tabbar_customer_support_on@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/CustomTabBar/src/assets/tabbar_customer_support_on@2x.png -------------------------------------------------------------------------------- /Examples/CustomTabBar/src/assets/tabbar_customer_support_on@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/CustomTabBar/src/assets/tabbar_customer_support_on@3x.png -------------------------------------------------------------------------------- /Examples/CustomTabBar/src/assets/tabbar_dashboard_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/CustomTabBar/src/assets/tabbar_dashboard_off.png -------------------------------------------------------------------------------- /Examples/CustomTabBar/src/assets/tabbar_dashboard_off@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/CustomTabBar/src/assets/tabbar_dashboard_off@2x.png -------------------------------------------------------------------------------- /Examples/CustomTabBar/src/assets/tabbar_dashboard_off@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/CustomTabBar/src/assets/tabbar_dashboard_off@3x.png -------------------------------------------------------------------------------- /Examples/CustomTabBar/src/assets/tabbar_dashboard_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/CustomTabBar/src/assets/tabbar_dashboard_on.png -------------------------------------------------------------------------------- /Examples/CustomTabBar/src/assets/tabbar_dashboard_on@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/CustomTabBar/src/assets/tabbar_dashboard_on@2x.png -------------------------------------------------------------------------------- /Examples/CustomTabBar/src/assets/tabbar_dashboard_on@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/CustomTabBar/src/assets/tabbar_dashboard_on@3x.png -------------------------------------------------------------------------------- /Examples/CustomTabBar/src/assets/tabbar_energy_advisor_off.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/CustomTabBar/src/assets/tabbar_energy_advisor_off.png -------------------------------------------------------------------------------- /Examples/CustomTabBar/src/assets/tabbar_energy_advisor_off@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/CustomTabBar/src/assets/tabbar_energy_advisor_off@2x.png -------------------------------------------------------------------------------- /Examples/CustomTabBar/src/assets/tabbar_energy_advisor_off@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/CustomTabBar/src/assets/tabbar_energy_advisor_off@3x.png -------------------------------------------------------------------------------- /Examples/CustomTabBar/src/assets/tabbar_energy_advisor_on.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/CustomTabBar/src/assets/tabbar_energy_advisor_on.png -------------------------------------------------------------------------------- /Examples/CustomTabBar/src/assets/tabbar_energy_advisor_on@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/CustomTabBar/src/assets/tabbar_energy_advisor_on@2x.png -------------------------------------------------------------------------------- /Examples/CustomTabBar/src/assets/tabbar_energy_advisor_on@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/CustomTabBar/src/assets/tabbar_energy_advisor_on@3x.png -------------------------------------------------------------------------------- /Examples/CustomTabBar/src/redux/store.js: -------------------------------------------------------------------------------- 1 | import { createStore, combineReducers } from 'redux'; 2 | import { reducer as navigation } from 'react-native-renavigate'; 3 | 4 | const reducers = combineReducers({ 5 | navigation 6 | }); 7 | 8 | export default createStore(reducers); 9 | -------------------------------------------------------------------------------- /Examples/CustomTabBar/src/routes.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Text, TouchableOpacity } from 'react-native'; 3 | import { actionCreators as navigationActions } from 'react-native-renavigate'; 4 | 5 | import PostDetailContainer from './PostDetailContainer'; 6 | import PostListContainer from './PostListContainer'; 7 | 8 | const navButtonStyle = { padding: 5, color: 'blue' }; 9 | const titleStyle = { fontWeight: 'bold' }; 10 | 11 | export default { 12 | DETAIL: (params) => ({ 13 | component: PostDetailContainer, 14 | params, 15 | leftButton: (dispatch) => { 16 | const goBack = () => { 17 | dispatch(navigationActions.pop()); 18 | }; 19 | return ( 20 | 21 | Back 22 | 23 | ); 24 | }, 25 | rightButton: () => { 26 | return FAV; 27 | }, 28 | title: () => { 29 | return { params.title }; 30 | } 31 | }), 32 | LIST: (params) => ({ 33 | component: PostListContainer, 34 | params, 35 | title: () => { 36 | return YOUR POSTS; 37 | } 38 | }) 39 | }; 40 | -------------------------------------------------------------------------------- /Examples/README.md: -------------------------------------------------------------------------------- 1 | # Running the examples 2 | 3 | - Clone this repository 4 | - Open the desired example folder in your terminal 5 | - `yarn install` or `npm install` 6 | - `rm -rf node_modules/react-native-renavigate` 7 | - `sh reset-renavigate.sh` (This command will use renavigate dependency from the fs and run the packager) 8 | - `react-native run-ios` or `react-native run-android` 9 | -------------------------------------------------------------------------------- /Examples/TabsExample/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["react-native"] 3 | } -------------------------------------------------------------------------------- /Examples/TabsExample/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /Examples/TabsExample/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | ; We fork some components by platform 3 | .*/*[.]android.js 4 | 5 | ; Ignore "BUCK" generated dirs 6 | /\.buckd/ 7 | 8 | ; Ignore unexpected extra "@providesModule" 9 | .*/node_modules/.*/node_modules/fbjs/.* 10 | 11 | ; Ignore duplicate module providers 12 | ; For RN Apps installed via npm, "Libraries" folder is inside 13 | ; "node_modules/react-native" but in the source repo it is in the root 14 | .*/Libraries/react-native/React.js 15 | .*/Libraries/react-native/ReactNative.js 16 | 17 | [include] 18 | 19 | [libs] 20 | node_modules/react-native/Libraries/react-native/react-native-interface.js 21 | node_modules/react-native/flow 22 | flow/ 23 | 24 | [options] 25 | module.system=haste 26 | 27 | experimental.strict_type_args=true 28 | 29 | munge_underscores=true 30 | 31 | 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' 32 | 33 | suppress_type=$FlowIssue 34 | suppress_type=$FlowFixMe 35 | suppress_type=$FixMe 36 | 37 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(3[0-6]\\|[1-2][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) 38 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(3[0-6]\\|1[0-9]\\|[1-2][0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ 39 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy 40 | 41 | unsafe.enable_getters_and_setters=true 42 | 43 | [version] 44 | ^0.36.0 45 | -------------------------------------------------------------------------------- /Examples/TabsExample/.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | -------------------------------------------------------------------------------- /Examples/TabsExample/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | project.xcworkspace 24 | 25 | # Android/IntelliJ 26 | # 27 | build/ 28 | .idea 29 | .gradle 30 | local.properties 31 | *.iml 32 | 33 | # node.js 34 | # 35 | node_modules/ 36 | npm-debug.log 37 | 38 | # BUCK 39 | buck-out/ 40 | \.buckd/ 41 | android/app/libs 42 | *.keystore 43 | 44 | # fastlane 45 | # 46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 47 | # screenshots whenever they are needed. 48 | # For more information about the recommended setup visit: 49 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 50 | 51 | fastlane/report.xml 52 | fastlane/Preview.html 53 | fastlane/screenshots 54 | -------------------------------------------------------------------------------- /Examples/TabsExample/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /Examples/TabsExample/__tests__/index.android.js: -------------------------------------------------------------------------------- 1 | import 'react-native'; 2 | import React from 'react'; 3 | import Index from '../index.android.js'; 4 | 5 | // Note: test renderer must be required after react-native. 6 | import renderer from 'react-test-renderer'; 7 | 8 | it('renders correctly', () => { 9 | const tree = renderer.create( 10 | 11 | ); 12 | }); 13 | -------------------------------------------------------------------------------- /Examples/TabsExample/__tests__/index.ios.js: -------------------------------------------------------------------------------- 1 | import 'react-native'; 2 | import React from 'react'; 3 | import Index from '../index.ios.js'; 4 | 5 | // Note: test renderer must be required after react-native. 6 | import renderer from 'react-test-renderer'; 7 | 8 | it('renders correctly', () => { 9 | const tree = renderer.create( 10 | 11 | ); 12 | }); 13 | -------------------------------------------------------------------------------- /Examples/TabsExample/android/app/BUCK: -------------------------------------------------------------------------------- 1 | import re 2 | 3 | # To learn about Buck see [Docs](https://buckbuild.com/). 4 | # To run your application with Buck: 5 | # - install Buck 6 | # - `npm start` - to start the packager 7 | # - `cd android` 8 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"` 9 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck 10 | # - `buck install -r android/app` - compile, install and run application 11 | # 12 | 13 | lib_deps = [] 14 | for jarfile in glob(['libs/*.jar']): 15 | name = 'jars__' + re.sub(r'^.*/([^/]+)\.jar$', r'\1', jarfile) 16 | lib_deps.append(':' + name) 17 | prebuilt_jar( 18 | name = name, 19 | binary_jar = jarfile, 20 | ) 21 | 22 | for aarfile in glob(['libs/*.aar']): 23 | name = 'aars__' + re.sub(r'^.*/([^/]+)\.aar$', r'\1', aarfile) 24 | lib_deps.append(':' + name) 25 | android_prebuilt_aar( 26 | name = name, 27 | aar = aarfile, 28 | ) 29 | 30 | android_library( 31 | name = 'all-libs', 32 | exported_deps = lib_deps 33 | ) 34 | 35 | android_library( 36 | name = 'app-code', 37 | srcs = glob([ 38 | 'src/main/java/**/*.java', 39 | ]), 40 | deps = [ 41 | ':all-libs', 42 | ':build_config', 43 | ':res', 44 | ], 45 | ) 46 | 47 | android_build_config( 48 | name = 'build_config', 49 | package = 'com.tabsexample', 50 | ) 51 | 52 | android_resource( 53 | name = 'res', 54 | res = 'src/main/res', 55 | package = 'com.tabsexample', 56 | ) 57 | 58 | android_binary( 59 | name = 'app', 60 | package_type = 'debug', 61 | manifest = 'src/main/AndroidManifest.xml', 62 | keystore = '//android/keystores:debug', 63 | deps = [ 64 | ':app-code', 65 | ], 66 | ) 67 | -------------------------------------------------------------------------------- /Examples/TabsExample/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | 3 | import com.android.build.OutputFile 4 | 5 | /** 6 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets 7 | * and bundleReleaseJsAndAssets). 8 | * These basically call `react-native bundle` with the correct arguments during the Android build 9 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the 10 | * bundle directly from the development server. Below you can see all the possible configurations 11 | * and their defaults. If you decide to add a configuration block, make sure to add it before the 12 | * `apply from: "../../node_modules/react-native/react.gradle"` line. 13 | * 14 | * project.ext.react = [ 15 | * // the name of the generated asset file containing your JS bundle 16 | * bundleAssetName: "index.android.bundle", 17 | * 18 | * // the entry file for bundle generation 19 | * entryFile: "index.android.js", 20 | * 21 | * // whether to bundle JS and assets in debug mode 22 | * bundleInDebug: false, 23 | * 24 | * // whether to bundle JS and assets in release mode 25 | * bundleInRelease: true, 26 | * 27 | * // whether to bundle JS and assets in another build variant (if configured). 28 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants 29 | * // The configuration property can be in the following formats 30 | * // 'bundleIn${productFlavor}${buildType}' 31 | * // 'bundleIn${buildType}' 32 | * // bundleInFreeDebug: true, 33 | * // bundleInPaidRelease: true, 34 | * // bundleInBeta: true, 35 | * 36 | * // the root of your project, i.e. where "package.json" lives 37 | * root: "../../", 38 | * 39 | * // where to put the JS bundle asset in debug mode 40 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", 41 | * 42 | * // where to put the JS bundle asset in release mode 43 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release", 44 | * 45 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 46 | * // require('./image.png')), in debug mode 47 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", 48 | * 49 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 50 | * // require('./image.png')), in release mode 51 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", 52 | * 53 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means 54 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to 55 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle 56 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ 57 | * // for example, you might want to remove it from here. 58 | * inputExcludes: ["android/**", "ios/**"], 59 | * 60 | * // override which node gets called and with what additional arguments 61 | * nodeExecutableAndArgs: ["node"] 62 | * 63 | * // supply additional arguments to the packager 64 | * extraPackagerArgs: [] 65 | * ] 66 | */ 67 | 68 | apply from: "../../node_modules/react-native/react.gradle" 69 | 70 | /** 71 | * Set this to true to create two separate APKs instead of one: 72 | * - An APK that only works on ARM devices 73 | * - An APK that only works on x86 devices 74 | * The advantage is the size of the APK is reduced by about 4MB. 75 | * Upload all the APKs to the Play Store and people will download 76 | * the correct one based on the CPU architecture of their device. 77 | */ 78 | def enableSeparateBuildPerCPUArchitecture = false 79 | 80 | /** 81 | * Run Proguard to shrink the Java bytecode in release builds. 82 | */ 83 | def enableProguardInReleaseBuilds = false 84 | 85 | android { 86 | compileSdkVersion 23 87 | buildToolsVersion "23.0.1" 88 | 89 | defaultConfig { 90 | applicationId "com.tabsexample" 91 | minSdkVersion 16 92 | targetSdkVersion 22 93 | versionCode 1 94 | versionName "1.0" 95 | ndk { 96 | abiFilters "armeabi-v7a", "x86" 97 | } 98 | } 99 | splits { 100 | abi { 101 | reset() 102 | enable enableSeparateBuildPerCPUArchitecture 103 | universalApk false // If true, also generate a universal APK 104 | include "armeabi-v7a", "x86" 105 | } 106 | } 107 | buildTypes { 108 | release { 109 | minifyEnabled enableProguardInReleaseBuilds 110 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 111 | } 112 | } 113 | // applicationVariants are e.g. debug, release 114 | applicationVariants.all { variant -> 115 | variant.outputs.each { output -> 116 | // For each separate APK per architecture, set a unique version code as described here: 117 | // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits 118 | def versionCodes = ["armeabi-v7a":1, "x86":2] 119 | def abi = output.getFilter(OutputFile.ABI) 120 | if (abi != null) { // null for the universal-debug, universal-release variants 121 | output.versionCodeOverride = 122 | versionCodes.get(abi) * 1048576 + defaultConfig.versionCode 123 | } 124 | } 125 | } 126 | } 127 | 128 | dependencies { 129 | compile fileTree(dir: "libs", include: ["*.jar"]) 130 | compile "com.android.support:appcompat-v7:23.0.1" 131 | compile "com.facebook.react:react-native:+" // From node_modules 132 | } 133 | 134 | // Run this once to be able to run the application with BUCK 135 | // puts all compile dependencies into folder libs for BUCK to use 136 | task copyDownloadableDepsToLibs(type: Copy) { 137 | from configurations.compile 138 | into 'libs' 139 | } 140 | -------------------------------------------------------------------------------- /Examples/TabsExample/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Disabling obfuscation is useful if you collect stack traces from production crashes 20 | # (unless you are using a system that supports de-obfuscate the stack traces). 21 | -dontobfuscate 22 | 23 | # React Native 24 | 25 | # Keep our interfaces so they can be used by other ProGuard rules. 26 | # See http://sourceforge.net/p/proguard/bugs/466/ 27 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip 28 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters 29 | -keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip 30 | 31 | # Do not strip any method/class that is annotated with @DoNotStrip 32 | -keep @com.facebook.proguard.annotations.DoNotStrip class * 33 | -keep @com.facebook.common.internal.DoNotStrip class * 34 | -keepclassmembers class * { 35 | @com.facebook.proguard.annotations.DoNotStrip *; 36 | @com.facebook.common.internal.DoNotStrip *; 37 | } 38 | 39 | -keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * { 40 | void set*(***); 41 | *** get*(); 42 | } 43 | 44 | -keep class * extends com.facebook.react.bridge.JavaScriptModule { *; } 45 | -keep class * extends com.facebook.react.bridge.NativeModule { *; } 46 | -keepclassmembers,includedescriptorclasses class * { native ; } 47 | -keepclassmembers class * { @com.facebook.react.uimanager.UIProp ; } 48 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp ; } 49 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup ; } 50 | 51 | -dontwarn com.facebook.react.** 52 | 53 | # okhttp 54 | 55 | -keepattributes Signature 56 | -keepattributes *Annotation* 57 | -keep class okhttp3.** { *; } 58 | -keep interface okhttp3.** { *; } 59 | -dontwarn okhttp3.** 60 | 61 | # okio 62 | 63 | -keep class sun.misc.Unsafe { *; } 64 | -dontwarn java.nio.file.* 65 | -dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement 66 | -dontwarn okio.** 67 | -------------------------------------------------------------------------------- /Examples/TabsExample/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /Examples/TabsExample/android/app/src/main/java/com/tabsexample/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.tabsexample; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. 9 | * This is used to schedule rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "TabsExample"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Examples/TabsExample/android/app/src/main/java/com/tabsexample/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.tabsexample; 2 | 3 | import android.app.Application; 4 | import android.util.Log; 5 | 6 | import com.facebook.react.ReactApplication; 7 | import com.facebook.react.ReactInstanceManager; 8 | import com.facebook.react.ReactNativeHost; 9 | import com.facebook.react.ReactPackage; 10 | import com.facebook.react.shell.MainReactPackage; 11 | import com.facebook.soloader.SoLoader; 12 | 13 | import java.util.Arrays; 14 | import java.util.List; 15 | 16 | public class MainApplication extends Application implements ReactApplication { 17 | 18 | private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { 19 | @Override 20 | protected boolean getUseDeveloperSupport() { 21 | return BuildConfig.DEBUG; 22 | } 23 | 24 | @Override 25 | protected List getPackages() { 26 | return Arrays.asList( 27 | new MainReactPackage() 28 | ); 29 | } 30 | }; 31 | 32 | @Override 33 | public ReactNativeHost getReactNativeHost() { 34 | return mReactNativeHost; 35 | } 36 | 37 | @Override 38 | public void onCreate() { 39 | super.onCreate(); 40 | SoLoader.init(this, /* native exopackage */ false); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Examples/TabsExample/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/TabsExample/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /Examples/TabsExample/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/TabsExample/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /Examples/TabsExample/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/TabsExample/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Examples/TabsExample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/TabsExample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /Examples/TabsExample/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | TabsExample 3 | 4 | -------------------------------------------------------------------------------- /Examples/TabsExample/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /Examples/TabsExample/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:1.3.1' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | mavenLocal() 18 | jcenter() 19 | maven { 20 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 21 | url "$rootDir/../node_modules/react-native/android" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Examples/TabsExample/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | android.useDeprecatedNdk=true 21 | -------------------------------------------------------------------------------- /Examples/TabsExample/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Wolox/react-native-renavigate/9ff7facb08da8d5f29f5712e1874be6963c088c7/Examples/TabsExample/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /Examples/TabsExample/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip 6 | -------------------------------------------------------------------------------- /Examples/TabsExample/android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /Examples/TabsExample/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /Examples/TabsExample/android/keystores/BUCK: -------------------------------------------------------------------------------- 1 | keystore( 2 | name = 'debug', 3 | store = 'debug.keystore', 4 | properties = 'debug.keystore.properties', 5 | visibility = [ 6 | 'PUBLIC', 7 | ], 8 | ) 9 | -------------------------------------------------------------------------------- /Examples/TabsExample/android/keystores/debug.keystore.properties: -------------------------------------------------------------------------------- 1 | key.store=debug.keystore 2 | key.alias=androiddebugkey 3 | key.store.password=android 4 | key.alias.password=android 5 | -------------------------------------------------------------------------------- /Examples/TabsExample/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'TabsExample' 2 | 3 | include ':app' 4 | -------------------------------------------------------------------------------- /Examples/TabsExample/index.android.js: -------------------------------------------------------------------------------- 1 | import { AppRegistry } from 'react-native'; 2 | 3 | import Main from './main'; 4 | 5 | AppRegistry.registerComponent('TabsExample', () => Main); 6 | -------------------------------------------------------------------------------- /Examples/TabsExample/index.ios.js: -------------------------------------------------------------------------------- 1 | import { AppRegistry } from 'react-native'; 2 | 3 | import Main from './main'; 4 | 5 | AppRegistry.registerComponent('TabsExample', () => Main); 6 | -------------------------------------------------------------------------------- /Examples/TabsExample/ios/TabsExample.xcodeproj/xcshareddata/xcschemes/TabsExample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 29 | 35 | 36 | 37 | 43 | 49 | 50 | 51 | 52 | 53 | 58 | 59 | 61 | 67 | 68 | 69 | 70 | 71 | 77 | 78 | 79 | 80 | 81 | 82 | 92 | 94 | 100 | 101 | 102 | 103 | 104 | 105 | 111 | 113 | 119 | 120 | 121 | 122 | 124 | 125 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /Examples/TabsExample/ios/TabsExample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | @interface AppDelegate : UIResponder 13 | 14 | @property (nonatomic, strong) UIWindow *window; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /Examples/TabsExample/ios/TabsExample/AppDelegate.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "AppDelegate.h" 11 | 12 | #import 13 | #import 14 | 15 | @implementation AppDelegate 16 | 17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 18 | { 19 | NSURL *jsCodeLocation; 20 | 21 | jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil]; 22 | 23 | RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation 24 | moduleName:@"TabsExample" 25 | initialProperties:nil 26 | launchOptions:launchOptions]; 27 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; 28 | 29 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 30 | UIViewController *rootViewController = [UIViewController new]; 31 | rootViewController.view = rootView; 32 | self.window.rootViewController = rootViewController; 33 | [self.window makeKeyAndVisible]; 34 | return YES; 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /Examples/TabsExample/ios/TabsExample/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /Examples/TabsExample/ios/TabsExample/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /Examples/TabsExample/ios/TabsExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UIViewControllerBasedStatusBarAppearance 38 | 39 | NSLocationWhenInUseUsageDescription 40 | 41 | NSAppTransportSecurity 42 | 43 | 44 | NSExceptionDomains 45 | 46 | localhost 47 | 48 | NSExceptionAllowsInsecureHTTPLoads 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /Examples/TabsExample/ios/TabsExample/main.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | #import "AppDelegate.h" 13 | 14 | int main(int argc, char * argv[]) { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /Examples/TabsExample/ios/TabsExampleTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /Examples/TabsExample/ios/TabsExampleTests/TabsExampleTests.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | #import 12 | 13 | #import 14 | #import 15 | 16 | #define TIMEOUT_SECONDS 600 17 | #define TEXT_TO_LOOK_FOR @"Welcome to React Native!" 18 | 19 | @interface TabsExampleTests : XCTestCase 20 | 21 | @end 22 | 23 | @implementation TabsExampleTests 24 | 25 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test 26 | { 27 | if (test(view)) { 28 | return YES; 29 | } 30 | for (UIView *subview in [view subviews]) { 31 | if ([self findSubviewInView:subview matching:test]) { 32 | return YES; 33 | } 34 | } 35 | return NO; 36 | } 37 | 38 | - (void)testRendersWelcomeScreen 39 | { 40 | UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController]; 41 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; 42 | BOOL foundElement = NO; 43 | 44 | __block NSString *redboxError = nil; 45 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { 46 | if (level >= RCTLogLevelError) { 47 | redboxError = message; 48 | } 49 | }); 50 | 51 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { 52 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 53 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 54 | 55 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { 56 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { 57 | return YES; 58 | } 59 | return NO; 60 | }]; 61 | } 62 | 63 | RCTSetLogFunction(RCTDefaultLogFunction); 64 | 65 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); 66 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); 67 | } 68 | 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /Examples/TabsExample/main.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Provider } from 'react-redux'; 3 | 4 | import store from './src/redux/store'; 5 | import App from './src/App'; 6 | 7 | export default function main() { 8 | return ( 9 | 10 | 11 | 12 | ); 13 | } 14 | -------------------------------------------------------------------------------- /Examples/TabsExample/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "TabsExample", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "start": "node node_modules/react-native/local-cli/cli.js start", 7 | "test": "jest" 8 | }, 9 | "dependencies": { 10 | "react": "~15.4.0-rc.4", 11 | "react-native": "0.40.0", 12 | "react-native-renavigate": "file:../../", 13 | "react-redux": "^5.0.2", 14 | "redux": "^3.6.0" 15 | }, 16 | "devDependencies": { 17 | "babel-eslint": "^7.1.1", 18 | "babel-jest": "18.0.0", 19 | "babel-preset-react-native": "1.9.1", 20 | "eslint": "^3.13.1", 21 | "eslint-plugin-react": "^6.9.0", 22 | "jest": "18.1.0", 23 | "react-test-renderer": "~15.4.0-rc.4" 24 | }, 25 | "jest": { 26 | "preset": "react-native" 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Examples/TabsExample/reset-renavigate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | rm -rf node_modules/react-native-renavigate/ 3 | npm i react-native-renavigate 4 | npm start -- --reset-cache 5 | -------------------------------------------------------------------------------- /Examples/TabsExample/src/EmptyView.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { connect } from 'react-redux'; 3 | import { View, Text, TouchableOpacity } from 'react-native'; 4 | import { actionCreators } from 'react-native-renavigate'; 5 | 6 | class EmptyView extends Component { 7 | 8 | backToList = () => { 9 | this.props.dispatch(actionCreators.pop()); 10 | } 11 | 12 | render() { 13 | return ( 14 | 15 | 19 | Go back to list 20 | 21 | 22 | This view is empty 23 | 24 | 25 | ); 26 | } 27 | } 28 | 29 | export default connect()(EmptyView); 30 | -------------------------------------------------------------------------------- /Examples/TabsExample/src/PostDetailContainer.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { Text, TouchableOpacity, View } from 'react-native'; 3 | import { connect } from 'react-redux'; 4 | import { actionCreators } from 'react-native-renavigate'; 5 | 6 | class PostDetailContainer extends Component { 7 | 8 | componentDidMount() { 9 | console.log('mount detail'); 10 | } 11 | 12 | componentWillUnmount() { 13 | console.log('unmount detail'); 14 | } 15 | 16 | backToList = () => { 17 | this.props.dispatch(actionCreators.pop()); 18 | } 19 | 20 | replaceWithEmpty = () => { 21 | this.props.dispatch(actionCreators.replace.EMPTY_VIEW()); 22 | } 23 | 24 | render() { 25 | return ( 26 | 27 | 31 | Go back to list 32 | 33 | 34 | { this.props.text } 35 | 36 | 40 | Go to empty view 41 | 42 | 43 | ); 44 | } 45 | } 46 | 47 | PostDetailContainer.propTypes = { 48 | text: React.PropTypes.string.isRequired 49 | }; 50 | 51 | export default connect()(PostDetailContainer); 52 | -------------------------------------------------------------------------------- /Examples/TabsExample/src/PostListContainer.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { ScrollView, TouchableOpacity, Text, View } from 'react-native'; 3 | import { connect } from 'react-redux'; 4 | import { actionCreators } from 'react-native-renavigate'; 5 | 6 | class PostListContainer extends Component { 7 | 8 | renderPostDetail = (post) => { 9 | this.props.dispatch(actionCreators.push.DETAIL(post)); 10 | } 11 | 12 | changeTab = (index) => { 13 | this.props.dispatch(actionCreators.tabChanged(index)); 14 | } 15 | 16 | render() { 17 | return ( 18 | 19 | { 20 | this.props.posts.map((post, idx) => { 21 | return ( 22 | 23 | this.renderPostDetail(post)} 27 | > 28 | { post.title } 29 | 30 | this.changeTab(idx)}> 31 | TAB: { idx } 32 | 33 | 34 | ); 35 | }) 36 | } 37 | 38 | ); 39 | } 40 | } 41 | 42 | PostListContainer.propTypes = { 43 | posts: React.PropTypes.array.isRequired 44 | }; 45 | 46 | export default connect()(PostListContainer); 47 | -------------------------------------------------------------------------------- /Examples/TabsExample/src/redux/store.js: -------------------------------------------------------------------------------- 1 | import { createStore, combineReducers } from 'redux'; 2 | import { reducer as navigation } from 'react-native-renavigate'; 3 | 4 | const reducers = combineReducers({ 5 | navigation 6 | }); 7 | 8 | export default createStore(reducers); 9 | -------------------------------------------------------------------------------- /Examples/TabsExample/src/routes.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { Text, TouchableOpacity } from 'react-native'; 3 | import { actionCreators as navigationActions } from 'react-native-renavigate'; 4 | 5 | import PostDetailContainer from './PostDetailContainer'; 6 | import PostListContainer from './PostListContainer'; 7 | import EmptyView from './EmptyView'; 8 | 9 | const navButtonStyle = { padding: 5, color: 'blue' }; 10 | const titleStyle = { fontWeight: 'bold' }; 11 | 12 | export default { 13 | DETAIL: (params) => ({ 14 | component: PostDetailContainer, 15 | params, 16 | leftButton: (dispatch) => { 17 | const goBack = () => { 18 | dispatch(navigationActions.pop()); 19 | }; 20 | return ( 21 | 22 | Back 23 | 24 | ); 25 | }, 26 | rightButton: () => { 27 | return FAV; 28 | }, 29 | title: () => { 30 | return { params.title }; 31 | } 32 | }), 33 | LIST: (params) => ({ 34 | component: PostListContainer, 35 | params, 36 | title: () => { 37 | return YOUR POSTS; 38 | } 39 | }), 40 | EMPTY_VIEW: (params) => ({ 41 | component: EmptyView, 42 | params, 43 | title: () => { 44 | return EMPTY VIEW; 45 | } 46 | }) 47 | }; 48 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Sebastián Balay 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /circle.yml: -------------------------------------------------------------------------------- 1 | machine: 2 | node: 3 | version: 6 4 | test: 5 | override: 6 | - npm run lint 7 | - npm run coverage 8 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | import reducerExport from './src/reducer'; 2 | import { actionCreators as actionCreatorsExport } from './src/actions'; 3 | import RootSceneContainerExport from './src/RootSceneContainer'; 4 | import TabsContainerExport from './src/TabsContainer'; 5 | 6 | export const reducer = reducerExport; 7 | export const actionCreators = actionCreatorsExport; 8 | export const RootSceneContainer = RootSceneContainerExport; 9 | export const TabsContainer = TabsContainerExport; 10 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-renavigate", 3 | "version": "0.2.20", 4 | "description": "React native navigation made easy using redux", 5 | "main": "lib/index.js", 6 | "scripts": { 7 | "lint": "eslint src && eslint index.js", 8 | "test": "jest", 9 | "coverage": "jest --coverage", 10 | "build": "babel index.js -d lib && babel src -d lib/src", 11 | "prepublish": "npm run build" 12 | }, 13 | "repository": { 14 | "type": "git", 15 | "url": "git+https://github.com/wolox/react-native-renavigate.git" 16 | }, 17 | "keywords": [ 18 | "react-native", 19 | "react", 20 | "navigation", 21 | "router", 22 | "redux", 23 | "navigator" 24 | ], 25 | "author": "Sebastian Balay ", 26 | "license": "MIT", 27 | "bugs": { 28 | "url": "https://github.com/wolox/react-native-renavigate/issues" 29 | }, 30 | "homepage": "https://github.com/wolox/react-native-renavigate#readme", 31 | "jest": { 32 | "testPathIgnorePatterns": [ 33 | "/node_modules/", 34 | "/Examples", 35 | "/lib" 36 | ], 37 | "collectCoverageFrom": [ 38 | "src/**/*.js" 39 | ], 40 | "coverageDirectory": "./coverage/", 41 | "testRegex": ".*\\.spec\\.js$" 42 | }, 43 | "dependencies": { 44 | "react-native-scrollable-tab-view": "^0.6.0", 45 | "seamless-immutable": "^7.0.1" 46 | }, 47 | "devDependencies": { 48 | "babel-cli": "^6.18.0", 49 | "babel-eslint": "^7.1.1", 50 | "babel-jest": "^18.0.0", 51 | "babel-preset-react-native": "^1.9.1", 52 | "eslint": "^3.13.1", 53 | "eslint-plugin-react": "^6.9.0", 54 | "jest": "^18.1.0", 55 | "react": "^15.4.2", 56 | "react-native": "^0.40.0" 57 | }, 58 | "peerDependencies": { 59 | "react-native": "^0.40.0", 60 | "react-redux": "^5.0.2", 61 | "redux": "^3.6.0" 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/RootSceneContainer.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { BackAndroid } from 'react-native'; 3 | import { connect } from 'react-redux'; 4 | 5 | import RootScene from './RootScene'; 6 | import { actionCreators as navigationActions } from './actions'; 7 | import { propTypes as navigationPropTypes } from './reducer'; 8 | 9 | class RootSceneContainer extends Component { 10 | 11 | componentDidMount() { 12 | BackAndroid.addEventListener('hardwareBackPress', this.handleAndroidBackButton); 13 | } 14 | 15 | componentWillUnmount() { 16 | BackAndroid.removeEventListener('hardwareBackPress', this.handleAndroidBackButton); 17 | } 18 | 19 | handleAndroidBackButton = () => { 20 | if (this.props.routeStack && this.props.routeStack.length) { 21 | this.props.dispatch(navigationActions.pop()); 22 | return true; 23 | } 24 | } 25 | 26 | render() { 27 | return ( 28 | 29 | ); 30 | } 31 | } 32 | 33 | RootSceneContainer.propTypes = { 34 | activeRoute: navigationPropTypes.activeRoute, // from store 35 | navigationMethod: navigationPropTypes.method, // from store 36 | routeStack: navigationPropTypes.routeStack // from store 37 | }; 38 | 39 | const mapStateToProps = (store) => { 40 | const navState = store.navigation.null; 41 | return { 42 | activeRoute: navState && navState.activeRoute, 43 | navigationMethod: navState && navState.method, 44 | routeStack: navState && navState.routeStack 45 | }; 46 | }; 47 | 48 | export default connect(mapStateToProps)(RootSceneContainer); 49 | -------------------------------------------------------------------------------- /src/TabContainer.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { connect } from 'react-redux'; 3 | import { BackAndroid } from 'react-native'; 4 | 5 | import RootScene from './RootScene'; 6 | import { actionCreators as navigationActions } from './actions'; 7 | 8 | class TabContainer extends Component { 9 | 10 | componentDidMount() { 11 | if (this.props.isActiveTab) { 12 | this.addAndroidBackButtonListener(); 13 | } 14 | } 15 | 16 | componentWillReceiveProps(nextProps) { 17 | if (this.props.isActiveTab && !nextProps.isActiveTab) { 18 | this.removeAndroidBackButtonListener(); 19 | } else if (!this.props.isActiveTab && nextProps.isActiveTab) { 20 | this.addAndroidBackButtonListener(); 21 | } 22 | } 23 | 24 | componentWillUnmount() { 25 | this.removeAndroidBackButtonListener(); 26 | } 27 | 28 | addAndroidBackButtonListener() { 29 | BackAndroid.addEventListener('hardwareBackPress', this.handleAndroidBackButton); 30 | } 31 | 32 | removeAndroidBackButtonListener() { 33 | BackAndroid.removeEventListener('hardwareBackPress', this.handleAndroidBackButton); 34 | } 35 | 36 | handleAndroidBackButton = () => { 37 | if (this.props.routeStack && this.props.routeStack.length) { 38 | this.props.dispatch(navigationActions.pop()); 39 | return true; 40 | } 41 | } 42 | 43 | handleWillFocus = (route) => { 44 | if (this.props.onWillFocus) { 45 | this.props.onWillFocus(route, this.props.tabIndex); 46 | } 47 | } 48 | 49 | handleDidFocus = (route) => { 50 | if (this.props.onDidFocus) { 51 | this.props.onDidFocus(route, this.props.tabIndex); 52 | } 53 | } 54 | 55 | render() { 56 | return ( 57 | ); 62 | } 63 | } 64 | 65 | TabContainer.propTypes = { 66 | isActiveTab: React.PropTypes.bool, 67 | ...RootScene.propTypes 68 | }; 69 | 70 | const mapStateToProps = (store, props) => { 71 | if (!props.tabIndex && props.tabIndex !== 0) { 72 | throw new Error('prop "tabIndex" must be present in TabContainer'); 73 | } 74 | const navState = store.navigation[props.tabIndex]; 75 | return { 76 | activeRoute: navState && navState.activeRoute, 77 | navigationMethod: navState && navState.method, 78 | routeStack: navState && navState.routeStack, 79 | isActiveTab: store.navigation.activeTabIndex === props.tabIndex 80 | }; 81 | }; 82 | 83 | export default connect(mapStateToProps)(TabContainer); 84 | -------------------------------------------------------------------------------- /src/TabsContainer.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import ScrollableTabView, { DefaultTabBar } from 'react-native-scrollable-tab-view'; 3 | import { connect } from 'react-redux'; 4 | import { View } from 'react-native'; 5 | 6 | import TabContainer from './TabContainer'; 7 | import RootScene, { routeInstancePropType } from './RootScene'; 8 | import { actionCreators } from './actions'; 9 | 10 | class TabsContainer extends Component { 11 | 12 | constructor(props) { 13 | super(props); 14 | this.initialTab = props.activeTabIndex || props.initialTab; 15 | props.dispatch(actionCreators.initTabs(props.tabs.length, this.initialTab)); 16 | this.activeRoutes = {}; 17 | this.state = { 18 | hiddenPad: this.props.hiddenPad || 0 19 | }; 20 | } 21 | 22 | shouldHideTabBar = () => { 23 | const currentTab = this.props.tabs[this.props.activeTabIndex]; 24 | const activeRoute = this.activeRoutes[this.props.activeTabIndex]; 25 | return (!this.props.alwaysShowTabBar && (this.props.shouldHideTabBar || (currentTab && 26 | Array.isArray(currentTab.initialRoute) && currentTab.initialRoute.indexOf(activeRoute) > 0))); 27 | } 28 | 29 | afterPushView = () => { 30 | if (this.shouldHideTabBar()) { 31 | this.setState({ hiddenPad: 0 }); 32 | } 33 | } 34 | 35 | beforePopView = (route, tabIndex) => { 36 | if (!this.shouldHideTabBar()) { 37 | this.setState({ hiddenPad: this.props.hiddenPad || 0 }); 38 | } 39 | this.activeRoutes[tabIndex] = route; 40 | this.setState({ activeRoutes: this.activeRoutes }); 41 | } 42 | 43 | renderTabBar = (props) => { 44 | if (this.shouldHideTabBar()) { 45 | return ; 46 | } 47 | 48 | if (this.props.tabsComponentProps.renderTabBar) { 49 | return this.props.tabsComponentProps.renderTabBar(props); 50 | } 51 | 52 | return ; 53 | } 54 | 55 | getTabsComponent(tabs) { 56 | return ( 57 | 65 | { 66 | tabs.map((tab, index) => { 67 | return this.getTabComponent(tab, index); 68 | }) 69 | } 70 | 71 | ); 72 | } 73 | 74 | getTabComponent(tab, index) { 75 | return ( 76 | 90 | ); 91 | } 92 | 93 | handleTabChanged = ({ i }) => { 94 | if (this.props.tabsComponentProps.onChangeTab) { 95 | this.props.tabsComponentProps.onChangeTab({ i }); 96 | } 97 | this.props.dispatch(actionCreators.tabChanged(i)); 98 | } 99 | 100 | render() { 101 | return this.getTabsComponent(this.props.tabs); 102 | } 103 | } 104 | 105 | TabsContainer.defaultProps = { 106 | initialTab: 0, 107 | tabsComponentProps: {}, 108 | alwaysShowTabBar: false 109 | }; 110 | 111 | TabsContainer.propTypes = { 112 | activeTabIndex: React.PropTypes.number, 113 | initialTab: React.PropTypes.number.isRequired, 114 | tabs: React.PropTypes.arrayOf( 115 | React.PropTypes.shape({ 116 | initialRoute: React.PropTypes.oneOfType([ 117 | routeInstancePropType, 118 | React.PropTypes.arrayOf(routeInstancePropType) 119 | ]), 120 | label: React.PropTypes.string.isRequired 121 | }).isRequired 122 | ).isRequired, 123 | tabsComponentProps: React.PropTypes.shape(ScrollableTabView.propTypes).isRequired, 124 | alwaysShowTabBar: React.PropTypes.bool, 125 | hiddenPad: React.PropTypes.number, 126 | ...RootScene.propTypes 127 | }; 128 | 129 | const mapStateToProps = (store) => { 130 | const navState = store.navigation[store.navigation.activeTabIndex]; 131 | return { 132 | activeRoute: navState && navState.activeRoute, 133 | activeTabIndex: store.navigation.activeTabIndex, 134 | shouldHideTabBar: store.navigation.shouldHideTabBar 135 | }; 136 | }; 137 | 138 | export default connect(mapStateToProps)(TabsContainer); 139 | -------------------------------------------------------------------------------- /src/actions.js: -------------------------------------------------------------------------------- 1 | 2 | export const actions = { 3 | PUSH: '@@renavigate/PUSH', 4 | SOFT_POP: '@@renavigate/SOFT_POP', 5 | POP: '@@renavigate/POP', 6 | POP_TO_TOP: '@@renavigate/POP_TO_TOP', 7 | RESET_TO: '@@renavigate/RESET_TO', 8 | REPLACE: '@@renavigate/REPLACE', 9 | TAB_CHANGED: '@@renavigate/TAB_CHANGED', 10 | INIT_TABS: '@@renavigate/INIT_TABS' 11 | }; 12 | 13 | export const methodActions = { 14 | PUSH: 'push', 15 | SOFT_POP: 'softPop', 16 | POP: 'pop', 17 | POP_TO_TOP: 'popToTop', 18 | RESET_TO: 'resetTo', 19 | REPLACE: 'replace', 20 | TAB_CHANGED: 'tabChanged', 21 | INIT_TABS: 'initTabs' 22 | }; 23 | 24 | export const typeToMethod = { 25 | '@@renavigate/PUSH': 'push', 26 | '@@renavigate/SOFT_POP': 'softPop', 27 | '@@renavigate/POP': 'pop', 28 | '@@renavigate/POP_TO_TOP': 'popToTop', 29 | '@@renavigate/RESET_TO': 'resetTo', 30 | '@@renavigate/REPLACE': 'replace', 31 | '@@renavigate/TAB_CHANGED': 'tabChanged', 32 | '@@renavigate/INIT_TABS': 'initTabs' 33 | }; 34 | 35 | export const actionCreators = { 36 | push: {}, 37 | resetTo: {}, 38 | replace: {}, 39 | softPop: () => ({ type: actions.SOFT_POP }), 40 | pop: () => ({ type: actions.POP }), 41 | popToTop: () => ({ type: actions.POP_TO_TOP }), 42 | tabChanged: (tabIndex) => ({ type: actions.TAB_CHANGED, payload: { tabIndex } }), 43 | initTabs: (tabsCount, initialTab) => ({ type: actions.INIT_TABS, payload: { tabsCount, initialTab } }) 44 | }; 45 | 46 | export function initActions(routeDefs) { 47 | 48 | const routePayload = (name, params) => ({ route: { name, params } }); 49 | 50 | const routeNames = Object.keys(routeDefs); 51 | for (const routeName of routeNames) { 52 | actionCreators.push[routeName] = (params) => { 53 | return { 54 | type: actions.PUSH, 55 | payload: routePayload(routeName, params) 56 | }; 57 | }; 58 | actionCreators.resetTo[routeName] = (params) => { 59 | return { 60 | type: actions.RESET_TO, 61 | payload: routePayload(routeName, params) 62 | }; 63 | }; 64 | actionCreators.replace[routeName] = (params) => { 65 | return { 66 | type: actions.REPLACE, 67 | payload: routePayload(routeName, params) 68 | }; 69 | }; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/navigationBarRouteMapper.js: -------------------------------------------------------------------------------- 1 | 2 | export default function buildNavigationBarRouteMapper(dispatch) { 3 | // arguments = (route, navigator, index, navState) 4 | return { 5 | LeftButton(route) { 6 | return route.leftButton ? route.leftButton(dispatch, ...arguments) : null; 7 | }, 8 | RightButton(route) { 9 | return route.rightButton ? route.rightButton(dispatch, ...arguments) : null; 10 | }, 11 | Title(route) { 12 | return route.title ? route.title(dispatch, ...arguments) : null; 13 | } 14 | }; 15 | } 16 | -------------------------------------------------------------------------------- /src/reducer.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import Immutable from 'seamless-immutable'; 3 | 4 | import { actions, typeToMethod } from './actions'; 5 | 6 | export const defaultState = Immutable({ 7 | activeTabIndex: null, 8 | [null]: { 9 | routeStack: [], 10 | activeRoute: null, 11 | method: null 12 | }, 13 | shouldHideTabBar: false 14 | }); 15 | 16 | /* eslint-disable complexity */ 17 | export default function reducer(state = defaultState, { type, payload }) { 18 | switch (type) { 19 | case actions.PUSH: { 20 | const tabState = state[state.activeTabIndex]; 21 | return state.merge({ 22 | [state.activeTabIndex]: { 23 | routeStack: [...tabState.routeStack, tabState.activeRoute], 24 | activeRoute: payload.route, 25 | method: typeToMethod[type] 26 | }, 27 | shouldHideTabBar: true 28 | }); 29 | } 30 | case actions.RESET_TO: { 31 | return state.merge({ 32 | [state.activeTabIndex]: { 33 | routeStack: [], 34 | activeRoute: payload.route, 35 | method: typeToMethod[type] 36 | }, 37 | shouldHideTabBar: false 38 | }); 39 | } 40 | case actions.REPLACE: { 41 | return state.merge({ 42 | [state.activeTabIndex]: { 43 | ...state[state.activeTabIndex], 44 | activeRoute: payload.route, 45 | method: typeToMethod[type] 46 | } 47 | }); 48 | } 49 | case actions.SOFT_POP: 50 | case actions.POP: { 51 | const tabState = state[state.activeTabIndex]; 52 | const nextActiveRoute = tabState.routeStack.length > 0 53 | ? tabState.routeStack.slice(-1)[0] 54 | : tabState.activeRoute; 55 | return state.merge({ 56 | [state.activeTabIndex]: { 57 | routeStack: tabState.routeStack.slice(0, -1), 58 | activeRoute: nextActiveRoute, 59 | method: typeToMethod[type] 60 | }, 61 | shouldHideTabBar: tabState.routeStack.slice(0, -1).length > 0 62 | }); 63 | } 64 | case actions.POP_TO_TOP: { 65 | const tabState = state[state.activeTabIndex]; 66 | return state.merge({ 67 | [state.activeTabIndex]: { 68 | routeStack: [], 69 | activeRoute: tabState.routeStack.length > 0 ? tabState.routeStack[0] : tabState.activeRoute, 70 | method: typeToMethod[type] 71 | }, 72 | shouldHideTabBar: false 73 | }); 74 | } 75 | case actions.INIT_TABS: { 76 | if (Number.isInteger(state.activeTabIndex)) { 77 | // in android. the init_tabs action is fired whenever the app restores from the background but we 78 | // only want to handle the first dispatch of this action. 79 | return state; 80 | } 81 | const tabsState = {}; 82 | for (let tabIndex = 0; tabIndex < payload.tabsCount; tabIndex++) { 83 | tabsState[tabIndex] = { 84 | routeStack: [], 85 | activeRoute: null, 86 | method: null 87 | }; 88 | } 89 | return state.merge({ 90 | ...tabsState, 91 | activeTabIndex: payload.initialTab, 92 | shouldHideTabBar: false 93 | }); 94 | } 95 | case actions.TAB_CHANGED: { 96 | return state.merge({ 97 | activeTabIndex: payload.tabIndex 98 | }); 99 | } 100 | default: { 101 | return state; 102 | } 103 | } 104 | } 105 | /* eslint-enable complexity */ 106 | 107 | const routePropType = React.PropTypes.shape({ 108 | name: React.PropTypes.string.isRequired, 109 | params: React.PropTypes.object 110 | }); 111 | 112 | export const propTypes = { 113 | activeRoute: routePropType, 114 | routeStack: React.PropTypes.arrayOf(routePropType), 115 | method: React.PropTypes.string, 116 | activeTabIndex(props, propName) { 117 | const value = props[propName]; 118 | return Number.isInteger(value) || value === null; 119 | } 120 | }; 121 | -------------------------------------------------------------------------------- /test/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | env: { 3 | jest: true 4 | } 5 | } 6 | -------------------------------------------------------------------------------- /test/actions.spec.js: -------------------------------------------------------------------------------- 1 | import { actions, actionCreators, initActions } from '../src/actions'; 2 | 3 | describe('#initActions', () => { 4 | beforeEach(() => { 5 | const routeDefs = { 6 | ROUTE_A: { component: 'RouteAComponent' }, 7 | ROUTE_B: { component: 'RouteBComponent' } 8 | }; 9 | initActions(routeDefs); 10 | }); 11 | it('should add push action creators', () => { 12 | expect(actionCreators.push.ROUTE_B).not.toBeUndefined(); 13 | expect(actionCreators.push.ROUTE_A).not.toBeUndefined(); 14 | expect(actionCreators.push.ROUTE_C).toBeUndefined(); 15 | }); 16 | it('should add resetTo action creators', () => { 17 | expect(actionCreators.resetTo.ROUTE_A).not.toBeUndefined(); 18 | expect(actionCreators.resetTo.ROUTE_B).not.toBeUndefined(); 19 | expect(actionCreators.resetTo.ROUTE_C).toBeUndefined(); 20 | }); 21 | it('should add replace action creators', () => { 22 | expect(actionCreators.replace.ROUTE_A).not.toBeUndefined(); 23 | expect(actionCreators.replace.ROUTE_B).not.toBeUndefined(); 24 | expect(actionCreators.replace.ROUTE_C).toBeUndefined(); 25 | }); 26 | }); 27 | 28 | describe('#actionCreators', () => { 29 | describe('push', () => { 30 | beforeEach(() => { 31 | initActions({ ROUTE: { component: 'RouteComponent' } }); 32 | }); 33 | it('should create a push action', () => { 34 | const expectedAction = { 35 | type: actions.PUSH, 36 | payload: { 37 | route: { 38 | name: 'ROUTE', 39 | params: { 40 | routeParam: 3 41 | } 42 | } 43 | } 44 | }; 45 | expect(actionCreators.push.ROUTE({ routeParam: 3 })).toEqual(expectedAction); 46 | }); 47 | }); 48 | describe('resetTo', () => { 49 | beforeEach(() => { 50 | initActions({ ROUTE: { component: 'RouteComponent' } }); 51 | }); 52 | it('should create a resetTo action', () => { 53 | const expectedAction = { 54 | type: actions.RESET_TO, 55 | payload: { 56 | route: { 57 | name: 'ROUTE', 58 | params: { foo: 'bar' } 59 | } 60 | } 61 | }; 62 | expect(actionCreators.resetTo.ROUTE({ foo: 'bar' })).toEqual(expectedAction); 63 | }); 64 | }); 65 | describe('replace', () => { 66 | beforeEach(() => { 67 | initActions({ ROUTE: { component: 'RouteComponent' } }); 68 | }); 69 | it('should create a replace action', () => { 70 | const expectedAction = { 71 | type: actions.REPLACE, 72 | payload: { 73 | route: { 74 | name: 'ROUTE', 75 | params: { foo: 'bar' } 76 | } 77 | } 78 | }; 79 | expect(actionCreators.replace.ROUTE({ foo: 'bar' })).toEqual(expectedAction); 80 | }); 81 | }); 82 | describe('pop', () => { 83 | it('should create a pop action', () => { 84 | const expectedAction = { 85 | type: actions.POP 86 | }; 87 | expect(actionCreators.pop()).toEqual(expectedAction); 88 | }); 89 | }); 90 | describe('popToTop', () => { 91 | it('should create a popToTop action', () => { 92 | const expectedAction = { 93 | type: actions.POP_TO_TOP 94 | }; 95 | expect(actionCreators.popToTop()).toEqual(expectedAction); 96 | }); 97 | }); 98 | describe('tabChanged', () => { 99 | it('should create a tabChanged action', () => { 100 | const expectedAction = { 101 | type: actions.TAB_CHANGED, 102 | payload: { tabIndex: 5 } 103 | }; 104 | expect(actionCreators.tabChanged(5)).toEqual(expectedAction); 105 | }); 106 | }); 107 | describe('initTabs', () => { 108 | it('should create a initTabs action', () => { 109 | const expectedAction = { 110 | type: actions.INIT_TABS, 111 | payload: { tabsCount: 3, initialTab: 0 } 112 | }; 113 | expect(actionCreators.initTabs(3, 0)).toEqual(expectedAction); 114 | }); 115 | }); 116 | }); 117 | --------------------------------------------------------------------------------