├── test
├── .watchmanconfig
├── .gitattributes
├── app.json
├── .eslintrc.js
├── babel.config.js
├── android
│ ├── .settings
│ │ └── org.eclipse.buildship.core.prefs
│ ├── app
│ │ ├── src
│ │ │ ├── main
│ │ │ │ ├── res
│ │ │ │ │ ├── values
│ │ │ │ │ │ ├── strings.xml
│ │ │ │ │ │ └── styles.xml
│ │ │ │ │ ├── mipmap-hdpi
│ │ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ │ └── ic_launcher_round.png
│ │ │ │ │ ├── mipmap-mdpi
│ │ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ │ └── ic_launcher_round.png
│ │ │ │ │ ├── mipmap-xhdpi
│ │ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ │ └── ic_launcher_round.png
│ │ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ │ └── ic_launcher_round.png
│ │ │ │ │ └── mipmap-xxxhdpi
│ │ │ │ │ │ ├── ic_launcher.png
│ │ │ │ │ │ └── ic_launcher_round.png
│ │ │ │ ├── java
│ │ │ │ │ └── com
│ │ │ │ │ │ └── test
│ │ │ │ │ │ ├── MainActivity.java
│ │ │ │ │ │ └── MainApplication.java
│ │ │ │ └── AndroidManifest.xml
│ │ │ └── debug
│ │ │ │ └── AndroidManifest.xml
│ │ ├── debug.keystore
│ │ ├── proguard-rules.pro
│ │ ├── build_defs.bzl
│ │ ├── BUCK
│ │ └── build.gradle
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── settings.gradle
│ ├── .project
│ ├── gradle.properties
│ ├── build.gradle
│ ├── gradlew.bat
│ └── gradlew
├── ios
│ ├── test
│ │ ├── Images.xcassets
│ │ │ ├── Contents.json
│ │ │ └── AppIcon.appiconset
│ │ │ │ └── Contents.json
│ │ ├── AppDelegate.h
│ │ ├── main.m
│ │ ├── AppDelegate.m
│ │ ├── Info.plist
│ │ └── Base.lproj
│ │ │ └── LaunchScreen.xib
│ ├── testTests
│ │ ├── Info.plist
│ │ └── testTests.m
│ ├── test-tvOSTests
│ │ └── Info.plist
│ ├── test-tvOS
│ │ └── Info.plist
│ ├── Podfile
│ └── test.xcodeproj
│ │ ├── xcshareddata
│ │ └── xcschemes
│ │ │ ├── test.xcscheme
│ │ │ └── test-tvOS.xcscheme
│ │ └── project.pbxproj
├── .buckconfig
├── .prettierrc.js
├── index.js
├── __tests__
│ └── App-test.js
├── metro.config.js
├── package.json
├── App.js
└── .flowconfig
├── .gitattributes
├── Button.ios.js
├── StaticContainer.js
├── Button.android.js
├── example
└── android
│ ├── .project
│ └── app
│ └── .project
├── SceneComponent.js
├── package.json
├── DefaultTabBar.js
├── README.md
├── .eslintrc
├── ScrollableTabBar.js
├── ScrollPager.js
└── index.js
/test/.watchmanconfig:
--------------------------------------------------------------------------------
1 | {}
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | *.pbxproj -text
2 |
--------------------------------------------------------------------------------
/test/.gitattributes:
--------------------------------------------------------------------------------
1 | *.pbxproj -text
2 |
--------------------------------------------------------------------------------
/test/app.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "test",
3 | "displayName": "test"
4 | }
--------------------------------------------------------------------------------
/test/.eslintrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | root: true,
3 | extends: '@react-native-community',
4 | };
5 |
--------------------------------------------------------------------------------
/test/babel.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | presets: ['module:metro-react-native-babel-preset'],
3 | };
4 |
--------------------------------------------------------------------------------
/test/android/.settings/org.eclipse.buildship.core.prefs:
--------------------------------------------------------------------------------
1 | connection.project.dir=
2 | eclipse.preferences.version=1
3 |
--------------------------------------------------------------------------------
/test/android/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | test
3 |
4 |
--------------------------------------------------------------------------------
/test/ios/test/Images.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
7 |
--------------------------------------------------------------------------------
/test/android/app/debug.keystore:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuC520/react-native-scrollable-tab-view-forked/HEAD/test/android/app/debug.keystore
--------------------------------------------------------------------------------
/test/.buckconfig:
--------------------------------------------------------------------------------
1 |
2 | [android]
3 | target = Google Inc.:Google APIs:23
4 |
5 | [maven_repositories]
6 | central = https://repo1.maven.org/maven2
7 |
--------------------------------------------------------------------------------
/test/.prettierrc.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | bracketSpacing: false,
3 | jsxBracketSameLine: true,
4 | singleQuote: true,
5 | trailingComma: 'all',
6 | };
7 |
--------------------------------------------------------------------------------
/test/android/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuC520/react-native-scrollable-tab-view-forked/HEAD/test/android/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/test/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuC520/react-native-scrollable-tab-view-forked/HEAD/test/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/test/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuC520/react-native-scrollable-tab-view-forked/HEAD/test/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/test/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuC520/react-native-scrollable-tab-view-forked/HEAD/test/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/test/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuC520/react-native-scrollable-tab-view-forked/HEAD/test/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/test/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuC520/react-native-scrollable-tab-view-forked/HEAD/test/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/test/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuC520/react-native-scrollable-tab-view-forked/HEAD/test/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/test/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuC520/react-native-scrollable-tab-view-forked/HEAD/test/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/test/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuC520/react-native-scrollable-tab-view-forked/HEAD/test/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/test/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuC520/react-native-scrollable-tab-view-forked/HEAD/test/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/test/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiuC520/react-native-scrollable-tab-view-forked/HEAD/test/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/test/index.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @format
3 | */
4 |
5 | import {AppRegistry} from 'react-native';
6 | import App from './App';
7 | import {name as appName} from './app.json';
8 |
9 | AppRegistry.registerComponent(appName, () => App);
10 |
--------------------------------------------------------------------------------
/test/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/Button.ios.js:
--------------------------------------------------------------------------------
1 | const React = require("react");
2 | const ReactNative = require("react-native");
3 | const { TouchableOpacity } = ReactNative;
4 |
5 | const Button = props => {
6 | return {props.children};
7 | };
8 |
9 | module.exports = Button;
10 |
--------------------------------------------------------------------------------
/test/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/test/__tests__/App-test.js:
--------------------------------------------------------------------------------
1 | /**
2 | * @format
3 | */
4 |
5 | import 'react-native';
6 | import React from 'react';
7 | import App from '../App';
8 |
9 | // Note: test renderer must be required after react-native.
10 | import renderer from 'react-test-renderer';
11 |
12 | it('renders correctly', () => {
13 | renderer.create();
14 | });
15 |
--------------------------------------------------------------------------------
/test/android/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'test'include ':react-native-pager-view'
2 | project(':react-native-pager-view').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-pager-view/android')
3 | apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings)
4 | include ':app'
5 |
--------------------------------------------------------------------------------
/test/metro.config.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Metro configuration for React Native
3 | * https://github.com/facebook/react-native
4 | *
5 | * @format
6 | */
7 |
8 | module.exports = {
9 | transformer: {
10 | getTransformOptions: async () => ({
11 | transform: {
12 | experimentalImportSupport: false,
13 | inlineRequires: false,
14 | },
15 | }),
16 | },
17 | };
18 |
--------------------------------------------------------------------------------
/test/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/test/android/app/src/main/java/com/test/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.test;
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. This is used to schedule
9 | * rendering of the component.
10 | */
11 | @Override
12 | protected String getMainComponentName() {
13 | return "test";
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/test/ios/test/AppDelegate.h:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) Facebook, Inc. and its affiliates.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file in the root directory of this source tree.
6 | */
7 |
8 | #import
9 | #import
10 |
11 | @interface AppDelegate : UIResponder
12 |
13 | @property (nonatomic, strong) UIWindow *window;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/test/ios/test/main.m:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) Facebook, Inc. and its affiliates.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file in the root directory of this source tree.
6 | */
7 |
8 | #import
9 |
10 | #import "AppDelegate.h"
11 |
12 | int main(int argc, char * argv[]) {
13 | @autoreleasepool {
14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class]));
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/StaticContainer.js:
--------------------------------------------------------------------------------
1 | const React = require('react');
2 |
3 | class StaticContainer extends React.Component {
4 |
5 | shouldComponentUpdate(nextProps: Object): boolean {
6 | return !!nextProps.shouldUpdate;
7 | }
8 |
9 | render(): ?ReactElement {
10 | var child = this.props.children;
11 | if (child === null || child === false) {
12 | return null;
13 | }
14 | return React.Children.only(child);
15 | }
16 |
17 | }
18 |
19 | module.exports = StaticContainer;
20 |
--------------------------------------------------------------------------------
/test/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 |
--------------------------------------------------------------------------------
/Button.android.js:
--------------------------------------------------------------------------------
1 | const React = require("react");
2 | const ReactNative = require("react-native");
3 | const { TouchableNativeFeedback, View } = ReactNative;
4 |
5 | const Button = props => {
6 | return (
7 |
12 | {props.children}
13 |
14 | );
15 | };
16 |
17 | module.exports = Button;
18 |
--------------------------------------------------------------------------------
/test/android/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | android
4 | Project android created by Buildship.
5 |
6 |
7 |
8 |
9 | org.eclipse.buildship.core.gradleprojectbuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.buildship.core.gradleprojectnature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/example/android/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | test0_57_7
4 | Project android created by Buildship.
5 |
6 |
7 |
8 |
9 | org.eclipse.buildship.core.gradleprojectbuilder
10 |
11 |
12 |
13 |
14 |
15 | org.eclipse.buildship.core.gradleprojectnature
16 |
17 |
18 |
--------------------------------------------------------------------------------
/SceneComponent.js:
--------------------------------------------------------------------------------
1 | const React = require('react');
2 | const ReactNative = require('react-native');
3 | const {Component, } = React;
4 | const {View, StyleSheet, } = ReactNative;
5 |
6 | const StaticContainer = require('./StaticContainer');
7 |
8 | const SceneComponent = (Props) => {
9 | const {shouldUpdated, ...props } = Props;
10 | return
11 |
12 | {props.children}
13 |
14 | ;
15 | };
16 |
17 | module.exports = SceneComponent;
18 |
--------------------------------------------------------------------------------
/test/android/app/build_defs.bzl:
--------------------------------------------------------------------------------
1 | """Helper definitions to glob .aar and .jar targets"""
2 |
3 | def create_aar_targets(aarfiles):
4 | for aarfile in aarfiles:
5 | name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")]
6 | lib_deps.append(":" + name)
7 | android_prebuilt_aar(
8 | name = name,
9 | aar = aarfile,
10 | )
11 |
12 | def create_jar_targets(jarfiles):
13 | for jarfile in jarfiles:
14 | name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")]
15 | lib_deps.append(":" + name)
16 | prebuilt_jar(
17 | name = name,
18 | binary_jar = jarfile,
19 | )
20 |
--------------------------------------------------------------------------------
/example/android/app/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | app
4 | Project app created by Buildship.
5 |
6 |
7 |
8 |
9 | org.eclipse.jdt.core.javabuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.buildship.core.gradleprojectbuilder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.jdt.core.javanature
21 | org.eclipse.buildship.core.gradleprojectnature
22 |
23 |
24 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "react-native-scrollable-tab-view-forked",
3 | "version": "1.1.4",
4 | "description": "forked react-native-scrollable-tab-view ,you can set line width",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "liucheng",
10 | "license": "MIT",
11 | "bundleDependencies": false,
12 | "dependencies": {
13 | "create-react-class": "^15.6.2",
14 | "prop-types": "^15.6.0",
15 | "react-timer-mixin": "^0.13.3",
16 | "react-native-pager-view": "^5.4.0"
17 | },
18 | "keywords": [
19 | "react-native-component",
20 | "react-component",
21 | "react-native",
22 | "ios",
23 | "tab",
24 | "scrollable"
25 | ]
26 | }
--------------------------------------------------------------------------------
/test/ios/test/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 | }
--------------------------------------------------------------------------------
/test/ios/testTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
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 |
--------------------------------------------------------------------------------
/test/ios/test-tvOSTests/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 |
--------------------------------------------------------------------------------
/test/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "test",
3 | "version": "0.0.1",
4 | "private": true,
5 | "scripts": {
6 | "android": "react-native run-android",
7 | "ios": "react-native run-ios",
8 | "start": "react-native start",
9 | "test": "jest",
10 | "lint": "eslint ."
11 | },
12 | "dependencies": {
13 | "@react-native-community/viewpager": "^1.1.7",
14 | "react": "16.9.0",
15 | "react-native": "0.61.1",
16 | "react-native-scrollable-tab-view-forked": "^1.0.3"
17 | },
18 | "devDependencies": {
19 | "@babel/core": "^7.6.2",
20 | "@babel/runtime": "^7.6.2",
21 | "@react-native-community/eslint-config": "^0.0.5",
22 | "babel-jest": "^24.9.0",
23 | "eslint": "^6.4.0",
24 | "jest": "^24.9.0",
25 | "metro-react-native-babel-preset": "^0.56.0",
26 | "react-test-renderer": "16.9.0"
27 | },
28 | "jest": {
29 | "preset": "react-native"
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/test/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.useAndroidX=true
21 | android.enableJetifier=true
22 |
--------------------------------------------------------------------------------
/test/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
6 |
13 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/test/android/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | ext {
5 | buildToolsVersion = "28.0.3"
6 | minSdkVersion = 16
7 | compileSdkVersion = 28
8 | targetSdkVersion = 28
9 | }
10 | repositories {
11 | google()
12 | jcenter()
13 | }
14 | dependencies {
15 | classpath("com.android.tools.build:gradle:3.4.2")
16 |
17 | // NOTE: Do not place your application dependencies here; they belong
18 | // in the individual module build.gradle files
19 | }
20 | }
21 |
22 | allprojects {
23 | repositories {
24 | mavenLocal()
25 | maven {
26 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
27 | url("$rootDir/../node_modules/react-native/android")
28 | }
29 | maven {
30 | // Android JSC is installed from npm
31 | url("$rootDir/../node_modules/jsc-android/dist")
32 | }
33 |
34 | google()
35 | jcenter()
36 | maven { url 'https://jitpack.io' }
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/test/android/app/BUCK:
--------------------------------------------------------------------------------
1 | # To learn about Buck see [Docs](https://buckbuild.com/).
2 | # To run your application with Buck:
3 | # - install Buck
4 | # - `npm start` - to start the packager
5 | # - `cd android`
6 | # - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US"`
7 | # - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck
8 | # - `buck install -r android/app` - compile, install and run application
9 | #
10 |
11 | load(":build_defs.bzl", "create_aar_targets", "create_jar_targets")
12 |
13 | lib_deps = []
14 |
15 | create_aar_targets(glob(["libs/*.aar"]))
16 |
17 | create_jar_targets(glob(["libs/*.jar"]))
18 |
19 | android_library(
20 | name = "all-libs",
21 | exported_deps = lib_deps,
22 | )
23 |
24 | android_library(
25 | name = "app-code",
26 | srcs = glob([
27 | "src/main/java/**/*.java",
28 | ]),
29 | deps = [
30 | ":all-libs",
31 | ":build_config",
32 | ":res",
33 | ],
34 | )
35 |
36 | android_build_config(
37 | name = "build_config",
38 | package = "com.test",
39 | )
40 |
41 | android_resource(
42 | name = "res",
43 | package = "com.test",
44 | res = "src/main/res",
45 | )
46 |
47 | android_binary(
48 | name = "app",
49 | keystore = "//android/keystores:debug",
50 | manifest = "src/main/AndroidManifest.xml",
51 | package_type = "debug",
52 | deps = [
53 | ":app-code",
54 | ],
55 | )
56 |
--------------------------------------------------------------------------------
/test/ios/test/AppDelegate.m:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) Facebook, Inc. and its affiliates.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file in the root directory of this source tree.
6 | */
7 |
8 | #import "AppDelegate.h"
9 |
10 | #import
11 | #import
12 | #import
13 |
14 | @implementation AppDelegate
15 |
16 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
17 | {
18 | RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
19 | RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
20 | moduleName:@"test"
21 | initialProperties:nil];
22 |
23 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];
24 |
25 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
26 | UIViewController *rootViewController = [UIViewController new];
27 | rootViewController.view = rootView;
28 | self.window.rootViewController = rootViewController;
29 | [self.window makeKeyAndVisible];
30 | return YES;
31 | }
32 |
33 | - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
34 | {
35 | #if DEBUG
36 | return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
37 | #else
38 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
39 | #endif
40 | }
41 |
42 | @end
43 |
--------------------------------------------------------------------------------
/test/ios/test-tvOS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
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 | NSAppTransportSecurity
26 |
27 | NSExceptionDomains
28 |
29 | localhost
30 |
31 | NSExceptionAllowsInsecureHTTPLoads
32 |
33 |
34 |
35 |
36 | NSLocationWhenInUseUsageDescription
37 |
38 | UILaunchStoryboardName
39 | LaunchScreen
40 | UIRequiredDeviceCapabilities
41 |
42 | armv7
43 |
44 | UISupportedInterfaceOrientations
45 |
46 | UIInterfaceOrientationPortrait
47 | UIInterfaceOrientationLandscapeLeft
48 | UIInterfaceOrientationLandscapeRight
49 |
50 | UIViewControllerBasedStatusBarAppearance
51 |
52 |
53 |
54 |
--------------------------------------------------------------------------------
/test/ios/test/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleDisplayName
8 | test
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1
25 | LSRequiresIPhoneOS
26 |
27 | NSAppTransportSecurity
28 |
29 | NSAllowsArbitraryLoads
30 |
31 | NSExceptionDomains
32 |
33 | localhost
34 |
35 | NSExceptionAllowsInsecureHTTPLoads
36 |
37 |
38 |
39 |
40 | NSLocationWhenInUseUsageDescription
41 |
42 | UILaunchStoryboardName
43 | LaunchScreen
44 | UIRequiredDeviceCapabilities
45 |
46 | armv7
47 |
48 | UISupportedInterfaceOrientations
49 |
50 | UIInterfaceOrientationPortrait
51 | UIInterfaceOrientationLandscapeLeft
52 | UIInterfaceOrientationLandscapeRight
53 |
54 | UIViewControllerBasedStatusBarAppearance
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/test/App.js:
--------------------------------------------------------------------------------
1 | /*
2 | * @PageName: 页面名称
3 | * @Description:
4 | * @Author: 刘成
5 | * @Date: 2019-09-27 16:09:20
6 | * @LastEditTime: 2019-09-27 16:09:20
7 | * @LastEditors: 刘成
8 | */
9 |
10 | /**
11 | * Sample React Native App
12 | * https://github.com/facebook/react-native
13 | *
14 | * @format
15 | * @flow
16 | */
17 |
18 | import React, {Component} from 'react';
19 | import {Platform, StyleSheet, Text, View} from 'react-native';
20 | import ScrollableTabView, { DefaultTabBar, ScrollableTabBar } from 'react-native-scrollable-tab-view-forked'
21 |
22 | export default class App extends Component {
23 | render() {
24 | return (
25 | (
27 |
31 | )}
32 | tabBarTextStyle={styles.tabBarTextStyle}
33 | tabBarInactiveTextColor={'black'}
34 | tabBarActiveTextColor={'red'}
35 | tabBarUnderlineStyle={styles.underlineStyle}
36 | initialPage={2}
37 | // containerWidth={200}
38 | >
39 |
40 |
41 |
42 |
43 |
44 | );
45 | }
46 | }
47 |
48 | const styles = StyleSheet.create({
49 | tabStyle: {},
50 | scrollStyle: {
51 | backgroundColor: 'white',
52 | // paddingLeft: 65,
53 | // paddingRight: 65,
54 | // justifyContent: 'center',
55 | },
56 | tabBarTextStyle: {
57 | fontSize: 14,
58 | fontWeight: 'normal',
59 | },
60 | underlineStyle: {
61 | height: 3,
62 | backgroundColor: 'red',
63 | borderRadius: 3,
64 | width: 15,
65 | },
66 | });
67 |
--------------------------------------------------------------------------------
/test/ios/testTests/testTests.m:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright (c) Facebook, Inc. and its affiliates.
3 | *
4 | * This source code is licensed under the MIT license found in the
5 | * LICENSE file in the root directory of this source tree.
6 | */
7 |
8 | #import
9 | #import
10 |
11 | #import
12 | #import
13 |
14 | #define TIMEOUT_SECONDS 600
15 | #define TEXT_TO_LOOK_FOR @"Welcome to React"
16 |
17 | @interface testTests : XCTestCase
18 |
19 | @end
20 |
21 | @implementation testTests
22 |
23 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test
24 | {
25 | if (test(view)) {
26 | return YES;
27 | }
28 | for (UIView *subview in [view subviews]) {
29 | if ([self findSubviewInView:subview matching:test]) {
30 | return YES;
31 | }
32 | }
33 | return NO;
34 | }
35 |
36 | - (void)testRendersWelcomeScreen
37 | {
38 | UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController];
39 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS];
40 | BOOL foundElement = NO;
41 |
42 | __block NSString *redboxError = nil;
43 | #ifdef DEBUG
44 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) {
45 | if (level >= RCTLogLevelError) {
46 | redboxError = message;
47 | }
48 | });
49 | #endif
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 | #ifdef DEBUG
64 | RCTSetLogFunction(RCTDefaultLogFunction);
65 | #endif
66 |
67 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError);
68 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS);
69 | }
70 |
71 |
72 | @end
73 |
--------------------------------------------------------------------------------
/test/.flowconfig:
--------------------------------------------------------------------------------
1 | [ignore]
2 | ; We fork some components by platform
3 | .*/*[.]android.js
4 |
5 | ; Ignore "BUCK" generated dirs
6 | /\.buckd/
7 |
8 | ; Ignore polyfills
9 | node_modules/react-native/Libraries/polyfills/.*
10 |
11 | ; These should not be required directly
12 | ; require from fbjs/lib instead: require('fbjs/lib/warning')
13 | node_modules/warning/.*
14 |
15 | ; Flow doesn't support platforms
16 | .*/Libraries/Utilities/LoadingView.js
17 |
18 | [untyped]
19 | .*/node_modules/@react-native-community/cli/.*/.*
20 |
21 | [include]
22 |
23 | [libs]
24 | node_modules/react-native/Libraries/react-native/react-native-interface.js
25 | node_modules/react-native/flow/
26 |
27 | [options]
28 | emoji=true
29 |
30 | esproposal.optional_chaining=enable
31 | esproposal.nullish_coalescing=enable
32 |
33 | module.file_ext=.js
34 | module.file_ext=.json
35 | module.file_ext=.ios.js
36 |
37 | munge_underscores=true
38 |
39 | module.name_mapper='^react-native$' -> '/node_modules/react-native/Libraries/react-native/react-native-implementation'
40 | module.name_mapper='^react-native/\(.*\)$' -> '/node_modules/react-native/\1'
41 | 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\)$' -> '/node_modules/react-native/Libraries/Image/RelativeImageStub'
42 |
43 | suppress_type=$FlowIssue
44 | suppress_type=$FlowFixMe
45 | suppress_type=$FlowFixMeProps
46 | suppress_type=$FlowFixMeState
47 |
48 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
49 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
50 | suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
51 |
52 | [lints]
53 | sketchy-null-number=warn
54 | sketchy-null-mixed=warn
55 | sketchy-number=warn
56 | untyped-type-import=warn
57 | nonstrict-import=warn
58 | deprecated-type=warn
59 | unsafe-getters-setters=warn
60 | inexact-spread=warn
61 | unnecessary-invariant=warn
62 | signature-verification-failure=warn
63 | deprecated-utility=error
64 |
65 | [strict]
66 | deprecated-type
67 | nonstrict-import
68 | sketchy-null
69 | unclear-type
70 | unsafe-getters-setters
71 | untyped-import
72 | untyped-type-import
73 |
74 | [version]
75 | ^0.105.0
76 |
--------------------------------------------------------------------------------
/test/android/app/src/main/java/com/test/MainApplication.java:
--------------------------------------------------------------------------------
1 | package com.test;
2 |
3 | import android.app.Application;
4 | import android.content.Context;
5 | import com.facebook.react.PackageList;
6 | import com.facebook.react.ReactApplication;
7 | import com.reactnativecommunity.viewpager.RNCViewPagerPackage;
8 | import com.facebook.react.ReactNativeHost;
9 | import com.facebook.react.ReactPackage;
10 | import com.facebook.soloader.SoLoader;
11 | import java.lang.reflect.InvocationTargetException;
12 | import java.util.List;
13 |
14 | public class MainApplication extends Application implements ReactApplication {
15 |
16 | private final ReactNativeHost mReactNativeHost =
17 | new ReactNativeHost(this) {
18 | @Override
19 | public boolean getUseDeveloperSupport() {
20 | return BuildConfig.DEBUG;
21 | }
22 |
23 | @Override
24 | protected List getPackages() {
25 | @SuppressWarnings("UnnecessaryLocalVariable")
26 | List packages = new PackageList(this).getPackages();
27 | // Packages that cannot be autolinked yet can be added manually here, for example:
28 | // packages.add(new MyReactNativePackage());
29 | return packages;
30 | }
31 |
32 | @Override
33 | protected String getJSMainModuleName() {
34 | return "index";
35 | }
36 | };
37 |
38 | @Override
39 | public ReactNativeHost getReactNativeHost() {
40 | return mReactNativeHost;
41 | }
42 |
43 | @Override
44 | public void onCreate() {
45 | super.onCreate();
46 | SoLoader.init(this, /* native exopackage */ false);
47 | initializeFlipper(this); // Remove this line if you don't want Flipper enabled
48 | }
49 |
50 | /**
51 | * Loads Flipper in React Native templates.
52 | *
53 | * @param context
54 | */
55 | private static void initializeFlipper(Context context) {
56 | if (BuildConfig.DEBUG) {
57 | try {
58 | /*
59 | We use reflection here to pick up the class that initializes Flipper,
60 | since Flipper library is not available in release mode
61 | */
62 | Class> aClass = Class.forName("com.facebook.flipper.ReactNativeFlipper");
63 | aClass.getMethod("initializeFlipper", Context.class).invoke(null, context);
64 | } catch (ClassNotFoundException e) {
65 | e.printStackTrace();
66 | } catch (NoSuchMethodException e) {
67 | e.printStackTrace();
68 | } catch (IllegalAccessException e) {
69 | e.printStackTrace();
70 | } catch (InvocationTargetException e) {
71 | e.printStackTrace();
72 | }
73 | }
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/test/ios/Podfile:
--------------------------------------------------------------------------------
1 | platform :ios, '9.0'
2 | require_relative '../node_modules/@react-native-community/cli-platform-ios/native_modules'
3 |
4 | target 'test' do
5 | # Pods for test
6 | pod 'FBLazyVector', :path => "../node_modules/react-native/Libraries/FBLazyVector"
7 | pod 'FBReactNativeSpec', :path => "../node_modules/react-native/Libraries/FBReactNativeSpec"
8 | pod 'RCTRequired', :path => "../node_modules/react-native/Libraries/RCTRequired"
9 | pod 'RCTTypeSafety', :path => "../node_modules/react-native/Libraries/TypeSafety"
10 | pod 'React', :path => '../node_modules/react-native/'
11 | pod 'React-Core', :path => '../node_modules/react-native/'
12 | pod 'React-CoreModules', :path => '../node_modules/react-native/React/CoreModules'
13 | pod 'React-Core/DevSupport', :path => '../node_modules/react-native/'
14 | pod 'React-RCTActionSheet', :path => '../node_modules/react-native/Libraries/ActionSheetIOS'
15 | pod 'React-RCTAnimation', :path => '../node_modules/react-native/Libraries/NativeAnimation'
16 | pod 'React-RCTBlob', :path => '../node_modules/react-native/Libraries/Blob'
17 | pod 'React-RCTImage', :path => '../node_modules/react-native/Libraries/Image'
18 | pod 'React-RCTLinking', :path => '../node_modules/react-native/Libraries/LinkingIOS'
19 | pod 'React-RCTNetwork', :path => '../node_modules/react-native/Libraries/Network'
20 | pod 'React-RCTSettings', :path => '../node_modules/react-native/Libraries/Settings'
21 | pod 'React-RCTText', :path => '../node_modules/react-native/Libraries/Text'
22 | pod 'React-RCTVibration', :path => '../node_modules/react-native/Libraries/Vibration'
23 | pod 'React-Core/RCTWebSocket', :path => '../node_modules/react-native/'
24 |
25 | pod 'React-cxxreact', :path => '../node_modules/react-native/ReactCommon/cxxreact'
26 | pod 'React-jsi', :path => '../node_modules/react-native/ReactCommon/jsi'
27 | pod 'React-jsiexecutor', :path => '../node_modules/react-native/ReactCommon/jsiexecutor'
28 | pod 'React-jsinspector', :path => '../node_modules/react-native/ReactCommon/jsinspector'
29 | pod 'ReactCommon/jscallinvoker', :path => "../node_modules/react-native/ReactCommon"
30 | pod 'ReactCommon/turbomodule/core', :path => "../node_modules/react-native/ReactCommon"
31 | pod 'Yoga', :path => '../node_modules/react-native/ReactCommon/yoga'
32 |
33 | pod 'DoubleConversion', :podspec => '../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec'
34 | pod 'glog', :podspec => '../node_modules/react-native/third-party-podspecs/glog.podspec'
35 | pod 'Folly', :podspec => '../node_modules/react-native/third-party-podspecs/Folly.podspec'
36 |
37 | pod 'react-native-pager-view', :path => '../node_modules/react-native-pager-view'
38 |
39 | target 'testTests' do
40 | inherit! :search_paths
41 | # Pods for testing
42 | end
43 |
44 | use_native_modules!
45 | end
46 |
47 | target 'test-tvOS' do
48 | # Pods for test-tvOS
49 |
50 | target 'test-tvOSTests' do
51 | inherit! :search_paths
52 | # Pods for testing
53 | end
54 |
55 | end
56 |
--------------------------------------------------------------------------------
/test/android/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem http://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%" == "" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%" == "" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
34 |
35 | @rem Find java.exe
36 | if defined JAVA_HOME goto findJavaFromJavaHome
37 |
38 | set JAVA_EXE=java.exe
39 | %JAVA_EXE% -version >NUL 2>&1
40 | if "%ERRORLEVEL%" == "0" goto init
41 |
42 | echo.
43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
44 | echo.
45 | echo Please set the JAVA_HOME variable in your environment to match the
46 | echo location of your Java installation.
47 |
48 | goto fail
49 |
50 | :findJavaFromJavaHome
51 | set JAVA_HOME=%JAVA_HOME:"=%
52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
53 |
54 | if exist "%JAVA_EXE%" goto init
55 |
56 | echo.
57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
58 | echo.
59 | echo Please set the JAVA_HOME variable in your environment to match the
60 | echo location of your Java installation.
61 |
62 | goto fail
63 |
64 | :init
65 | @rem Get command-line arguments, handling Windows variants
66 |
67 | if not "%OS%" == "Windows_NT" goto win9xME_args
68 |
69 | :win9xME_args
70 | @rem Slurp the command line arguments.
71 | set CMD_LINE_ARGS=
72 | set _SKIP=2
73 |
74 | :win9xME_args_slurp
75 | if "x%~1" == "x" goto execute
76 |
77 | set CMD_LINE_ARGS=%*
78 |
79 | :execute
80 | @rem Setup the command line
81 |
82 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
83 |
84 | @rem Execute Gradle
85 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
86 |
87 | :end
88 | @rem End local scope for the variables with windows NT shell
89 | if "%ERRORLEVEL%"=="0" goto mainEnd
90 |
91 | :fail
92 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
93 | rem the _cmd.exe /c_ return code!
94 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
95 | exit /b 1
96 |
97 | :mainEnd
98 | if "%OS%"=="Windows_NT" endlocal
99 |
100 | :omega
101 |
--------------------------------------------------------------------------------
/test/ios/test/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 |
--------------------------------------------------------------------------------
/DefaultTabBar.js:
--------------------------------------------------------------------------------
1 |
2 | const React = require('react');
3 | const { ViewPropTypes, TouchableOpacity } = (ReactNative = require('react-native'))
4 | const PropTypes = require('prop-types');
5 | const createReactClass = require('create-react-class');
6 |
7 | const {
8 | StyleSheet,
9 | Text,
10 | View,
11 | Animated,
12 | Dimensions,
13 | } = ReactNative;
14 | // const Button = require('./Button');
15 |
16 | const DefaultTabBar = createReactClass({
17 | propTypes: {
18 | goToPage: PropTypes.func,
19 | activeTab: PropTypes.number,
20 | tabs: PropTypes.array,
21 | backgroundColor: PropTypes.string,
22 | activeTextColor: PropTypes.string,
23 | inactiveTextColor: PropTypes.string,
24 | textStyle: Text.propTypes.style,
25 | tabStyle: ViewPropTypes.style,
26 | renderTab: PropTypes.func,
27 | underlineStyle: ViewPropTypes.style,
28 | width:PropTypes.number,
29 | },
30 |
31 | getDefaultProps() {
32 | return {
33 | activeTextColor: 'navy',
34 | inactiveTextColor: 'black',
35 | backgroundColor: null,
36 | width:Dimensions.get('window').width
37 | };
38 | },
39 |
40 | renderTab(child, page, isTabActive, onPressHandler) {
41 | const { activeTextColor, inactiveTextColor, textStyle } = this.props;
42 | const textColor = isTabActive ? activeTextColor : inactiveTextColor;
43 | const fontWeight = isTabActive ? 'bold' : 'normal';
44 |
45 | return (
46 | onPressHandler(page)}
54 | >
55 |
56 | {child.tabLabel}
57 |
58 |
59 | )
60 | },
61 |
62 | /**
63 | * 刘成修改源码:
64 | * 增加tab可以固定宽度
65 | */
66 | render() {
67 | const width = this.props.width;
68 | const containerWidth = this.props.containerWidth || width;
69 | const numberOfTabs = this.props.tabs.length;
70 | const eachWidth = containerWidth / numberOfTabs
71 | const tabUnderlineStyle = {
72 | position: 'absolute',
73 | width: eachWidth,
74 | height: 4,
75 | backgroundColor: 'navy',
76 | bottom: 0,
77 | };
78 | let left = 0;
79 | if(this.props.underlineStyle && this.props.underlineStyle.width){
80 | left = eachWidth / 2 - this.props.underlineStyle.width / 2;
81 | }
82 | const translateX = this.props.scrollValue.interpolate({
83 | inputRange: [0, 1],
84 | outputRange: [0, eachWidth],
85 | });
86 | return (
87 |
93 |
94 | {this.props.tabs.map((child, page) => {
95 | const isTabActive = this.props.activeTab === page;
96 | const renderTab = this.props.renderTab || this.renderTab;
97 | return renderTab(child, page, isTabActive, this.props.goToPage);
98 | })}
99 |
100 | this.animatedLine = sl}
102 | style={[
103 | tabUnderlineStyle,
104 | {
105 | left,
106 | },
107 | {
108 | transform: [
109 | { translateX },
110 | ],
111 | },
112 | this.props.underlineStyle,
113 | ]}
114 | />
115 |
116 | );
117 | },
118 | });
119 |
120 | const styles = StyleSheet.create({
121 | tab: {
122 | flex: 1,
123 | alignItems: 'center',
124 | justifyContent: 'center',
125 | // paddingBottom: 10,
126 | },
127 | tabs: {
128 | height: 40,
129 | flexDirection: 'row',
130 | justifyContent: 'space-around',
131 | borderWidth: 0.5,
132 | borderTopWidth: 0,
133 | borderLeftWidth: 0,
134 | borderRightWidth: 0,
135 | borderColor: '#E6E6E6',
136 | },
137 | });
138 |
139 | module.exports = DefaultTabBar;
140 |
--------------------------------------------------------------------------------
/test/ios/test.xcodeproj/xcshareddata/xcschemes/test.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 |
--------------------------------------------------------------------------------
/test/ios/test.xcodeproj/xcshareddata/xcschemes/test-tvOS.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 |
--------------------------------------------------------------------------------
/test/android/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env sh
2 |
3 | #
4 | # Copyright 2015 the original author or authors.
5 | #
6 | # Licensed under the Apache License, Version 2.0 (the "License");
7 | # you may not use this file except in compliance with the License.
8 | # You may obtain a copy of the License at
9 | #
10 | # http://www.apache.org/licenses/LICENSE-2.0
11 | #
12 | # Unless required by applicable law or agreed to in writing, software
13 | # distributed under the License is distributed on an "AS IS" BASIS,
14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 | # See the License for the specific language governing permissions and
16 | # limitations under the License.
17 | #
18 |
19 | ##############################################################################
20 | ##
21 | ## Gradle start up script for UN*X
22 | ##
23 | ##############################################################################
24 |
25 | # Attempt to set APP_HOME
26 | # Resolve links: $0 may be a link
27 | PRG="$0"
28 | # Need this for relative symlinks.
29 | while [ -h "$PRG" ] ; do
30 | ls=`ls -ld "$PRG"`
31 | link=`expr "$ls" : '.*-> \(.*\)$'`
32 | if expr "$link" : '/.*' > /dev/null; then
33 | PRG="$link"
34 | else
35 | PRG=`dirname "$PRG"`"/$link"
36 | fi
37 | done
38 | SAVED="`pwd`"
39 | cd "`dirname \"$PRG\"`/" >/dev/null
40 | APP_HOME="`pwd -P`"
41 | cd "$SAVED" >/dev/null
42 |
43 | APP_NAME="Gradle"
44 | APP_BASE_NAME=`basename "$0"`
45 |
46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
48 |
49 | # Use the maximum available, or set MAX_FD != -1 to use that value.
50 | MAX_FD="maximum"
51 |
52 | warn () {
53 | echo "$*"
54 | }
55 |
56 | die () {
57 | echo
58 | echo "$*"
59 | echo
60 | exit 1
61 | }
62 |
63 | # OS specific support (must be 'true' or 'false').
64 | cygwin=false
65 | msys=false
66 | darwin=false
67 | nonstop=false
68 | case "`uname`" in
69 | CYGWIN* )
70 | cygwin=true
71 | ;;
72 | Darwin* )
73 | darwin=true
74 | ;;
75 | MINGW* )
76 | msys=true
77 | ;;
78 | NONSTOP* )
79 | nonstop=true
80 | ;;
81 | esac
82 |
83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
84 |
85 | # Determine the Java command to use to start the JVM.
86 | if [ -n "$JAVA_HOME" ] ; then
87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
88 | # IBM's JDK on AIX uses strange locations for the executables
89 | JAVACMD="$JAVA_HOME/jre/sh/java"
90 | else
91 | JAVACMD="$JAVA_HOME/bin/java"
92 | fi
93 | if [ ! -x "$JAVACMD" ] ; then
94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
95 |
96 | Please set the JAVA_HOME variable in your environment to match the
97 | location of your Java installation."
98 | fi
99 | else
100 | JAVACMD="java"
101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
102 |
103 | Please set the JAVA_HOME variable in your environment to match the
104 | location of your Java installation."
105 | fi
106 |
107 | # Increase the maximum file descriptors if we can.
108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
109 | MAX_FD_LIMIT=`ulimit -H -n`
110 | if [ $? -eq 0 ] ; then
111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
112 | MAX_FD="$MAX_FD_LIMIT"
113 | fi
114 | ulimit -n $MAX_FD
115 | if [ $? -ne 0 ] ; then
116 | warn "Could not set maximum file descriptor limit: $MAX_FD"
117 | fi
118 | else
119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
120 | fi
121 | fi
122 |
123 | # For Darwin, add options to specify how the application appears in the dock
124 | if $darwin; then
125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
126 | fi
127 |
128 | # For Cygwin, switch paths to Windows format before running java
129 | if $cygwin ; then
130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
132 | JAVACMD=`cygpath --unix "$JAVACMD"`
133 |
134 | # We build the pattern for arguments to be converted via cygpath
135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
136 | SEP=""
137 | for dir in $ROOTDIRSRAW ; do
138 | ROOTDIRS="$ROOTDIRS$SEP$dir"
139 | SEP="|"
140 | done
141 | OURCYGPATTERN="(^($ROOTDIRS))"
142 | # Add a user-defined pattern to the cygpath arguments
143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
145 | fi
146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
147 | i=0
148 | for arg in "$@" ; do
149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
151 |
152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
154 | else
155 | eval `echo args$i`="\"$arg\""
156 | fi
157 | i=$((i+1))
158 | done
159 | case $i in
160 | (0) set -- ;;
161 | (1) set -- "$args0" ;;
162 | (2) set -- "$args0" "$args1" ;;
163 | (3) set -- "$args0" "$args1" "$args2" ;;
164 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
165 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
166 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
167 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
168 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
169 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
170 | esac
171 | fi
172 |
173 | # Escape application args
174 | save () {
175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
176 | echo " "
177 | }
178 | APP_ARGS=$(save "$@")
179 |
180 | # Collect all arguments for the java command, following the shell quoting and substitution rules
181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
182 |
183 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
184 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
185 | cd "$(dirname "$0")"
186 | fi
187 |
188 | exec "$JAVACMD" "$@"
189 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
9 |
10 | ## react-native-scrollable-tab-view-forked
11 | [](https://badge.fury.io/js/react-native-scrollable-tab-view-forked)
12 |
13 | This is probably my favorite navigation pattern on Android, I wish it
14 | were more common on iOS! This is a very simple JavaScript-only
15 | implementation of it for React Native. For more information about how
16 | the animations behind this work, check out the Rebound section of the
17 | [React Native Animation Guide](https://facebook.github.io/react-native/docs/animations.html)
18 |
19 | ## add , set line width
20 | ## add , fix defaulttabbar's width
21 | ## add , can set DefaultTabBar's width
22 | ## add , can set ScrollableTabBar's width
23 |
24 |
25 |
26 | ## Add it to your project
27 |
28 | 1. Run `npm install react-native-scrollable-tab-view-forked --save`
29 | 2. `import ScrollableTabView, { DefaultTabBar, ScrollableTabBar } from 'react-native-scrollable-tab-view-forked'`
30 |
31 | ## Demo
32 | 
33 |
34 | ## Basic usage
35 |
36 | ```javascript
37 |
38 | export default class App extends Component {
39 | render() {
40 | return (
41 | (
44 |
48 | )}
49 | tabBarTextStyle={styles.tabBarTextStyle}
50 | tabBarInactiveTextColor={'black'}
51 | tabBarActiveTextColor={'red'}
52 | tabBarUnderlineStyle={styles.underlineStyle}
53 | initialPage={2}
54 | >
55 |
56 |
57 |
58 |
59 |
60 | );
61 | }
62 | }
63 |
64 | const styles = StyleSheet.create({
65 | tabStyle: {},
66 | scrollStyle: {
67 | backgroundColor: 'white',
68 | paddingLeft: 65,
69 | paddingRight: 65,
70 | // justifyContent: 'center',
71 | },
72 | tabBarTextStyle: {
73 | fontSize: 14,
74 | fontWeight: 'normal',
75 | },
76 | underlineStyle: {
77 | height: 3,
78 | backgroundColor: 'red',
79 | borderRadius: 3,
80 | width: 15,
81 | },
82 | });
83 | ```
84 |
85 | ## Injecting a custom tab bar
86 |
87 | Suppose we had a custom tab bar called `CustomTabBar`, we would inject
88 | it into our `ScrollableTabView` like this:
89 |
90 | ```javascript
91 | var ScrollableTabView = require('react-native-scrollable-tab-view-forked');
92 | var CustomTabBar = require('./CustomTabBar');
93 |
94 | var App = React.createClass({
95 | render() {
96 | return (
97 | }>
98 |
99 |
100 |
101 |
102 | );
103 | }
104 | });
105 | ```
106 | To start you can just copy [DefaultTabBar](https://github.com/skv-headless/react-native-scrollable-tab-view-forked/blob/master/DefaultTabBar.js).
107 |
108 | ## Examples 示例可以参考react-native-scrollable-tab-view中的实例,用法一样
109 |
110 | [SimpleExample](https://github.com/skv-headless/react-native-scrollable-tab-view/blob/master/examples/FacebookTabsExample/SimpleExample.js).
111 |
112 | [ScrollableTabsExample](https://github.com/skv-headless/react-native-scrollable-tab-view/blob/master/examples/FacebookTabsExample/ScrollableTabsExample.js).
113 |
114 | [OverlayExample](https://github.com/skv-headless/react-native-scrollable-tab-view/blob/master/examples/FacebookTabsExample/OverlayExample.js).
115 |
116 | [FacebookExample](https://github.com/skv-headless/react-native-scrollable-tab-view/blob/master/examples/FacebookTabsExample/FacebookExample.js).
117 |
118 | ## Props
119 |
120 | - **`renderTabBar`** _(Function:ReactComponent)_ - accept 1 argument `props` and should return a component to use as
121 | the tab bar. The component has `goToPage`, `tabs`, `activeTab` and
122 | `ref` added to the props, and should implement `setAnimationValue` to
123 | be able to animate itself along with the tab content. You can manually pass the `props` to the TabBar component.
124 | - **`tabBarPosition`** _(String)_ Defaults to `"top"`.
125 | - `"bottom"` to position the tab bar below content.
126 | - `"overlayTop"` or `"overlayBottom"` for a semitransparent tab bar that overlays content. Custom tab bars must consume a style prop on their outer element to support this feature: `style={this.props.style}`.
127 | - **`onChangeTab`** _(Function)_ - function to call when tab changes, should accept 1 argument which is an Object containing two keys: `i`: the index of the tab that is selected, `ref`: the ref of the tab that is selected
128 | - **`onScroll`** _(Function)_ - function to call when the pages are sliding, should accept 1 argument which is an Float number representing the page position in the slide frame.
129 | - **`locked`** _(Bool)_ - disables horizontal dragging to scroll between tabs, default is false.
130 | - **`initialPage`** _(Integer)_ - the index of the initially selected tab, defaults to 0 === first tab.
131 | - **`page`** _(Integer)_ - set selected tab(can be buggy see [#126](https://github.com/brentvatne/react-native-scrollable-tab-view/issues/126)
132 | - **`children`** _(ReactComponents)_ - each top-level child component should have a `tabLabel` prop that can be used by the tab bar component to render out the labels. The default tab bar expects it to be a string, but you can use anything you want if you make a custom tab bar.
133 | - **`tabBarUnderlineStyle`** _([View.propTypes.style](https://facebook.github.io/react-native/docs/view.html#style))_ - style of the default tab bar's underline.
134 | can set width in tabBarUnderlineStyle.
135 | - **`tabBarBackgroundColor`** _(String)_ - color of the default tab bar's background, defaults to `white`
136 | - **`tabBarActiveTextColor`** _(String)_ - color of the default tab bar's text when active, defaults to `navy`
137 | - **`tabBarInactiveTextColor`** _(String)_ - color of the default tab bar's text when inactive, defaults to `black`
138 | - **`tabBarTextStyle`** _(Object)_ - Additional styles to the tab bar's text. Example: `{fontFamily: 'Roboto', fontSize: 15}`
139 | - **`style`** _([View.propTypes.style](https://facebook.github.io/react-native/docs/view.html#style))_
140 | - **`contentProps`** _(Object)_ - props that are applied to root `ScrollView`/`ViewPagerAndroid`. Note that overriding defaults set by the library may break functionality; see the source for details.
141 | - **`scrollWithoutAnimation`** _(Bool)_ - on tab press change tab without animation.
142 | - **`prerenderingSiblingsNumber`** _(Integer)_ - pre-render nearby # sibling, `Infinity` === render all the siblings, default to 0 === render current page.
143 |
144 | ## Contribution
145 | **Issues** are welcome. Please add a screenshot of bug and code snippet. Quickest way to solve issue is to reproduce it on one of the examples.
146 |
147 | **Pull requests** are welcome. If you want to change API or making something big better to create issue and discuss it first. Before submiting PR please run ```eslint .``` Also all eslint fixes are welcome.
148 |
149 | Please attach video or gif to PR's and issues it is super helpful.
150 |
151 | How to make video
152 |
153 | How to make gif from video
154 |
155 | ---
156 |
157 | **MIT Licensed**
158 |
--------------------------------------------------------------------------------
/test/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 | * // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
22 | * bundleCommand: "ram-bundle",
23 | *
24 | * // whether to bundle JS and assets in debug mode
25 | * bundleInDebug: false,
26 | *
27 | * // whether to bundle JS and assets in release mode
28 | * bundleInRelease: true,
29 | *
30 | * // whether to bundle JS and assets in another build variant (if configured).
31 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
32 | * // The configuration property can be in the following formats
33 | * // 'bundleIn${productFlavor}${buildType}'
34 | * // 'bundleIn${buildType}'
35 | * // bundleInFreeDebug: true,
36 | * // bundleInPaidRelease: true,
37 | * // bundleInBeta: true,
38 | *
39 | * // whether to disable dev mode in custom build variants (by default only disabled in release)
40 | * // for example: to disable dev mode in the staging build type (if configured)
41 | * devDisabledInStaging: true,
42 | * // The configuration property can be in the following formats
43 | * // 'devDisabledIn${productFlavor}${buildType}'
44 | * // 'devDisabledIn${buildType}'
45 | *
46 | * // the root of your project, i.e. where "package.json" lives
47 | * root: "../../",
48 | *
49 | * // where to put the JS bundle asset in debug mode
50 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
51 | *
52 | * // where to put the JS bundle asset in release mode
53 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release",
54 | *
55 | * // where to put drawable resources / React Native assets, e.g. the ones you use via
56 | * // require('./image.png')), in debug mode
57 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
58 | *
59 | * // where to put drawable resources / React Native assets, e.g. the ones you use via
60 | * // require('./image.png')), in release mode
61 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
62 | *
63 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means
64 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
65 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle
66 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
67 | * // for example, you might want to remove it from here.
68 | * inputExcludes: ["android/**", "ios/**"],
69 | *
70 | * // override which node gets called and with what additional arguments
71 | * nodeExecutableAndArgs: ["node"],
72 | *
73 | * // supply additional arguments to the packager
74 | * extraPackagerArgs: []
75 | * ]
76 | */
77 |
78 | project.ext.react = [
79 | entryFile: "index.js",
80 | enableHermes: false, // clean and rebuild if changing
81 | ]
82 |
83 | apply from: "../../node_modules/react-native/react.gradle"
84 |
85 | /**
86 | * Set this to true to create two separate APKs instead of one:
87 | * - An APK that only works on ARM devices
88 | * - An APK that only works on x86 devices
89 | * The advantage is the size of the APK is reduced by about 4MB.
90 | * Upload all the APKs to the Play Store and people will download
91 | * the correct one based on the CPU architecture of their device.
92 | */
93 | def enableSeparateBuildPerCPUArchitecture = false
94 |
95 | /**
96 | * Run Proguard to shrink the Java bytecode in release builds.
97 | */
98 | def enableProguardInReleaseBuilds = false
99 |
100 | /**
101 | * The preferred build flavor of JavaScriptCore.
102 | *
103 | * For example, to use the international variant, you can use:
104 | * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
105 | *
106 | * The international variant includes ICU i18n library and necessary data
107 | * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
108 | * give correct results when using with locales other than en-US. Note that
109 | * this variant is about 6MiB larger per architecture than default.
110 | */
111 | def jscFlavor = 'org.webkit:android-jsc:+'
112 |
113 | /**
114 | * Whether to enable the Hermes VM.
115 | *
116 | * This should be set on project.ext.react and mirrored here. If it is not set
117 | * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
118 | * and the benefits of using Hermes will therefore be sharply reduced.
119 | */
120 | def enableHermes = project.ext.react.get("enableHermes", false);
121 |
122 | android {
123 | compileSdkVersion rootProject.ext.compileSdkVersion
124 |
125 | compileOptions {
126 | sourceCompatibility JavaVersion.VERSION_1_8
127 | targetCompatibility JavaVersion.VERSION_1_8
128 | }
129 |
130 | defaultConfig {
131 | applicationId "com.test"
132 | minSdkVersion rootProject.ext.minSdkVersion
133 | targetSdkVersion rootProject.ext.targetSdkVersion
134 | versionCode 1
135 | versionName "1.0"
136 | }
137 | splits {
138 | abi {
139 | reset()
140 | enable enableSeparateBuildPerCPUArchitecture
141 | universalApk false // If true, also generate a universal APK
142 | include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
143 | }
144 | }
145 | signingConfigs {
146 | debug {
147 | storeFile file('debug.keystore')
148 | storePassword 'android'
149 | keyAlias 'androiddebugkey'
150 | keyPassword 'android'
151 | }
152 | }
153 | buildTypes {
154 | debug {
155 | signingConfig signingConfigs.debug
156 | }
157 | release {
158 | // Caution! In production, you need to generate your own keystore file.
159 | // see https://facebook.github.io/react-native/docs/signed-apk-android.
160 | signingConfig signingConfigs.debug
161 | minifyEnabled enableProguardInReleaseBuilds
162 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
163 | }
164 | }
165 | // applicationVariants are e.g. debug, release
166 | applicationVariants.all { variant ->
167 | variant.outputs.each { output ->
168 | // For each separate APK per architecture, set a unique version code as described here:
169 | // https://developer.android.com/studio/build/configure-apk-splits.html
170 | def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
171 | def abi = output.getFilter(OutputFile.ABI)
172 | if (abi != null) { // null for the universal-debug, universal-release variants
173 | output.versionCodeOverride =
174 | versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
175 | }
176 |
177 | }
178 | }
179 | }
180 |
181 | dependencies {
182 | implementation project(':react-native-pager-view')
183 | implementation fileTree(dir: "libs", include: ["*.jar"])
184 | implementation "com.facebook.react:react-native:+" // From node_modules
185 |
186 | if (enableHermes) {
187 | def hermesPath = "../../node_modules/hermes-engine/android/";
188 | debugImplementation files(hermesPath + "hermes-debug.aar")
189 | releaseImplementation files(hermesPath + "hermes-release.aar")
190 | } else {
191 | implementation jscFlavor
192 | }
193 | }
194 |
195 | // Run this once to be able to run the application with BUCK
196 | // puts all compile dependencies into folder libs for BUCK to use
197 | task copyDownloadableDepsToLibs(type: Copy) {
198 | from configurations.compile
199 | into 'libs'
200 | }
201 |
202 | apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
203 |
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "parser": "babel-eslint",
3 | "env": {
4 | "browser": true,
5 | "node": true,
6 | "jasmine": true
7 | },
8 | "ecmaFeatures": {
9 | "arrowFunctions": true,
10 | "blockBindings": true,
11 | "classes": true,
12 | "defaultParams": true,
13 | "destructuring": true,
14 | "forOf": true,
15 | "generators": false,
16 | "modules": true,
17 | "objectLiteralComputedProperties": true,
18 | "objectLiteralDuplicateProperties": false,
19 | "objectLiteralShorthandMethods": true,
20 | "objectLiteralShorthandProperties": true,
21 | "spread": true,
22 | "superInFunctions": true,
23 | "templateStrings": true,
24 | "jsx": true
25 | },
26 | "rules": {
27 | /**
28 | * Strict mode
29 | */
30 | // babel inserts "use strict"; for us
31 | // http://eslint.org/docs/rules/strict
32 | "strict": [2, "never"],
33 |
34 | /**
35 | * ES6
36 | */
37 | "no-var": 2, // http://eslint.org/docs/rules/no-var
38 |
39 | /**
40 | * Variables
41 | */
42 | "no-shadow": 2, // http://eslint.org/docs/rules/no-shadow
43 | "no-shadow-restricted-names": 2, // http://eslint.org/docs/rules/no-shadow-restricted-names
44 | "no-unused-vars": [0, { // http://eslint.org/docs/rules/no-unused-vars
45 | "vars": "local",
46 | "args": "after-used"
47 | }],
48 |
49 | /**
50 | * Possible errors
51 | */
52 | "comma-dangle": [2, "always"], // http://eslint.org/docs/rules/comma-dangle
53 | "no-cond-assign": [2, "always"], // http://eslint.org/docs/rules/no-cond-assign
54 | "no-console": 1, // http://eslint.org/docs/rules/no-console
55 | "no-debugger": 1, // http://eslint.org/docs/rules/no-debugger
56 | "no-alert": 1, // http://eslint.org/docs/rules/no-alert
57 | "no-constant-condition": 1, // http://eslint.org/docs/rules/no-constant-condition
58 | "no-dupe-keys": 2, // http://eslint.org/docs/rules/no-dupe-keys
59 | "no-duplicate-case": 2, // http://eslint.org/docs/rules/no-duplicate-case
60 | "no-empty": 2, // http://eslint.org/docs/rules/no-empty
61 | "no-ex-assign": 2, // http://eslint.org/docs/rules/no-ex-assign
62 | "no-extra-boolean-cast": 0, // http://eslint.org/docs/rules/no-extra-boolean-cast
63 | "no-extra-semi": 2, // http://eslint.org/docs/rules/no-extra-semi
64 | "no-func-assign": 2, // http://eslint.org/docs/rules/no-func-assign
65 | "no-inner-declarations": 2, // http://eslint.org/docs/rules/no-inner-declarations
66 | "no-invalid-regexp": 2, // http://eslint.org/docs/rules/no-invalid-regexp
67 | "no-irregular-whitespace": 2, // http://eslint.org/docs/rules/no-irregular-whitespace
68 | "no-obj-calls": 2, // http://eslint.org/docs/rules/no-obj-calls
69 | "no-reserved-keys": 0, // http://eslint.org/docs/rules/no-reserved-keys
70 | "no-sparse-arrays": 2, // http://eslint.org/docs/rules/no-sparse-arrays
71 | "no-unreachable": 2, // http://eslint.org/docs/rules/no-unreachable
72 | "use-isnan": 2, // http://eslint.org/docs/rules/use-isnan
73 | "block-scoped-var": 2, // http://eslint.org/docs/rules/block-scoped-var
74 |
75 | /**
76 | * Best practices
77 | */
78 | "consistent-return": 2, // http://eslint.org/docs/rules/consistent-return
79 | "curly": [2, "multi-line"], // http://eslint.org/docs/rules/curly
80 | "default-case": 2, // http://eslint.org/docs/rules/default-case
81 | "dot-notation": [2, { // http://eslint.org/docs/rules/dot-notation
82 | "allowKeywords": true
83 | }],
84 | "eqeqeq": 2, // http://eslint.org/docs/rules/eqeqeq
85 | "guard-for-in": 2, // http://eslint.org/docs/rules/guard-for-in
86 | "no-caller": 2, // http://eslint.org/docs/rules/no-caller
87 | "no-eq-null": 2, // http://eslint.org/docs/rules/no-eq-null
88 | "no-eval": 2, // http://eslint.org/docs/rules/no-eval
89 | "no-extend-native": 2, // http://eslint.org/docs/rules/no-extend-native
90 | "no-extra-bind": 2, // http://eslint.org/docs/rules/no-extra-bind
91 | "no-fallthrough": 2, // http://eslint.org/docs/rules/no-fallthrough
92 | "no-floating-decimal": 2, // http://eslint.org/docs/rules/no-floating-decimal
93 | "no-implied-eval": 2, // http://eslint.org/docs/rules/no-implied-eval
94 | "no-lone-blocks": 2, // http://eslint.org/docs/rules/no-lone-blocks
95 | "no-loop-func": 2, // http://eslint.org/docs/rules/no-loop-func
96 | "no-multi-str": 2, // http://eslint.org/docs/rules/no-multi-str
97 | "no-native-reassign": 2, // http://eslint.org/docs/rules/no-native-reassign
98 | "no-new": 2, // http://eslint.org/docs/rules/no-new
99 | "no-new-func": 2, // http://eslint.org/docs/rules/no-new-func
100 | "no-new-wrappers": 2, // http://eslint.org/docs/rules/no-new-wrappers
101 | "no-octal": 2, // http://eslint.org/docs/rules/no-octal
102 | "no-octal-escape": 2, // http://eslint.org/docs/rules/no-octal-escape
103 | "no-param-reassign": 2, // http://eslint.org/docs/rules/no-param-reassign
104 | "no-proto": 2, // http://eslint.org/docs/rules/no-proto
105 | "no-redeclare": 2, // http://eslint.org/docs/rules/no-redeclare
106 | "no-return-assign": 2, // http://eslint.org/docs/rules/no-return-assign
107 | "no-script-url": 2, // http://eslint.org/docs/rules/no-script-url
108 | "no-self-compare": 2, // http://eslint.org/docs/rules/no-self-compare
109 | "no-sequences": 2, // http://eslint.org/docs/rules/no-sequences
110 | "no-throw-literal": 2, // http://eslint.org/docs/rules/no-throw-literal
111 | "no-with": 2, // http://eslint.org/docs/rules/no-with
112 | "radix": 2, // http://eslint.org/docs/rules/radix
113 | "vars-on-top": 2, // http://eslint.org/docs/rules/vars-on-top
114 | "wrap-iife": [2, "any"], // http://eslint.org/docs/rules/wrap-iife
115 | "yoda": 2, // http://eslint.org/docs/rules/yoda
116 |
117 | /**
118 | * Style
119 | */
120 | "indent": [2, 2], // http://eslint.org/docs/rules/
121 | "brace-style": [2, // http://eslint.org/docs/rules/brace-style
122 | "1tbs", {
123 | "allowSingleLine": true
124 | }],
125 | "quotes": [
126 | 2, "single", "avoid-escape" // http://eslint.org/docs/rules/quotes
127 | ],
128 | "camelcase": [2, { // http://eslint.org/docs/rules/camelcase
129 | "properties": "never"
130 | }],
131 | "comma-spacing": [2, { // http://eslint.org/docs/rules/comma-spacing
132 | "before": false,
133 | "after": true
134 | }],
135 | "comma-style": [2, "last"], // http://eslint.org/docs/rules/comma-style
136 | "eol-last": 2, // http://eslint.org/docs/rules/eol-last
137 | "func-names": 1, // http://eslint.org/docs/rules/func-names
138 | "key-spacing": [2, { // http://eslint.org/docs/rules/key-spacing
139 | "beforeColon": false,
140 | "afterColon": true
141 | }],
142 | "new-cap": [2, { // http://eslint.org/docs/rules/new-cap
143 | "newIsCap": true
144 | }],
145 | "no-multiple-empty-lines": [2, { // http://eslint.org/docs/rules/no-multiple-empty-lines
146 | "max": 2
147 | }],
148 | "no-nested-ternary": 2, // http://eslint.org/docs/rules/no-nested-ternary
149 | "no-new-object": 2, // http://eslint.org/docs/rules/no-new-object
150 | "no-spaced-func": 2, // http://eslint.org/docs/rules/no-spaced-func
151 | "no-trailing-spaces": 2, // http://eslint.org/docs/rules/no-trailing-spaces
152 | "no-extra-parens": 0, // http://eslint.org/docs/rules/no-extra-parens
153 | "no-underscore-dangle": 0, // http://eslint.org/docs/rules/no-underscore-dangle
154 | "one-var": [2, "never"], // http://eslint.org/docs/rules/one-var
155 | "padded-blocks": 0, // http://eslint.org/docs/rules/padded-blocks
156 | "semi": [2, "always"], // http://eslint.org/docs/rules/semi
157 | "semi-spacing": [2, { // http://eslint.org/docs/rules/semi-spacing
158 | "before": false,
159 | "after": true
160 | }],
161 | "keyword-spacing": 2, // http://eslint.org/docs/rules/keyword-spacing
162 | "space-before-blocks": 2, // http://eslint.org/docs/rules/space-before-blocks
163 | "space-before-function-paren": [2, "never"], // http://eslint.org/docs/rules/space-before-function-paren
164 | "space-infix-ops": 2 // http://eslint.org/docs/rules/space-infix-ops
165 | }
166 | }
167 |
--------------------------------------------------------------------------------
/ScrollableTabBar.js:
--------------------------------------------------------------------------------
1 | const React = require("react");
2 | const { ViewPropTypes } = (ReactNative = require("react-native"));
3 | const PropTypes = require("prop-types");
4 | const createReactClass = require("create-react-class");
5 |
6 | const {
7 | View,
8 | Animated,
9 | StyleSheet,
10 | ScrollView,
11 | Text,
12 | Platform,
13 | Dimensions
14 | } = ReactNative;
15 | const Button = require("./Button");
16 |
17 | const ScrollableTabBar = createReactClass({
18 | propTypes: {
19 | goToPage: PropTypes.func,
20 | activeTab: PropTypes.number,
21 | tabs: PropTypes.array,
22 | backgroundColor: PropTypes.string,
23 | activeTextColor: PropTypes.string,
24 | inactiveTextColor: PropTypes.string,
25 | scrollOffset: PropTypes.number,
26 | style: ViewPropTypes.style,
27 | tabStyle: ViewPropTypes.style,
28 | tabsContainerStyle: ViewPropTypes.style,
29 | textStyle: Text.propTypes.style,
30 | renderTab: PropTypes.func,
31 | underlineStyle: ViewPropTypes.style,
32 | onScroll: PropTypes.func,
33 | activeTextStyle: Text.propTypes.style,
34 | width: PropTypes.number
35 | },
36 |
37 | getDefaultProps() {
38 | return {
39 | scrollOffset: 52,
40 | activeTextColor: "navy",
41 | inactiveTextColor: "black",
42 | backgroundColor: null,
43 | style: {},
44 | tabStyle: {},
45 | tabsContainerStyle: {},
46 | underlineStyle: {},
47 | width: Dimensions.get("window").width
48 | };
49 | },
50 |
51 | getInitialState() {
52 | this._tabsMeasurements = [];
53 | return {
54 | _leftTabUnderline: new Animated.Value(0),
55 | _widthTabUnderline: new Animated.Value(0),
56 | _containerWidth: null,
57 | _lineWidth: 0 // 底部下划线的宽度
58 | };
59 | },
60 |
61 | componentDidMount() {
62 | this.props.scrollValue.addListener(this.updateView);
63 | console.log();
64 | },
65 | hasSetLineWidth() {
66 | if (
67 | !this.props.underlineStyle ||
68 | !typeof this.props.underlineStyle.width != "number"
69 | ) {
70 | return false;
71 | }
72 | return true;
73 | },
74 |
75 | updateView(offset) {
76 | const position = Math.floor(offset.value);
77 | const pageOffset = offset.value % 1;
78 | const tabCount = this.props.tabs.length;
79 | const lastTabPosition = tabCount - 1;
80 |
81 | if (tabCount === 0 || offset.value < 0 || offset.value > lastTabPosition) {
82 | return;
83 | }
84 |
85 | if (
86 | this.necessarilyMeasurementsCompleted(
87 | position,
88 | position === lastTabPosition
89 | )
90 | ) {
91 | this.updateTabPanel(position, pageOffset);
92 | this.updateTabUnderline(position, pageOffset, tabCount);
93 | }
94 | },
95 |
96 | necessarilyMeasurementsCompleted(position, isLastTab) {
97 | return (
98 | this._tabsMeasurements[position] &&
99 | (isLastTab || this._tabsMeasurements[position + 1]) &&
100 | this._tabContainerMeasurements &&
101 | this._containerMeasurements
102 | );
103 | },
104 |
105 | updateTabPanel(position, pageOffset) {
106 | const containerWidth = this._containerMeasurements.width;
107 | const tabWidth = this._tabsMeasurements[position].width;
108 | const nextTabMeasurements = this._tabsMeasurements[position + 1];
109 | const nextTabWidth =
110 | (nextTabMeasurements && nextTabMeasurements.width) || 0;
111 | const tabOffset = this._tabsMeasurements[position].left;
112 | const absolutePageOffset = pageOffset * tabWidth;
113 | let newScrollX = tabOffset + absolutePageOffset;
114 |
115 | // center tab and smooth tab change (for when tabWidth changes a lot between two tabs)
116 | newScrollX -=
117 | (containerWidth -
118 | (1 - pageOffset) * tabWidth -
119 | pageOffset * nextTabWidth) /
120 | 2;
121 | newScrollX = newScrollX >= 0 ? newScrollX : 0;
122 |
123 | if (Platform.OS === "android") {
124 | this._scrollView.scrollTo({ x: newScrollX, y: 0, animated: false });
125 | } else {
126 | const rightBoundScroll =
127 | this._tabContainerMeasurements.width -
128 | this._containerMeasurements.width;
129 | newScrollX =
130 | newScrollX > rightBoundScroll ? rightBoundScroll : newScrollX;
131 | this._scrollView.scrollTo({ x: newScrollX, y: 0, animated: false });
132 | }
133 | },
134 |
135 | updateTabUnderline(position, pageOffset, tabCount) {
136 | const linewidth =
137 | (this._tabsMeasurements[position].width - this.state._lineWidth) / 2;
138 | const lineLeft = this._tabsMeasurements[position].left + linewidth;
139 | const lineRight = this._tabsMeasurements[position].right + linewidth;
140 |
141 | if (position < tabCount - 1) {
142 | const nextTabLeft = this._tabsMeasurements[position + 1].left;
143 | const nextTabRight = this._tabsMeasurements[position + 1].right;
144 |
145 | const newLineLeft =
146 | pageOffset * nextTabLeft + (1 - pageOffset) * lineLeft;
147 | const newLineRight =
148 | pageOffset * nextTabRight + (1 - pageOffset) * lineRight;
149 |
150 | this.state._leftTabUnderline.setValue(newLineLeft);
151 | !this.hasSetLineWidth() &&
152 | this.state._widthTabUnderline.setValue(newLineRight - newLineLeft);
153 | } else {
154 | this.state._leftTabUnderline.setValue(lineLeft);
155 | !this.hasSetLineWidth() &&
156 | this.state._widthTabUnderline.setValue(lineRight - lineLeft);
157 | }
158 | },
159 |
160 | renderTab(child, page, isTabActive, onPressHandler, onLayoutHandler) {
161 | const {
162 | activeTextColor,
163 | inactiveTextColor,
164 | textStyle,
165 | activeTextStyle = {}
166 | } = this.props;
167 | const textColor = isTabActive ? activeTextColor : inactiveTextColor;
168 | const fontWeight = isTabActive ? "bold" : "normal";
169 | const atextStyle = isTabActive ? activeTextStyle : {};
170 | return (
171 |
187 | );
188 | },
189 |
190 | measureTab(page, event) {
191 | const { x, width, height } = event.nativeEvent.layout;
192 | this._tabsMeasurements[page] = {
193 | left: x,
194 | right: x + width,
195 | width,
196 | height
197 | };
198 | this.updateView({ value: this.props.scrollValue.__getValue() });
199 | },
200 |
201 | render() {
202 | const tabUnderlineStyle = {
203 | position: "absolute",
204 | height: 4,
205 | backgroundColor: "navy",
206 | bottom: 0
207 | };
208 |
209 | const dynamicTabUnderline = {
210 | left: this.state._leftTabUnderline
211 | };
212 |
213 | /**
214 | * 如果没有设置宽度就用默认的宽度
215 | */
216 | if (!this.hasSetLineWidth()) {
217 | dynamicTabUnderline.width = this.state._widthTabUnderline;
218 | }
219 |
220 | return (
221 |
229 | {
231 | this._scrollView = scrollView;
232 | }}
233 | horizontal
234 | showsHorizontalScrollIndicator={false}
235 | showsVerticalScrollIndicator={false}
236 | directionalLockEnabled
237 | bounces={false}
238 | scrollsToTop={false}
239 | onScroll={this.props.onScroll}
240 | scrollEventThrottle={16}
241 | >
242 |
251 | {this.props.tabs.map((child, page) => {
252 | const isTabActive = this.props.activeTab === page;
253 | const renderTab = this.props.renderTab || this.renderTab;
254 | return renderTab(
255 | child,
256 | page,
257 | isTabActive,
258 | this.props.goToPage,
259 | this.measureTab.bind(this, page)
260 | );
261 | })}
262 | {
269 | this._tabline = r;
270 | }}
271 | onLayout={({ nativeEvent: e }) => {
272 | that = this;
273 | this.setState({ _lineWidth: e.layout.width }, function() {
274 | that.updateView({
275 | value: that.props.scrollValue.__getValue()
276 | });
277 | });
278 | }}
279 | />
280 |
281 |
282 |
283 | );
284 | },
285 |
286 | componentWillReceiveProps(nextProps) {
287 | // If the tabs change, force the width of the tabs container to be recalculated
288 | if (
289 | JSON.stringify(this.props.tabs) !== JSON.stringify(nextProps.tabs) &&
290 | this.state._containerWidth
291 | ) {
292 | this.setState({ _containerWidth: null });
293 | }
294 | },
295 |
296 | onTabContainerLayout(e) {
297 | this._tabContainerMeasurements = e.nativeEvent.layout;
298 | let width = this._tabContainerMeasurements.width;
299 | if (width < this.props.width) {
300 | width = this.props.width;
301 | }
302 | this.setState({ _containerWidth: width });
303 | this.updateView({ value: this.props.scrollValue.__getValue() });
304 | },
305 |
306 | onContainerLayout(e) {
307 | this._containerMeasurements = e.nativeEvent.layout;
308 | this.updateView({ value: this.props.scrollValue.__getValue() });
309 | }
310 | });
311 |
312 | module.exports = ScrollableTabBar;
313 |
314 | const styles = StyleSheet.create({
315 | tab: {
316 | height: 49,
317 | alignItems: "center",
318 | justifyContent: "center",
319 | paddingLeft: 20,
320 | paddingRight: 20
321 | },
322 | container: {
323 | height: 50,
324 | borderWidth: 1,
325 | borderTopWidth: 0,
326 | borderLeftWidth: 0,
327 | borderRightWidth: 0,
328 | borderColor: "#ccc"
329 | },
330 | tabs: {
331 | flexDirection: "row",
332 | justifyContent: "space-around"
333 | }
334 | });
335 |
--------------------------------------------------------------------------------
/ScrollPager.js:
--------------------------------------------------------------------------------
1 |
2 | const React = require('react')
3 |
4 | const { Component } = React
5 | const { ViewPropTypes } = ReactNative = require('react-native')
6 | const createReactClass = require('create-react-class')
7 | const PropTypes = require('prop-types')
8 |
9 | const {
10 | Dimensions,
11 | View,
12 | Animated,
13 | ScrollView,
14 | Platform,
15 | StyleSheet,
16 | InteractionManager,
17 | } = ReactNative
18 | const TimerMixin = require('react-timer-mixin')
19 | import ViewPagerAndroid from "react-native-pager-view"
20 |
21 | const SceneComponent = require('./SceneComponent')
22 |
23 | const AnimatedViewPagerAndroid = Platform.OS === 'android' ?
24 | Animated.createAnimatedComponent(ViewPagerAndroid) :
25 | undefined
26 |
27 | const ScrollableTabView = createReactClass({
28 | mixins: [TimerMixin],
29 |
30 | scrollOnMountCalled: false,
31 |
32 | propTypes: {
33 | initialPage: PropTypes.number,
34 | page: PropTypes.number,
35 | onChangeTab: PropTypes.func,
36 | onScroll: PropTypes.func,
37 | style: ViewPropTypes.style,
38 | contentProps: PropTypes.object,
39 | scrollWithoutAnimation: PropTypes.bool,
40 | locked: PropTypes.bool,
41 | prerenderingSiblingsNumber: PropTypes.number,
42 | containerWidth: PropTypes.number,
43 | },
44 |
45 | getDefaultProps() {
46 | return {
47 | initialPage: 0,
48 | page: -1,
49 | onChangeTab: () => {},
50 | onScroll: () => {},
51 | contentProps: {},
52 | scrollWithoutAnimation: false,
53 | locked: false,
54 | prerenderingSiblingsNumber: 0,
55 | containerWidth: Dimensions.get('window').width,
56 | }
57 | },
58 |
59 | getInitialState() {
60 | let scrollValue
61 | let scrollXIOS
62 | let positionAndroid
63 | let offsetAndroid
64 |
65 | if (Platform.OS === 'ios') {
66 | scrollXIOS = new Animated.Value(this.props.initialPage * this.props.containerWidth)
67 | const containerWidthAnimatedValue = new Animated.Value(this.props.containerWidth)
68 | // Need to call __makeNative manually to avoid a native animated bug. See
69 | // https://github.com/facebook/react-native/pull/14435
70 | containerWidthAnimatedValue.__makeNative()
71 | scrollValue = Animated.divide(scrollXIOS, containerWidthAnimatedValue)
72 |
73 | const callListeners = this._polyfillAnimatedValue(scrollValue)
74 | scrollXIOS.addListener(({ value }) => callListeners(value / this.props.containerWidth) )
75 | } else {
76 | positionAndroid = new Animated.Value(this.props.initialPage)
77 | offsetAndroid = new Animated.Value(0)
78 | scrollValue = Animated.add(positionAndroid, offsetAndroid)
79 |
80 | const callListeners = this._polyfillAnimatedValue(scrollValue)
81 | let positionAndroidValue = this.props.initialPage
82 | let offsetAndroidValue = 0
83 | positionAndroid.addListener(({ value }) => {
84 | positionAndroidValue = value
85 | callListeners(positionAndroidValue + offsetAndroidValue)
86 | })
87 | offsetAndroid.addListener(({ value }) => {
88 | offsetAndroidValue = value
89 | callListeners(positionAndroidValue + offsetAndroidValue)
90 | })
91 | }
92 |
93 | return {
94 | currentPage: this.props.initialPage,
95 | scrollValue,
96 | scrollXIOS,
97 | positionAndroid,
98 | offsetAndroid,
99 | sceneKeys: this.newSceneKeys({ currentPage: this.props.initialPage }),
100 | }
101 | },
102 |
103 | componentWillReceiveProps(props) {
104 | if (props.children !== this.props.children) {
105 | this.updateSceneKeys({ page: this.state.currentPage, children: props.children })
106 | }
107 |
108 | if (props.page >= 0 && props.page !== this.state.currentPage) {
109 | this.goToPage(props.page)
110 | }
111 | },
112 |
113 | componentWillUnmount() {
114 | if (Platform.OS === 'ios') {
115 | this.state.scrollXIOS.removeAllListeners()
116 | } else {
117 | this.state.positionAndroid.removeAllListeners()
118 | this.state.offsetAndroid.removeAllListeners()
119 | }
120 | },
121 |
122 | goToPage(pageNumber) {
123 | if (Platform.OS === 'ios') {
124 | const offset = pageNumber * this.props.containerWidth
125 | if (this.scrollView) {
126 | this.scrollView.getNode().scrollTo({ x: offset, y: 0, animated: !this.props.scrollWithoutAnimation })
127 | }
128 | } else if (this.scrollView) {
129 | if (this.props.scrollWithoutAnimation) {
130 | this.scrollView.getNode().setPageWithoutAnimation(pageNumber)
131 | } else {
132 | this.scrollView.getNode().setPage(pageNumber)
133 | }
134 | }
135 |
136 | const currentPage = this.state.currentPage
137 | this.updateSceneKeys({
138 | page: pageNumber,
139 | callback: this._onChangeTab.bind(this, currentPage, pageNumber),
140 | })
141 | },
142 |
143 |
144 | updateSceneKeys({ page, children = this.props.children, callback = () => {} }) {
145 | const newKeys = this.newSceneKeys({ previousKeys: this.state.sceneKeys, currentPage: page, children })
146 | this.setState({ currentPage: page, sceneKeys: newKeys }, callback)
147 | },
148 |
149 | newSceneKeys({ previousKeys = [], currentPage = 0, children = this.props.children }) {
150 | const newKeys = []
151 | this._children(children).forEach((child, idx) => {
152 | const key = this._makeSceneKey(child, idx)
153 | if (this._keyExists(previousKeys, key) ||
154 | this._shouldRenderSceneKey(idx, currentPage)) {
155 | newKeys.push(key)
156 | }
157 | })
158 | return newKeys
159 | },
160 |
161 | // Animated.add and Animated.divide do not currently support listeners so
162 | // we have to polyfill it here since a lot of code depends on being able
163 | // to add a listener to `scrollValue`. See https://github.com/facebook/react-native/pull/12620.
164 | _polyfillAnimatedValue(animatedValue) {
165 | const listeners = new Set()
166 | const addListener = (listener) => {
167 | listeners.add(listener)
168 | }
169 |
170 | const removeListener = (listener) => {
171 | listeners.delete(listener)
172 | }
173 |
174 | const removeAllListeners = () => {
175 | listeners.clear()
176 | }
177 |
178 | animatedValue.addListener = addListener
179 | animatedValue.removeListener = removeListener
180 | animatedValue.removeAllListeners = removeAllListeners
181 |
182 | return value => listeners.forEach(listener => listener({ value }))
183 | },
184 |
185 | _shouldRenderSceneKey(idx, currentPageKey) {
186 | const numOfSibling = this.props.prerenderingSiblingsNumber
187 | return (idx < (currentPageKey + numOfSibling + 1) &&
188 | idx > (currentPageKey - numOfSibling - 1))
189 | },
190 |
191 | _keyExists(sceneKeys, key) {
192 | return sceneKeys.find(sceneKey => key === sceneKey)
193 | },
194 |
195 | _makeSceneKey(child, idx) {
196 | return `${child.props.tabLabel}_${ idx}`
197 | },
198 |
199 | renderScrollableContent() {
200 | if (Platform.OS === 'ios') {
201 | const scenes = this._composeScenes()
202 | return ( { this.scrollView = scrollView; }}
208 | onScroll={Animated.event(
209 | [{ nativeEvent: { contentOffset: { x: this.state.scrollXIOS, }, }, }, ],
210 | { useNativeDriver: true, listener: this._onScroll, }
211 | )}
212 | onMomentumScrollBegin={this._onMomentumScrollBeginAndEnd}
213 | onMomentumScrollEnd={this._onMomentumScrollBeginAndEnd}
214 | scrollEventThrottle={16}
215 | scrollsToTop={false}
216 | showsHorizontalScrollIndicator={false}
217 | scrollEnabled={!this.props.locked}
218 | directionalLockEnabled
219 | alwaysBounceVertical={false}
220 | keyboardDismissMode="on-drag"
221 | {...this.props.contentProps}
222 | >
223 | {scenes}
224 | );
225 | }
226 | const scenes = this._composeScenes()
227 | return ( { this.scrollView = scrollView; }}
247 | {...this.props.contentProps}
248 | >
249 | {scenes}
250 | );
251 | },
252 |
253 | _composeScenes() {
254 | return this._children().map((child, idx) => {
255 | const key = this._makeSceneKey(child, idx)
256 | return (
261 | {this._keyExists(this.state.sceneKeys, key) ? child : }
262 | )
263 | })
264 | },
265 |
266 | _onMomentumScrollBeginAndEnd(e) {
267 | const offsetX = e.nativeEvent.contentOffset.x
268 | const page = Math.round(offsetX / this.props.containerWidth)
269 | if (this.state.currentPage !== page) {
270 | this._updateSelectedPage(page)
271 | }
272 | },
273 |
274 | _updateSelectedPage(nextPage) {
275 | let localNextPage = nextPage
276 | if (typeof localNextPage === 'object') {
277 | localNextPage = nextPage.nativeEvent.position
278 | }
279 |
280 | const currentPage = this.state.currentPage
281 | this.updateSceneKeys({
282 | page: localNextPage,
283 | callback: this._onChangeTab.bind(this, currentPage, localNextPage),
284 | })
285 | },
286 |
287 | _onChangeTab(prevPage, currentPage) {
288 | this.props.onChangeTab({
289 | i: currentPage,
290 | ref: this._children()[currentPage],
291 | from: prevPage,
292 | })
293 | },
294 |
295 | _onScroll(e) {
296 | if (Platform.OS === 'ios') {
297 | const offsetX = e.nativeEvent.contentOffset.x
298 | if (offsetX === 0 && !this.scrollOnMountCalled) {
299 | this.scrollOnMountCalled = true
300 | } else {
301 | this.props.onScroll(offsetX / this.props.containerWidth)
302 | }
303 | } else {
304 | const { position, offset } = e.nativeEvent
305 | this.props.onScroll(position + offset)
306 | }
307 | },
308 |
309 | _handleLayout(e) {
310 | const { width } = e.nativeEvent.layout
311 | if (!width || width <= 0 || Math.round(width) === Math.round(this.props.containerWidth)) {
312 | return
313 | }
314 | if (Math.round(width) !== Math.round(this.props.containerWidth)) {
315 | if (Platform.OS === 'ios') {
316 | const containerWidthAnimatedValue = new Animated.Value(width)
317 | // Need to call __makeNative manually to avoid a native animated bug. See
318 | // https://github.com/facebook/react-native/pull/14435
319 | containerWidthAnimatedValue.__makeNative()
320 | scrollValue = Animated.divide(this.state.scrollXIOS, containerWidthAnimatedValue)
321 | this.setState({ containerWidth: width, scrollValue })
322 | } else {
323 | this.setState({ containerWidth: width })
324 | }
325 | this.requestAnimationFrame(() => {
326 | this.goToPage(this.state.currentPage)
327 | })
328 | }
329 | },
330 |
331 | _children(children = this.props.children) {
332 | return React.Children.map(children, child => child)
333 | },
334 |
335 | render() {
336 | return (
337 | {this.renderScrollableContent()}
338 | )
339 | },
340 | })
341 |
342 | module.exports = ScrollableTabView
343 |
344 | const styles = StyleSheet.create({
345 | container: {
346 | flex: 1,
347 | },
348 | scrollableContentAndroid: {
349 | flex: 1,
350 | },
351 | })
352 |
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | const React = require('react')
2 | const { Component } = React
3 | const { ViewPropTypes } = (ReactNative = require('react-native'))
4 | const createReactClass = require('create-react-class')
5 | const PropTypes = require('prop-types')
6 |
7 | const {
8 | Dimensions,
9 | View,
10 | Animated,
11 | ScrollView,
12 | Platform,
13 | StyleSheet,
14 |
15 | InteractionManager,
16 | } = ReactNative
17 | const ViewPagerAndroid = require('react-native-pager-view').default
18 | const TimerMixin = require('react-timer-mixin')
19 |
20 | const SceneComponent = require('./SceneComponent')
21 | const DefaultTabBar = require('./DefaultTabBar')
22 | const ScrollableTabBar = require('./ScrollableTabBar')
23 |
24 | const screenWidth = Dimensions.get('window').width
25 | const AnimatedViewPagerAndroid =
26 | Platform.OS === 'android' ? Animated.createAnimatedComponent(ViewPagerAndroid) : undefined
27 |
28 | const ScrollableTabView = createReactClass({
29 | mixins: [TimerMixin],
30 | statics: {
31 | DefaultTabBar,
32 | ScrollableTabBar,
33 | },
34 | scrollOnMountCalled: false,
35 |
36 | propTypes: {
37 | tabBarPosition: PropTypes.oneOf(['top', 'bottom', 'overlayTop', 'overlayBottom']),
38 | initialPage: PropTypes.number,
39 | page: PropTypes.number,
40 | onChangeTab: PropTypes.func,
41 | onScroll: PropTypes.func,
42 | renderTabBar: PropTypes.any,
43 | tabBarUnderlineStyle: ViewPropTypes.style,
44 | tabBarBackgroundColor: PropTypes.string,
45 | tabBarActiveTextColor: PropTypes.string,
46 | tabBarInactiveTextColor: PropTypes.string,
47 | tabBarTextStyle: PropTypes.object,
48 | style: ViewPropTypes.style,
49 | contentProps: PropTypes.object,
50 | scrollWithoutAnimation: PropTypes.bool,
51 | locked: PropTypes.bool,
52 | prerenderingSiblingsNumber: PropTypes.number,
53 | containerWidth: PropTypes.number,
54 | tabsWidth: PropTypes.number, // tabs的宽度,默认是ContainerWidth,可以自定义tabsWidth,不能修改containerWidth,修改了,ios的内容宽度就变了,android的宽度是整个屏幕宽度
55 | },
56 |
57 | getDefaultProps() {
58 | return {
59 | tabBarPosition: 'top',
60 | initialPage: 0,
61 | page: -1,
62 | onChangeTab: () => {},
63 | onScroll: () => {},
64 | contentProps: {},
65 | scrollWithoutAnimation: false,
66 | locked: false,
67 | prerenderingSiblingsNumber: 0,
68 | containerWidth: screenWidth,
69 | }
70 | },
71 |
72 | getInitialState() {
73 | let scrollValue
74 | let scrollXIOS
75 | let positionAndroid
76 | let offsetAndroid
77 |
78 | if (Platform.OS === 'ios') {
79 | scrollXIOS = new Animated.Value(this.props.initialPage * this.props.containerWidth)
80 | const containerWidthAnimatedValue = new Animated.Value(this.props.containerWidth)
81 | // Need to call __makeNative manually to avoid a native animated bug. See
82 | // https://github.com/facebook/react-native/pull/14435
83 | containerWidthAnimatedValue.__makeNative()
84 | scrollValue = Animated.divide(scrollXIOS, containerWidthAnimatedValue)
85 |
86 | const callListeners = this._polyfillAnimatedValue(scrollValue)
87 | scrollXIOS.addListener(({ value }) => callListeners(value / this.props.containerWidth))
88 | } else {
89 | positionAndroid = new Animated.Value(this.props.initialPage)
90 | offsetAndroid = new Animated.Value(0)
91 | scrollValue = Animated.add(positionAndroid, offsetAndroid)
92 |
93 | const callListeners = this._polyfillAnimatedValue(scrollValue)
94 | let positionAndroidValue = this.props.initialPage
95 | let offsetAndroidValue = 0
96 | positionAndroid.addListener(({ value }) => {
97 | positionAndroidValue = value
98 | callListeners(positionAndroidValue + offsetAndroidValue)
99 | })
100 | offsetAndroid.addListener(({ value }) => {
101 | offsetAndroidValue = value
102 | callListeners(positionAndroidValue + offsetAndroidValue)
103 | })
104 | }
105 |
106 | return {
107 | currentPage: this.props.initialPage,
108 | scrollValue,
109 | scrollXIOS,
110 | positionAndroid,
111 | offsetAndroid,
112 | containerWidth: screenWidth,
113 | sceneKeys: this.newSceneKeys({ currentPage: this.props.initialPage }),
114 | }
115 | },
116 |
117 | componentDidUpdate(prevProps) {
118 | if (this.props.children !== prevProps.children) {
119 | this.updateSceneKeys({ page: this.state.currentPage, children: this.props.children })
120 | }
121 |
122 | if (this.props.page >= 0 && this.props.page !== this.state.currentPage) {
123 | this.goToPage(this.props.page)
124 | }
125 | },
126 |
127 | componentWillUnmount() {
128 | if (Platform.OS === 'ios') {
129 | this.state.scrollXIOS.removeAllListeners()
130 | } else {
131 | this.state.positionAndroid.removeAllListeners()
132 | this.state.offsetAndroid.removeAllListeners()
133 | }
134 | },
135 |
136 | goToPage(pageNumber) {
137 | if (Platform.OS === 'ios') {
138 | const offset = pageNumber * this.props.containerWidth
139 | if (this.scrollView) {
140 | this.scrollView
141 | .getNode()
142 | .scrollTo({ x: offset, y: 0, animated: !this.props.scrollWithoutAnimation })
143 | }
144 | } else if (this.scrollView) {
145 | if (this.props.scrollWithoutAnimation) {
146 | this.scrollView.getNode().setPageWithoutAnimation(pageNumber)
147 | } else {
148 | this.scrollView.getNode().setPage(pageNumber)
149 | }
150 | }
151 |
152 | const currentPage = this.state.currentPage
153 |
154 | this.updateSceneKeys({
155 | page: pageNumber,
156 | callback: this._onChangeTab.bind(this, currentPage, pageNumber),
157 | })
158 | },
159 |
160 | renderTabBar(props) {
161 | if (this.props.renderTabBar === false) {
162 | return null
163 | } else if (this.props.renderTabBar) {
164 | return React.cloneElement(this.props.renderTabBar(props), props)
165 | }
166 | return
167 | },
168 |
169 | updateSceneKeys({ page, children = this.props.children, callback = () => {} }) {
170 | const newKeys = this.newSceneKeys({
171 | previousKeys: this.state.sceneKeys,
172 | currentPage: page,
173 | children,
174 | })
175 | this.setState({ currentPage: page, sceneKeys: newKeys }, callback)
176 | },
177 |
178 | newSceneKeys({ previousKeys = [], currentPage = 0, children = this.props.children }) {
179 | const newKeys = []
180 | this._children(children).forEach((child, idx) => {
181 | const key = this._makeSceneKey(child, idx)
182 | if (this._keyExists(previousKeys, key) || this._shouldRenderSceneKey(idx, currentPage)) {
183 | newKeys.push(key)
184 | }
185 | })
186 | return newKeys
187 | },
188 |
189 | // Animated.add and Animated.divide do not currently support listeners so
190 | // we have to polyfill it here since a lot of code depends on being able
191 | // to add a listener to `scrollValue`. See https://github.com/facebook/react-native/pull/12620.
192 | _polyfillAnimatedValue(animatedValue) {
193 | const listeners = new Set()
194 | const addListener = (listener) => {
195 | listeners.add(listener)
196 | }
197 |
198 | const removeListener = (listener) => {
199 | listeners.delete(listener)
200 | }
201 |
202 | const removeAllListeners = () => {
203 | listeners.clear()
204 | }
205 |
206 | animatedValue.addListener = addListener
207 | animatedValue.removeListener = removeListener
208 | animatedValue.removeAllListeners = removeAllListeners
209 |
210 | return (value) => listeners.forEach((listener) => listener({ value }))
211 | },
212 |
213 | _shouldRenderSceneKey(idx, currentPageKey) {
214 | const numOfSibling = this.props.prerenderingSiblingsNumber
215 | return idx < currentPageKey + numOfSibling + 1 && idx > currentPageKey - numOfSibling - 1
216 | },
217 |
218 | _keyExists(sceneKeys, key) {
219 | return sceneKeys.find((sceneKey) => key === sceneKey)
220 | },
221 |
222 | _makeSceneKey(child, idx) {
223 | return `${child.props.tabLabel}_${idx}`
224 | },
225 |
226 | renderScrollableContent() {
227 | if (Platform.OS === 'ios') {
228 | const scenes = this._composeScenes()
229 | return (
230 | {
236 | this.scrollView = scrollView
237 | }}
238 | onScroll={Animated.event(
239 | [{ nativeEvent: { contentOffset: { x: this.state.scrollXIOS } } }],
240 | { useNativeDriver: true, listener: this._onScroll }
241 | )}
242 | onMomentumScrollBegin={this._onMomentumScrollBeginAndEnd}
243 | onMomentumScrollEnd={this._onMomentumScrollBeginAndEnd}
244 | scrollEventThrottle={16}
245 | scrollsToTop={false}
246 | showsHorizontalScrollIndicator={false}
247 | scrollEnabled={!this.props.locked}
248 | directionalLockEnabled
249 | alwaysBounceVertical={false}
250 | keyboardDismissMode='on-drag'
251 | {...this.props.contentProps}
252 | >
253 | {scenes}
254 |
255 | )
256 | }
257 | const scenes = this._composeScenes()
258 | return (
259 | {
281 | this.scrollView = scrollView
282 | }}
283 | {...this.props.contentProps}
284 | >
285 | {scenes}
286 |
287 | )
288 | },
289 |
290 | _composeScenes() {
291 | return this._children().map((child, idx) => {
292 | const key = this._makeSceneKey(child, idx)
293 | return (
294 |
299 | {this._keyExists(this.state.sceneKeys, key) ? (
300 | child
301 | ) : (
302 |
303 | )}
304 |
305 | )
306 | })
307 | },
308 |
309 | _onMomentumScrollBeginAndEnd(e) {
310 | const offsetX = e.nativeEvent.contentOffset.x
311 | const page = Math.round(offsetX / this.props.containerWidth)
312 | if (this.state.currentPage !== page) {
313 | this._updateSelectedPage(page)
314 | }
315 | },
316 |
317 | _updateSelectedPage(nextPage) {
318 | let localNextPage = nextPage
319 | if (typeof localNextPage === 'object') {
320 | localNextPage = nextPage.nativeEvent.position
321 | }
322 |
323 | const currentPage = this.state.currentPage
324 | this.updateSceneKeys({
325 | page: localNextPage,
326 | callback: this._onChangeTab.bind(this, currentPage, localNextPage),
327 | })
328 | },
329 |
330 | _onChangeTab(prevPage, currentPage) {
331 | this.props.onChangeTab({
332 | i: currentPage,
333 | ref: this._children()[currentPage],
334 | from: prevPage,
335 | })
336 | },
337 |
338 | _onScroll(e) {
339 | if (Platform.OS === 'ios') {
340 | const offsetX = e.nativeEvent.contentOffset.x
341 | if (offsetX === 0 && !this.scrollOnMountCalled) {
342 | this.scrollOnMountCalled = true
343 | } else {
344 | this.props.onScroll(offsetX / this.props.containerWidth)
345 | }
346 | } else {
347 | const { position, offset } = e.nativeEvent
348 | this.props.onScroll(position + offset)
349 | }
350 | },
351 |
352 | _handleLayout(e) {
353 | const { width } = e.nativeEvent.layout
354 |
355 | if (!width || width <= 0 || Math.round(width) === Math.round(this.state.containerWidth)) {
356 | return
357 | }
358 |
359 | if (Platform.OS === 'ios') {
360 | const containerWidthAnimatedValue = new Animated.Value(width)
361 | // Need to call __makeNative manually to avoid a native animated bug. See
362 | // https://github.com/facebook/react-native/pull/14435
363 | containerWidthAnimatedValue.__makeNative()
364 | scrollValue = Animated.divide(this.state.scrollXIOS, containerWidthAnimatedValue)
365 | this.setState({ containerWidth: width, scrollValue })
366 | } else {
367 | this.setState({ containerWidth: width })
368 | }
369 | this.requestAnimationFrame(() => {
370 | this.goToPage(this.state.currentPage)
371 | })
372 | },
373 |
374 | _children(children = this.props.children) {
375 | return React.Children.map(children, (child) => child)
376 | },
377 |
378 | render() {
379 | const overlayTabs =
380 | this.props.tabBarPosition === 'overlayTop' || this.props.tabBarPosition === 'overlayBottom'
381 | const tabBarProps = {
382 | goToPage: this.goToPage,
383 | tabs: this._children().map((child) => child.props),
384 | activeTab: this.state.currentPage,
385 | scrollValue: this.state.scrollValue,
386 | // containerWidth: this.props.containerWidth,
387 | containerWidth: this.props.tabsWidth || this.props.containerWidth,
388 | initialPage: this.props.initialPage,
389 | }
390 |
391 | if (this.props.tabBarBackgroundColor) {
392 | tabBarProps.backgroundColor = this.props.tabBarBackgroundColor
393 | }
394 | if (this.props.tabBarActiveTextColor) {
395 | tabBarProps.activeTextColor = this.props.tabBarActiveTextColor
396 | }
397 | if (this.props.tabBarInactiveTextColor) {
398 | tabBarProps.inactiveTextColor = this.props.tabBarInactiveTextColor
399 | }
400 | if (this.props.tabBarTextStyle) {
401 | tabBarProps.textStyle = this.props.tabBarTextStyle
402 | }
403 | if (this.props.tabBarUnderlineStyle) {
404 | tabBarProps.underlineStyle = this.props.tabBarUnderlineStyle
405 | }
406 | if (overlayTabs) {
407 | tabBarProps.style = {
408 | position: 'absolute',
409 | left: 0,
410 | right: 0,
411 | [this.props.tabBarPosition === 'overlayTop' ? 'top' : 'bottom']: 0,
412 | }
413 | }
414 |
415 | return (
416 |
417 | {this.props.tabBarPosition === 'top' && this.renderTabBar(tabBarProps)}
418 | {this.renderScrollableContent()}
419 | {(this.props.tabBarPosition === 'bottom' || overlayTabs) && this.renderTabBar(tabBarProps)}
420 |
421 | )
422 | },
423 | })
424 |
425 | module.exports = ScrollableTabView
426 |
427 | const styles = StyleSheet.create({
428 | container: {
429 | flex: 1,
430 | },
431 | scrollableContentAndroid: {
432 | flex: 1,
433 | },
434 | })
435 |
--------------------------------------------------------------------------------
/test/ios/test.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 00E356F31AD99517003FC87E /* testTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* testTests.m */; };
11 | 13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; };
12 | 13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB11A68108700A75B9A /* LaunchScreen.xib */; };
13 | 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
14 | 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
15 | 2D02E4BC1E0B4A80006451C7 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; };
16 | 2D02E4BD1E0B4A84006451C7 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; };
17 | 2D02E4BF1E0B4AB3006451C7 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; };
18 | 2DCD954D1E0B4F2C00145EB5 /* testTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* testTests.m */; };
19 | /* End PBXBuildFile section */
20 |
21 | /* Begin PBXContainerItemProxy section */
22 | 00E356F41AD99517003FC87E /* PBXContainerItemProxy */ = {
23 | isa = PBXContainerItemProxy;
24 | containerPortal = 83CBB9F71A601CBA00E9B192 /* Project object */;
25 | proxyType = 1;
26 | remoteGlobalIDString = 13B07F861A680F5B00A75B9A;
27 | remoteInfo = test;
28 | };
29 | 2D02E4911E0B4A5D006451C7 /* PBXContainerItemProxy */ = {
30 | isa = PBXContainerItemProxy;
31 | containerPortal = 83CBB9F71A601CBA00E9B192 /* Project object */;
32 | proxyType = 1;
33 | remoteGlobalIDString = 2D02E47A1E0B4A5D006451C7;
34 | remoteInfo = "test-tvOS";
35 | };
36 | /* End PBXContainerItemProxy section */
37 |
38 | /* Begin PBXFileReference section */
39 | 008F07F21AC5B25A0029DE68 /* main.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = main.jsbundle; sourceTree = ""; };
40 | 00E356EE1AD99517003FC87E /* testTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = testTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
41 | 00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
42 | 00E356F21AD99517003FC87E /* testTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = testTests.m; sourceTree = ""; };
43 | 13B07F961A680F5B00A75B9A /* test.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = test.app; sourceTree = BUILT_PRODUCTS_DIR; };
44 | 13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = test/AppDelegate.h; sourceTree = ""; };
45 | 13B07FB01A68108700A75B9A /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = test/AppDelegate.m; sourceTree = ""; };
46 | 13B07FB21A68108700A75B9A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; };
47 | 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = test/Images.xcassets; sourceTree = ""; };
48 | 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = test/Info.plist; sourceTree = ""; };
49 | 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = test/main.m; sourceTree = ""; };
50 | 2D02E47B1E0B4A5D006451C7 /* test-tvOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "test-tvOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
51 | 2D02E4901E0B4A5D006451C7 /* test-tvOSTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "test-tvOSTests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; };
52 | ED297162215061F000B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
53 | ED2971642150620600B7C4FE /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS12.0.sdk/System/Library/Frameworks/JavaScriptCore.framework; sourceTree = DEVELOPER_DIR; };
54 | /* End PBXFileReference section */
55 |
56 | /* Begin PBXFrameworksBuildPhase section */
57 | 00E356EB1AD99517003FC87E /* Frameworks */ = {
58 | isa = PBXFrameworksBuildPhase;
59 | buildActionMask = 2147483647;
60 | files = (
61 | );
62 | runOnlyForDeploymentPostprocessing = 0;
63 | };
64 | 13B07F8C1A680F5B00A75B9A /* Frameworks */ = {
65 | isa = PBXFrameworksBuildPhase;
66 | buildActionMask = 2147483647;
67 | files = (
68 | );
69 | runOnlyForDeploymentPostprocessing = 0;
70 | };
71 | 2D02E4781E0B4A5D006451C7 /* Frameworks */ = {
72 | isa = PBXFrameworksBuildPhase;
73 | buildActionMask = 2147483647;
74 | files = (
75 | );
76 | runOnlyForDeploymentPostprocessing = 0;
77 | };
78 | 2D02E48D1E0B4A5D006451C7 /* Frameworks */ = {
79 | isa = PBXFrameworksBuildPhase;
80 | buildActionMask = 2147483647;
81 | files = (
82 | );
83 | runOnlyForDeploymentPostprocessing = 0;
84 | };
85 | /* End PBXFrameworksBuildPhase section */
86 |
87 | /* Begin PBXGroup section */
88 | 00E356EF1AD99517003FC87E /* testTests */ = {
89 | isa = PBXGroup;
90 | children = (
91 | 00E356F21AD99517003FC87E /* testTests.m */,
92 | 00E356F01AD99517003FC87E /* Supporting Files */,
93 | );
94 | path = testTests;
95 | sourceTree = "";
96 | };
97 | 00E356F01AD99517003FC87E /* Supporting Files */ = {
98 | isa = PBXGroup;
99 | children = (
100 | 00E356F11AD99517003FC87E /* Info.plist */,
101 | );
102 | name = "Supporting Files";
103 | sourceTree = "";
104 | };
105 | 13B07FAE1A68108700A75B9A /* test */ = {
106 | isa = PBXGroup;
107 | children = (
108 | 008F07F21AC5B25A0029DE68 /* main.jsbundle */,
109 | 13B07FAF1A68108700A75B9A /* AppDelegate.h */,
110 | 13B07FB01A68108700A75B9A /* AppDelegate.m */,
111 | 13B07FB51A68108700A75B9A /* Images.xcassets */,
112 | 13B07FB61A68108700A75B9A /* Info.plist */,
113 | 13B07FB11A68108700A75B9A /* LaunchScreen.xib */,
114 | 13B07FB71A68108700A75B9A /* main.m */,
115 | );
116 | name = test;
117 | sourceTree = "";
118 | };
119 | 2D16E6871FA4F8E400B85C8A /* Frameworks */ = {
120 | isa = PBXGroup;
121 | children = (
122 | ED297162215061F000B7C4FE /* JavaScriptCore.framework */,
123 | ED2971642150620600B7C4FE /* JavaScriptCore.framework */,
124 | );
125 | name = Frameworks;
126 | sourceTree = "";
127 | };
128 | 832341AE1AAA6A7D00B99B32 /* Libraries */ = {
129 | isa = PBXGroup;
130 | children = (
131 | );
132 | name = Libraries;
133 | sourceTree = "";
134 | };
135 | 83CBB9F61A601CBA00E9B192 = {
136 | isa = PBXGroup;
137 | children = (
138 | 13B07FAE1A68108700A75B9A /* test */,
139 | 832341AE1AAA6A7D00B99B32 /* Libraries */,
140 | 00E356EF1AD99517003FC87E /* testTests */,
141 | 83CBBA001A601CBA00E9B192 /* Products */,
142 | 2D16E6871FA4F8E400B85C8A /* Frameworks */,
143 | );
144 | indentWidth = 2;
145 | sourceTree = "";
146 | tabWidth = 2;
147 | usesTabs = 0;
148 | };
149 | 83CBBA001A601CBA00E9B192 /* Products */ = {
150 | isa = PBXGroup;
151 | children = (
152 | 13B07F961A680F5B00A75B9A /* test.app */,
153 | 00E356EE1AD99517003FC87E /* testTests.xctest */,
154 | 2D02E47B1E0B4A5D006451C7 /* test-tvOS.app */,
155 | 2D02E4901E0B4A5D006451C7 /* test-tvOSTests.xctest */,
156 | );
157 | name = Products;
158 | sourceTree = "";
159 | };
160 | /* End PBXGroup section */
161 |
162 | /* Begin PBXNativeTarget section */
163 | 00E356ED1AD99517003FC87E /* testTests */ = {
164 | isa = PBXNativeTarget;
165 | buildConfigurationList = 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "testTests" */;
166 | buildPhases = (
167 | 00E356EA1AD99517003FC87E /* Sources */,
168 | 00E356EB1AD99517003FC87E /* Frameworks */,
169 | 00E356EC1AD99517003FC87E /* Resources */,
170 | );
171 | buildRules = (
172 | );
173 | dependencies = (
174 | 00E356F51AD99517003FC87E /* PBXTargetDependency */,
175 | );
176 | name = testTests;
177 | productName = testTests;
178 | productReference = 00E356EE1AD99517003FC87E /* testTests.xctest */;
179 | productType = "com.apple.product-type.bundle.unit-test";
180 | };
181 | 13B07F861A680F5B00A75B9A /* test */ = {
182 | isa = PBXNativeTarget;
183 | buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "test" */;
184 | buildPhases = (
185 | FD10A7F022414F080027D42C /* Start Packager */,
186 | 13B07F871A680F5B00A75B9A /* Sources */,
187 | 13B07F8C1A680F5B00A75B9A /* Frameworks */,
188 | 13B07F8E1A680F5B00A75B9A /* Resources */,
189 | 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */,
190 | );
191 | buildRules = (
192 | );
193 | dependencies = (
194 | );
195 | name = test;
196 | productName = "test";
197 | productReference = 13B07F961A680F5B00A75B9A /* test.app */;
198 | productType = "com.apple.product-type.application";
199 | };
200 | 2D02E47A1E0B4A5D006451C7 /* test-tvOS */ = {
201 | isa = PBXNativeTarget;
202 | buildConfigurationList = 2D02E4BA1E0B4A5E006451C7 /* Build configuration list for PBXNativeTarget "test-tvOS" */;
203 | buildPhases = (
204 | FD10A7F122414F3F0027D42C /* Start Packager */,
205 | 2D02E4771E0B4A5D006451C7 /* Sources */,
206 | 2D02E4781E0B4A5D006451C7 /* Frameworks */,
207 | 2D02E4791E0B4A5D006451C7 /* Resources */,
208 | 2D02E4CB1E0B4B27006451C7 /* Bundle React Native Code And Images */,
209 | );
210 | buildRules = (
211 | );
212 | dependencies = (
213 | );
214 | name = "test-tvOS";
215 | productName = "test-tvOS";
216 | productReference = 2D02E47B1E0B4A5D006451C7 /* test-tvOS.app */;
217 | productType = "com.apple.product-type.application";
218 | };
219 | 2D02E48F1E0B4A5D006451C7 /* test-tvOSTests */ = {
220 | isa = PBXNativeTarget;
221 | buildConfigurationList = 2D02E4BB1E0B4A5E006451C7 /* Build configuration list for PBXNativeTarget "test-tvOSTests" */;
222 | buildPhases = (
223 | 2D02E48C1E0B4A5D006451C7 /* Sources */,
224 | 2D02E48D1E0B4A5D006451C7 /* Frameworks */,
225 | 2D02E48E1E0B4A5D006451C7 /* Resources */,
226 | );
227 | buildRules = (
228 | );
229 | dependencies = (
230 | 2D02E4921E0B4A5D006451C7 /* PBXTargetDependency */,
231 | );
232 | name = "test-tvOSTests";
233 | productName = "test-tvOSTests";
234 | productReference = 2D02E4901E0B4A5D006451C7 /* test-tvOSTests.xctest */;
235 | productType = "com.apple.product-type.bundle.unit-test";
236 | };
237 | /* End PBXNativeTarget section */
238 |
239 | /* Begin PBXProject section */
240 | 83CBB9F71A601CBA00E9B192 /* Project object */ = {
241 | isa = PBXProject;
242 | attributes = {
243 | LastUpgradeCheck = 0940;
244 | ORGANIZATIONNAME = Facebook;
245 | TargetAttributes = {
246 | 00E356ED1AD99517003FC87E = {
247 | CreatedOnToolsVersion = 6.2;
248 | TestTargetID = 13B07F861A680F5B00A75B9A;
249 | };
250 | 2D02E47A1E0B4A5D006451C7 = {
251 | CreatedOnToolsVersion = 8.2.1;
252 | ProvisioningStyle = Automatic;
253 | };
254 | 2D02E48F1E0B4A5D006451C7 = {
255 | CreatedOnToolsVersion = 8.2.1;
256 | ProvisioningStyle = Automatic;
257 | TestTargetID = 2D02E47A1E0B4A5D006451C7;
258 | };
259 | };
260 | };
261 | buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "test" */;
262 | compatibilityVersion = "Xcode 3.2";
263 | developmentRegion = English;
264 | hasScannedForEncodings = 0;
265 | knownRegions = (
266 | en,
267 | Base,
268 | );
269 | mainGroup = 83CBB9F61A601CBA00E9B192;
270 | productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */;
271 | projectDirPath = "";
272 | projectRoot = "";
273 | targets = (
274 | 13B07F861A680F5B00A75B9A /* test */,
275 | 00E356ED1AD99517003FC87E /* testTests */,
276 | 2D02E47A1E0B4A5D006451C7 /* test-tvOS */,
277 | 2D02E48F1E0B4A5D006451C7 /* test-tvOSTests */,
278 | );
279 | };
280 | /* End PBXProject section */
281 |
282 | /* Begin PBXResourcesBuildPhase section */
283 | 00E356EC1AD99517003FC87E /* Resources */ = {
284 | isa = PBXResourcesBuildPhase;
285 | buildActionMask = 2147483647;
286 | files = (
287 | );
288 | runOnlyForDeploymentPostprocessing = 0;
289 | };
290 | 13B07F8E1A680F5B00A75B9A /* Resources */ = {
291 | isa = PBXResourcesBuildPhase;
292 | buildActionMask = 2147483647;
293 | files = (
294 | 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */,
295 | 13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */,
296 | );
297 | runOnlyForDeploymentPostprocessing = 0;
298 | };
299 | 2D02E4791E0B4A5D006451C7 /* Resources */ = {
300 | isa = PBXResourcesBuildPhase;
301 | buildActionMask = 2147483647;
302 | files = (
303 | 2D02E4BD1E0B4A84006451C7 /* Images.xcassets in Resources */,
304 | );
305 | runOnlyForDeploymentPostprocessing = 0;
306 | };
307 | 2D02E48E1E0B4A5D006451C7 /* Resources */ = {
308 | isa = PBXResourcesBuildPhase;
309 | buildActionMask = 2147483647;
310 | files = (
311 | );
312 | runOnlyForDeploymentPostprocessing = 0;
313 | };
314 | /* End PBXResourcesBuildPhase section */
315 |
316 | /* Begin PBXShellScriptBuildPhase section */
317 | 00DD1BFF1BD5951E006B06BC /* Bundle React Native code and images */ = {
318 | isa = PBXShellScriptBuildPhase;
319 | buildActionMask = 2147483647;
320 | files = (
321 | );
322 | inputPaths = (
323 | );
324 | name = "Bundle React Native code and images";
325 | outputPaths = (
326 | );
327 | runOnlyForDeploymentPostprocessing = 0;
328 | shellPath = /bin/sh;
329 | shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh";
330 | };
331 | 2D02E4CB1E0B4B27006451C7 /* Bundle React Native Code And Images */ = {
332 | isa = PBXShellScriptBuildPhase;
333 | buildActionMask = 2147483647;
334 | files = (
335 | );
336 | inputPaths = (
337 | );
338 | name = "Bundle React Native Code And Images";
339 | outputPaths = (
340 | );
341 | runOnlyForDeploymentPostprocessing = 0;
342 | shellPath = /bin/sh;
343 | shellScript = "export NODE_BINARY=node\n../node_modules/react-native/scripts/react-native-xcode.sh";
344 | };
345 | FD10A7F022414F080027D42C /* Start Packager */ = {
346 | isa = PBXShellScriptBuildPhase;
347 | buildActionMask = 2147483647;
348 | files = (
349 | );
350 | inputFileListPaths = (
351 | );
352 | inputPaths = (
353 | );
354 | name = "Start Packager";
355 | outputFileListPaths = (
356 | );
357 | outputPaths = (
358 | );
359 | runOnlyForDeploymentPostprocessing = 0;
360 | shellPath = /bin/sh;
361 | shellScript = "export RCT_METRO_PORT=\"${RCT_METRO_PORT:=8081}\"\necho \"export RCT_METRO_PORT=${RCT_METRO_PORT}\" > \"${SRCROOT}/../node_modules/react-native/scripts/.packager.env\"\nif [ -z \"${RCT_NO_LAUNCH_PACKAGER+xxx}\" ] ; then\n if nc -w 5 -z localhost ${RCT_METRO_PORT} ; then\n if ! curl -s \"http://localhost:${RCT_METRO_PORT}/status\" | grep -q \"packager-status:running\" ; then\n echo \"Port ${RCT_METRO_PORT} already in use, packager is either not running or not running correctly\"\n exit 2\n fi\n else\n open \"$SRCROOT/../node_modules/react-native/scripts/launchPackager.command\" || echo \"Can't start packager automatically\"\n fi\nfi\n";
362 | showEnvVarsInLog = 0;
363 | };
364 | FD10A7F122414F3F0027D42C /* Start Packager */ = {
365 | isa = PBXShellScriptBuildPhase;
366 | buildActionMask = 2147483647;
367 | files = (
368 | );
369 | inputFileListPaths = (
370 | );
371 | inputPaths = (
372 | );
373 | name = "Start Packager";
374 | outputFileListPaths = (
375 | );
376 | outputPaths = (
377 | );
378 | runOnlyForDeploymentPostprocessing = 0;
379 | shellPath = /bin/sh;
380 | shellScript = "export RCT_METRO_PORT=\"${RCT_METRO_PORT:=8081}\"\necho \"export RCT_METRO_PORT=${RCT_METRO_PORT}\" > \"${SRCROOT}/../node_modules/react-native/scripts/.packager.env\"\nif [ -z \"${RCT_NO_LAUNCH_PACKAGER+xxx}\" ] ; then\n if nc -w 5 -z localhost ${RCT_METRO_PORT} ; then\n if ! curl -s \"http://localhost:${RCT_METRO_PORT}/status\" | grep -q \"packager-status:running\" ; then\n echo \"Port ${RCT_METRO_PORT} already in use, packager is either not running or not running correctly\"\n exit 2\n fi\n else\n open \"$SRCROOT/../node_modules/react-native/scripts/launchPackager.command\" || echo \"Can't start packager automatically\"\n fi\nfi\n";
381 | showEnvVarsInLog = 0;
382 | };
383 | /* End PBXShellScriptBuildPhase section */
384 |
385 | /* Begin PBXSourcesBuildPhase section */
386 | 00E356EA1AD99517003FC87E /* Sources */ = {
387 | isa = PBXSourcesBuildPhase;
388 | buildActionMask = 2147483647;
389 | files = (
390 | 00E356F31AD99517003FC87E /* testTests.m in Sources */,
391 | );
392 | runOnlyForDeploymentPostprocessing = 0;
393 | };
394 | 13B07F871A680F5B00A75B9A /* Sources */ = {
395 | isa = PBXSourcesBuildPhase;
396 | buildActionMask = 2147483647;
397 | files = (
398 | 13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */,
399 | 13B07FC11A68108700A75B9A /* main.m in Sources */,
400 | );
401 | runOnlyForDeploymentPostprocessing = 0;
402 | };
403 | 2D02E4771E0B4A5D006451C7 /* Sources */ = {
404 | isa = PBXSourcesBuildPhase;
405 | buildActionMask = 2147483647;
406 | files = (
407 | 2D02E4BF1E0B4AB3006451C7 /* main.m in Sources */,
408 | 2D02E4BC1E0B4A80006451C7 /* AppDelegate.m in Sources */,
409 | );
410 | runOnlyForDeploymentPostprocessing = 0;
411 | };
412 | 2D02E48C1E0B4A5D006451C7 /* Sources */ = {
413 | isa = PBXSourcesBuildPhase;
414 | buildActionMask = 2147483647;
415 | files = (
416 | 2DCD954D1E0B4F2C00145EB5 /* testTests.m in Sources */,
417 | );
418 | runOnlyForDeploymentPostprocessing = 0;
419 | };
420 | /* End PBXSourcesBuildPhase section */
421 |
422 | /* Begin PBXTargetDependency section */
423 | 00E356F51AD99517003FC87E /* PBXTargetDependency */ = {
424 | isa = PBXTargetDependency;
425 | target = 13B07F861A680F5B00A75B9A /* test */;
426 | targetProxy = 00E356F41AD99517003FC87E /* PBXContainerItemProxy */;
427 | };
428 | 2D02E4921E0B4A5D006451C7 /* PBXTargetDependency */ = {
429 | isa = PBXTargetDependency;
430 | target = 2D02E47A1E0B4A5D006451C7 /* test-tvOS */;
431 | targetProxy = 2D02E4911E0B4A5D006451C7 /* PBXContainerItemProxy */;
432 | };
433 | /* End PBXTargetDependency section */
434 |
435 | /* Begin PBXVariantGroup section */
436 | 13B07FB11A68108700A75B9A /* LaunchScreen.xib */ = {
437 | isa = PBXVariantGroup;
438 | children = (
439 | 13B07FB21A68108700A75B9A /* Base */,
440 | );
441 | name = LaunchScreen.xib;
442 | path = test;
443 | sourceTree = "";
444 | };
445 | /* End PBXVariantGroup section */
446 |
447 | /* Begin XCBuildConfiguration section */
448 | 00E356F61AD99517003FC87E /* Debug */ = {
449 | isa = XCBuildConfiguration;
450 | buildSettings = {
451 | BUNDLE_LOADER = "$(TEST_HOST)";
452 | GCC_PREPROCESSOR_DEFINITIONS = (
453 | "DEBUG=1",
454 | "$(inherited)",
455 | );
456 | INFOPLIST_FILE = testTests/Info.plist;
457 | IPHONEOS_DEPLOYMENT_TARGET = 9.0;
458 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
459 | OTHER_LDFLAGS = (
460 | "-ObjC",
461 | "-lc++",
462 | "$(inherited)",
463 | );
464 | PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
465 | PRODUCT_NAME = "$(TARGET_NAME)";
466 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/test.app/test";
467 | };
468 | name = Debug;
469 | };
470 | 00E356F71AD99517003FC87E /* Release */ = {
471 | isa = XCBuildConfiguration;
472 | buildSettings = {
473 | BUNDLE_LOADER = "$(TEST_HOST)";
474 | COPY_PHASE_STRIP = NO;
475 | INFOPLIST_FILE = testTests/Info.plist;
476 | IPHONEOS_DEPLOYMENT_TARGET = 9.0;
477 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
478 | OTHER_LDFLAGS = (
479 | "-ObjC",
480 | "-lc++",
481 | "$(inherited)",
482 | );
483 | PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
484 | PRODUCT_NAME = "$(TARGET_NAME)";
485 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/test.app/test";
486 | };
487 | name = Release;
488 | };
489 | 13B07F941A680F5B00A75B9A /* Debug */ = {
490 | isa = XCBuildConfiguration;
491 | buildSettings = {
492 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
493 | CURRENT_PROJECT_VERSION = 1;
494 | DEAD_CODE_STRIPPING = NO;
495 | INFOPLIST_FILE = test/Info.plist;
496 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
497 | OTHER_LDFLAGS = (
498 | "$(inherited)",
499 | "-ObjC",
500 | "-lc++",
501 | );
502 | PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
503 | PRODUCT_NAME = test;
504 | VERSIONING_SYSTEM = "apple-generic";
505 | };
506 | name = Debug;
507 | };
508 | 13B07F951A680F5B00A75B9A /* Release */ = {
509 | isa = XCBuildConfiguration;
510 | buildSettings = {
511 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
512 | CURRENT_PROJECT_VERSION = 1;
513 | INFOPLIST_FILE = test/Info.plist;
514 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
515 | OTHER_LDFLAGS = (
516 | "$(inherited)",
517 | "-ObjC",
518 | "-lc++",
519 | );
520 | PRODUCT_BUNDLE_IDENTIFIER = "org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier)";
521 | PRODUCT_NAME = test;
522 | VERSIONING_SYSTEM = "apple-generic";
523 | };
524 | name = Release;
525 | };
526 | 2D02E4971E0B4A5E006451C7 /* Debug */ = {
527 | isa = XCBuildConfiguration;
528 | buildSettings = {
529 | ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image";
530 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
531 | CLANG_ANALYZER_NONNULL = YES;
532 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
533 | CLANG_WARN_INFINITE_RECURSION = YES;
534 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
535 | DEBUG_INFORMATION_FORMAT = dwarf;
536 | ENABLE_TESTABILITY = YES;
537 | GCC_NO_COMMON_BLOCKS = YES;
538 | INFOPLIST_FILE = "test-tvOS/Info.plist";
539 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
540 | OTHER_LDFLAGS = (
541 | "$(inherited)",
542 | "-ObjC",
543 | "-lc++",
544 | );
545 | PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.REACT.test-tvOS";
546 | PRODUCT_NAME = "$(TARGET_NAME)";
547 | SDKROOT = appletvos;
548 | TARGETED_DEVICE_FAMILY = 3;
549 | TVOS_DEPLOYMENT_TARGET = 9.2;
550 | };
551 | name = Debug;
552 | };
553 | 2D02E4981E0B4A5E006451C7 /* Release */ = {
554 | isa = XCBuildConfiguration;
555 | buildSettings = {
556 | ASSETCATALOG_COMPILER_APPICON_NAME = "App Icon & Top Shelf Image";
557 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage;
558 | CLANG_ANALYZER_NONNULL = YES;
559 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
560 | CLANG_WARN_INFINITE_RECURSION = YES;
561 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
562 | COPY_PHASE_STRIP = NO;
563 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
564 | GCC_NO_COMMON_BLOCKS = YES;
565 | INFOPLIST_FILE = "test-tvOS/Info.plist";
566 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
567 | OTHER_LDFLAGS = (
568 | "$(inherited)",
569 | "-ObjC",
570 | "-lc++",
571 | );
572 | PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.REACT.test-tvOS";
573 | PRODUCT_NAME = "$(TARGET_NAME)";
574 | SDKROOT = appletvos;
575 | TARGETED_DEVICE_FAMILY = 3;
576 | TVOS_DEPLOYMENT_TARGET = 9.2;
577 | };
578 | name = Release;
579 | };
580 | 2D02E4991E0B4A5E006451C7 /* Debug */ = {
581 | isa = XCBuildConfiguration;
582 | buildSettings = {
583 | BUNDLE_LOADER = "$(TEST_HOST)";
584 | CLANG_ANALYZER_NONNULL = YES;
585 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
586 | CLANG_WARN_INFINITE_RECURSION = YES;
587 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
588 | DEBUG_INFORMATION_FORMAT = dwarf;
589 | ENABLE_TESTABILITY = YES;
590 | GCC_NO_COMMON_BLOCKS = YES;
591 | INFOPLIST_FILE = "test-tvOSTests/Info.plist";
592 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
593 | OTHER_LDFLAGS = (
594 | "$(inherited)",
595 | "-ObjC",
596 | "-lc++",
597 | );
598 | PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.REACT.test-tvOSTests";
599 | PRODUCT_NAME = "$(TARGET_NAME)";
600 | SDKROOT = appletvos;
601 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/test-tvOS.app/test-tvOS";
602 | TVOS_DEPLOYMENT_TARGET = 10.1;
603 | };
604 | name = Debug;
605 | };
606 | 2D02E49A1E0B4A5E006451C7 /* Release */ = {
607 | isa = XCBuildConfiguration;
608 | buildSettings = {
609 | BUNDLE_LOADER = "$(TEST_HOST)";
610 | CLANG_ANALYZER_NONNULL = YES;
611 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
612 | CLANG_WARN_INFINITE_RECURSION = YES;
613 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
614 | COPY_PHASE_STRIP = NO;
615 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
616 | GCC_NO_COMMON_BLOCKS = YES;
617 | INFOPLIST_FILE = "test-tvOSTests/Info.plist";
618 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
619 | OTHER_LDFLAGS = (
620 | "$(inherited)",
621 | "-ObjC",
622 | "-lc++",
623 | );
624 | PRODUCT_BUNDLE_IDENTIFIER = "com.facebook.REACT.test-tvOSTests";
625 | PRODUCT_NAME = "$(TARGET_NAME)";
626 | SDKROOT = appletvos;
627 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/test-tvOS.app/test-tvOS";
628 | TVOS_DEPLOYMENT_TARGET = 10.1;
629 | };
630 | name = Release;
631 | };
632 | 83CBBA201A601CBA00E9B192 /* Debug */ = {
633 | isa = XCBuildConfiguration;
634 | buildSettings = {
635 | ALWAYS_SEARCH_USER_PATHS = NO;
636 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
637 | CLANG_CXX_LIBRARY = "libc++";
638 | CLANG_ENABLE_MODULES = YES;
639 | CLANG_ENABLE_OBJC_ARC = YES;
640 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
641 | CLANG_WARN_BOOL_CONVERSION = YES;
642 | CLANG_WARN_COMMA = YES;
643 | CLANG_WARN_CONSTANT_CONVERSION = YES;
644 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
645 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
646 | CLANG_WARN_EMPTY_BODY = YES;
647 | CLANG_WARN_ENUM_CONVERSION = YES;
648 | CLANG_WARN_INFINITE_RECURSION = YES;
649 | CLANG_WARN_INT_CONVERSION = YES;
650 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
651 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
652 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
653 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
654 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
655 | CLANG_WARN_STRICT_PROTOTYPES = YES;
656 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
657 | CLANG_WARN_UNREACHABLE_CODE = YES;
658 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
659 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
660 | COPY_PHASE_STRIP = NO;
661 | ENABLE_STRICT_OBJC_MSGSEND = YES;
662 | ENABLE_TESTABILITY = YES;
663 | GCC_C_LANGUAGE_STANDARD = gnu99;
664 | GCC_DYNAMIC_NO_PIC = NO;
665 | GCC_NO_COMMON_BLOCKS = YES;
666 | GCC_OPTIMIZATION_LEVEL = 0;
667 | GCC_PREPROCESSOR_DEFINITIONS = (
668 | "DEBUG=1",
669 | "$(inherited)",
670 | );
671 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
672 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
673 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
674 | GCC_WARN_UNDECLARED_SELECTOR = YES;
675 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
676 | GCC_WARN_UNUSED_FUNCTION = YES;
677 | GCC_WARN_UNUSED_VARIABLE = YES;
678 | IPHONEOS_DEPLOYMENT_TARGET = 9.0;
679 | MTL_ENABLE_DEBUG_INFO = YES;
680 | ONLY_ACTIVE_ARCH = YES;
681 | SDKROOT = iphoneos;
682 | };
683 | name = Debug;
684 | };
685 | 83CBBA211A601CBA00E9B192 /* Release */ = {
686 | isa = XCBuildConfiguration;
687 | buildSettings = {
688 | ALWAYS_SEARCH_USER_PATHS = NO;
689 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
690 | CLANG_CXX_LIBRARY = "libc++";
691 | CLANG_ENABLE_MODULES = YES;
692 | CLANG_ENABLE_OBJC_ARC = YES;
693 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
694 | CLANG_WARN_BOOL_CONVERSION = YES;
695 | CLANG_WARN_COMMA = YES;
696 | CLANG_WARN_CONSTANT_CONVERSION = YES;
697 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
698 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
699 | CLANG_WARN_EMPTY_BODY = YES;
700 | CLANG_WARN_ENUM_CONVERSION = YES;
701 | CLANG_WARN_INFINITE_RECURSION = YES;
702 | CLANG_WARN_INT_CONVERSION = YES;
703 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
704 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
705 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
706 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
707 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
708 | CLANG_WARN_STRICT_PROTOTYPES = YES;
709 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
710 | CLANG_WARN_UNREACHABLE_CODE = YES;
711 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
712 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
713 | COPY_PHASE_STRIP = YES;
714 | ENABLE_NS_ASSERTIONS = NO;
715 | ENABLE_STRICT_OBJC_MSGSEND = YES;
716 | GCC_C_LANGUAGE_STANDARD = gnu99;
717 | GCC_NO_COMMON_BLOCKS = YES;
718 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
719 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
720 | GCC_WARN_UNDECLARED_SELECTOR = YES;
721 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
722 | GCC_WARN_UNUSED_FUNCTION = YES;
723 | GCC_WARN_UNUSED_VARIABLE = YES;
724 | IPHONEOS_DEPLOYMENT_TARGET = 9.0;
725 | MTL_ENABLE_DEBUG_INFO = NO;
726 | SDKROOT = iphoneos;
727 | VALIDATE_PRODUCT = YES;
728 | };
729 | name = Release;
730 | };
731 | /* End XCBuildConfiguration section */
732 |
733 | /* Begin XCConfigurationList section */
734 | 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "testTests" */ = {
735 | isa = XCConfigurationList;
736 | buildConfigurations = (
737 | 00E356F61AD99517003FC87E /* Debug */,
738 | 00E356F71AD99517003FC87E /* Release */,
739 | );
740 | defaultConfigurationIsVisible = 0;
741 | defaultConfigurationName = Release;
742 | };
743 | 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "test" */ = {
744 | isa = XCConfigurationList;
745 | buildConfigurations = (
746 | 13B07F941A680F5B00A75B9A /* Debug */,
747 | 13B07F951A680F5B00A75B9A /* Release */,
748 | );
749 | defaultConfigurationIsVisible = 0;
750 | defaultConfigurationName = Release;
751 | };
752 | 2D02E4BA1E0B4A5E006451C7 /* Build configuration list for PBXNativeTarget "test-tvOS" */ = {
753 | isa = XCConfigurationList;
754 | buildConfigurations = (
755 | 2D02E4971E0B4A5E006451C7 /* Debug */,
756 | 2D02E4981E0B4A5E006451C7 /* Release */,
757 | );
758 | defaultConfigurationIsVisible = 0;
759 | defaultConfigurationName = Release;
760 | };
761 | 2D02E4BB1E0B4A5E006451C7 /* Build configuration list for PBXNativeTarget "test-tvOSTests" */ = {
762 | isa = XCConfigurationList;
763 | buildConfigurations = (
764 | 2D02E4991E0B4A5E006451C7 /* Debug */,
765 | 2D02E49A1E0B4A5E006451C7 /* Release */,
766 | );
767 | defaultConfigurationIsVisible = 0;
768 | defaultConfigurationName = Release;
769 | };
770 | 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "test" */ = {
771 | isa = XCConfigurationList;
772 | buildConfigurations = (
773 | 83CBBA201A601CBA00E9B192 /* Debug */,
774 | 83CBBA211A601CBA00E9B192 /* Release */,
775 | );
776 | defaultConfigurationIsVisible = 0;
777 | defaultConfigurationName = Release;
778 | };
779 | /* End XCConfigurationList section */
780 | };
781 | rootObject = 83CBB9F71A601CBA00E9B192 /* Project object */;
782 | }
783 |
--------------------------------------------------------------------------------