├── example ├── .watchmanconfig ├── .gitattributes ├── .babelrc ├── app.json ├── android │ ├── settings.gradle │ ├── app │ │ ├── src │ │ │ └── main │ │ │ │ ├── res │ │ │ │ ├── values │ │ │ │ │ ├── strings.xml │ │ │ │ │ └── styles.xml │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ └── mipmap-xxhdpi │ │ │ │ │ └── ic_launcher.png │ │ │ │ ├── assets │ │ │ │ └── fonts │ │ │ │ │ └── Bungee-Regular.ttf │ │ │ │ ├── java │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ ├── MainActivity.java │ │ │ │ │ └── MainApplication.java │ │ │ │ └── AndroidManifest.xml │ │ ├── BUCK │ │ ├── proguard-rules.pro │ │ └── build.gradle │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── keystores │ │ ├── debug.keystore.properties │ │ └── BUCK │ ├── build.gradle │ ├── gradle.properties │ ├── gradlew.bat │ └── gradlew ├── pages │ ├── assets │ │ ├── decrement.png │ │ ├── increment.png │ │ ├── decrement@2x.png │ │ ├── decrement@3x.png │ │ ├── increment@2x.png │ │ └── increment@3x.png │ ├── UIStepper.js │ └── MainPage.js ├── assets │ └── fonts │ │ └── Bungee-Regular.ttf ├── .buckconfig ├── components │ ├── Header.js │ ├── Container.js │ └── Item.js ├── __tests__ │ ├── index.ios.js │ └── index.android.js ├── ios │ ├── example │ │ ├── AppDelegate.h │ │ ├── main.m │ │ ├── Images.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ ├── AppDelegate.m │ │ ├── Info.plist │ │ └── Base.lproj │ │ │ └── LaunchScreen.xib │ ├── exampleTests │ │ ├── Info.plist │ │ └── exampleTests.m │ ├── example-tvOSTests │ │ └── Info.plist │ ├── example-tvOS │ │ └── Info.plist │ └── example.xcodeproj │ │ ├── xcshareddata │ │ └── xcschemes │ │ │ ├── example.xcscheme │ │ │ └── example-tvOS.xcscheme │ │ └── project.pbxproj ├── index.android.js ├── index.ios.js ├── package.json ├── .gitignore └── .flowconfig ├── assets ├── decrement.png ├── increment.png ├── decrement@2x.png ├── decrement@3x.png ├── increment@2x.png └── increment@3x.png ├── package.json ├── .gitignore ├── .npmignore ├── LICENSE ├── yarn.lock ├── UIStepper.js └── README.md /example/.watchmanconfig: -------------------------------------------------------------------------------- 1 | {} -------------------------------------------------------------------------------- /example/.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | -------------------------------------------------------------------------------- /example/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["react-native"] 3 | } 4 | -------------------------------------------------------------------------------- /example/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "displayName": "example" 4 | } -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'example' 2 | 3 | include ':app' 4 | -------------------------------------------------------------------------------- /assets/decrement.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hannigand/react-native-ui-stepper/HEAD/assets/decrement.png -------------------------------------------------------------------------------- /assets/increment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hannigand/react-native-ui-stepper/HEAD/assets/increment.png -------------------------------------------------------------------------------- /assets/decrement@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hannigand/react-native-ui-stepper/HEAD/assets/decrement@2x.png -------------------------------------------------------------------------------- /assets/decrement@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hannigand/react-native-ui-stepper/HEAD/assets/decrement@3x.png -------------------------------------------------------------------------------- /assets/increment@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hannigand/react-native-ui-stepper/HEAD/assets/increment@2x.png -------------------------------------------------------------------------------- /assets/increment@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hannigand/react-native-ui-stepper/HEAD/assets/increment@3x.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | example 3 | 4 | -------------------------------------------------------------------------------- /example/pages/assets/decrement.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hannigand/react-native-ui-stepper/HEAD/example/pages/assets/decrement.png -------------------------------------------------------------------------------- /example/pages/assets/increment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hannigand/react-native-ui-stepper/HEAD/example/pages/assets/increment.png -------------------------------------------------------------------------------- /example/pages/assets/decrement@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hannigand/react-native-ui-stepper/HEAD/example/pages/assets/decrement@2x.png -------------------------------------------------------------------------------- /example/pages/assets/decrement@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hannigand/react-native-ui-stepper/HEAD/example/pages/assets/decrement@3x.png -------------------------------------------------------------------------------- /example/pages/assets/increment@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hannigand/react-native-ui-stepper/HEAD/example/pages/assets/increment@2x.png -------------------------------------------------------------------------------- /example/pages/assets/increment@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hannigand/react-native-ui-stepper/HEAD/example/pages/assets/increment@3x.png -------------------------------------------------------------------------------- /example/assets/fonts/Bungee-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hannigand/react-native-ui-stepper/HEAD/example/assets/fonts/Bungee-Regular.ttf -------------------------------------------------------------------------------- /example/.buckconfig: -------------------------------------------------------------------------------- 1 | 2 | [android] 3 | target = Google Inc.:Google APIs:23 4 | 5 | [maven_repositories] 6 | central = https://repo1.maven.org/maven2 7 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hannigand/react-native-ui-stepper/HEAD/example/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /example/android/keystores/debug.keystore.properties: -------------------------------------------------------------------------------- 1 | key.store=debug.keystore 2 | key.alias=androiddebugkey 3 | key.store.password=android 4 | key.alias.password=android 5 | -------------------------------------------------------------------------------- /example/android/app/src/main/assets/fonts/Bungee-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hannigand/react-native-ui-stepper/HEAD/example/android/app/src/main/assets/fonts/Bungee-Regular.ttf -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hannigand/react-native-ui-stepper/HEAD/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hannigand/react-native-ui-stepper/HEAD/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hannigand/react-native-ui-stepper/HEAD/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hannigand/react-native-ui-stepper/HEAD/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/components/Header.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {Text} from 'react-native'; 3 | 4 | export default ({text}) => {text} -------------------------------------------------------------------------------- /example/android/keystores/BUCK: -------------------------------------------------------------------------------- 1 | keystore( 2 | name = "debug", 3 | properties = "debug.keystore.properties", 4 | store = "debug.keystore", 5 | visibility = [ 6 | "PUBLIC", 7 | ], 8 | ) 9 | -------------------------------------------------------------------------------- /example/components/Container.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import { ScrollView } from 'react-native'; 3 | 4 | export default ({ children }) => ( 5 | 6 | {children} 7 | 8 | ); 9 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip 6 | -------------------------------------------------------------------------------- /example/components/Item.js: -------------------------------------------------------------------------------- 1 | import React from 'react'; 2 | import {View, TouchableOpacity, Button, Text} from 'react-native'; 3 | 4 | export default ({onPress, children}) => ( 5 | 6 | {children} 7 | 8 | ) -------------------------------------------------------------------------------- /example/__tests__/index.ios.js: -------------------------------------------------------------------------------- 1 | import 'react-native'; 2 | import React from 'react'; 3 | import Index from '../index.ios.js'; 4 | 5 | // Note: test renderer must be required after react-native. 6 | import renderer from 'react-test-renderer'; 7 | 8 | it('renders correctly', () => { 9 | const tree = renderer.create( 10 | 11 | ); 12 | }); 13 | -------------------------------------------------------------------------------- /example/__tests__/index.android.js: -------------------------------------------------------------------------------- 1 | import 'react-native'; 2 | import React from 'react'; 3 | import Index from '../index.android.js'; 4 | 5 | // Note: test renderer must be required after react-native. 6 | import renderer from 'react-test-renderer'; 7 | 8 | it('renders correctly', () => { 9 | const tree = renderer.create( 10 | 11 | ); 12 | }); 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/example/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.example; 2 | 3 | import com.facebook.react.ReactActivity; 4 | 5 | public class MainActivity extends ReactActivity { 6 | 7 | /** 8 | * Returns the name of the main component registered from JavaScript. 9 | * This is used to schedule rendering of the component. 10 | */ 11 | @Override 12 | protected String getMainComponentName() { 13 | return "example"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /example/ios/example/AppDelegate.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | @interface AppDelegate : UIResponder 13 | 14 | @property (nonatomic, strong) UIWindow *window; 15 | 16 | @end 17 | -------------------------------------------------------------------------------- /example/index.android.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sample React Native App 3 | * https://github.com/facebook/react-native 4 | * @flow 5 | */ 6 | 7 | import React, { Component } from 'react'; 8 | import { AppRegistry } from 'react-native'; 9 | import { StackNavigator } from 'react-navigation'; 10 | import MainPage from './pages/MainPage'; 11 | 12 | const Navigation = StackNavigator({ 13 | Main: { screen: MainPage } 14 | }); 15 | 16 | export default class example extends Component { 17 | render() { 18 | return ; 19 | } 20 | } 21 | 22 | AppRegistry.registerComponent('example', () => example); 23 | -------------------------------------------------------------------------------- /example/ios/example/main.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | 12 | #import "AppDelegate.h" 13 | 14 | int main(int argc, char * argv[]) { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /example/index.ios.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Sample React Native App 3 | * https://github.com/facebook/react-native 4 | * @flow 5 | */ 6 | 7 | import React, { Component } from 'react'; 8 | import { AppRegistry } from 'react-native'; 9 | import { StackNavigator } from 'react-navigation'; 10 | import MainPage from './pages/MainPage'; 11 | 12 | const Navigation = StackNavigator({ 13 | Main: {screen: MainPage}, 14 | }); 15 | 16 | export default class example extends Component { 17 | render() { 18 | return ( 19 | 20 | ); 21 | } 22 | } 23 | 24 | 25 | AppRegistry.registerComponent('example', () => example); 26 | -------------------------------------------------------------------------------- /example/android/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.2.3' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | mavenLocal() 18 | jcenter() 19 | maven { 20 | // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm 21 | url "$rootDir/../node_modules/react-native/android" 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "version": "0.0.1", 4 | "private": true, 5 | "scripts": { 6 | "start": "node node_modules/react-native/local-cli/cli.js start", 7 | "test": "jest" 8 | }, 9 | "dependencies": { 10 | "react": "16.0.0-alpha.12", 11 | "react-native": "0.48.4", 12 | "react-native-markdown": "^0.1.1", 13 | "react-native-ui-stepper": "^1.2.3", 14 | "react-navigation": "^1.0.0-beta.13" 15 | }, 16 | "devDependencies": { 17 | "babel-jest": "21.2.0", 18 | "babel-preset-react-native": "4.0.0", 19 | "jest": "21.2.1", 20 | "react-test-renderer": "16.0.0-alpha.12" 21 | }, 22 | "jest": { 23 | "preset": "react-native" 24 | }, 25 | "rnpm": { 26 | "assets": [ 27 | "./assets/fonts" 28 | ] 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /example/ios/exampleTests/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 | -------------------------------------------------------------------------------- /example/ios/example-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 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-ui-stepper", 3 | "version": "1.2.4", 4 | "description": "A react-native implementation of the iOS UIStepper", 5 | "main": "UIStepper.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "repository": { 10 | "type": "git", 11 | "url": "git+https://github.com/hannigand/react-native-ui-stepper.git" 12 | }, 13 | "keywords": [ 14 | "react-native", 15 | "ios", 16 | "android", 17 | "stepper", 18 | "ios-stepper", 19 | "ui-stepper", 20 | "UIStepper", 21 | "uikit-stepper" 22 | ], 23 | "author": "Dan Hannigan", 24 | "license": "MIT", 25 | "bugs": { 26 | "url": "https://github.com/hannigand/react-native-ui-stepper/issues" 27 | }, 28 | "homepage": "https://github.com/hannigand/react-native-ui-stepper#readme", 29 | "dependencies": { 30 | "prop-types": "^15.5.10" 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | 20 | android.useDeprecatedNdk=true 21 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # Xcode 6 | # 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | project.xcworkspace 24 | 25 | # Android/IntelliJ 26 | # 27 | build/ 28 | .idea 29 | .gradle 30 | local.properties 31 | *.iml 32 | 33 | # node.js 34 | # 35 | node_modules/ 36 | npm-debug.log 37 | yarn-error.log 38 | 39 | # BUCK 40 | buck-out/ 41 | \.buckd/ 42 | *.keystore 43 | 44 | # fastlane 45 | # 46 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 47 | # screenshots whenever they are needed. 48 | # For more information about the recommended setup visit: 49 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 50 | 51 | fastlane/report.xml 52 | fastlane/Preview.html 53 | fastlane/screenshots 54 | -------------------------------------------------------------------------------- /example/ios/example/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | } 43 | ], 44 | "info" : { 45 | "version" : 1, 46 | "author" : "xcode" 47 | } 48 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | !**/*.xcodeproj 3 | !**/*.pbxproj 4 | !**/*.xcworkspacedata 5 | !**/*.xcsettings 6 | !**/*.xcscheme 7 | *.pbxuser 8 | !default.pbxuser 9 | *.mode1v3 10 | !default.mode1v3 11 | *.mode2v3 12 | !default.mode2v3 13 | *.perspectivev3 14 | !default.perspectivev3 15 | xcuserdata 16 | *.xccheckout 17 | *.moved-aside 18 | DerivedData 19 | *.hmap 20 | *.ipa 21 | *.xcuserstate 22 | project.xcworkspace 23 | 24 | # Gradle 25 | /build/ 26 | /RNTester/android/app/build/ 27 | /RNTester/android/app/gradle/ 28 | /RNTester/android/app/gradlew 29 | /RNTester/android/app/gradlew.bat 30 | /ReactAndroid/build/ 31 | 32 | # Buck 33 | .buckd 34 | buck-out 35 | /ReactAndroid/src/main/jni/prebuilt/lib/armeabi-v7a/ 36 | /ReactAndroid/src/main/jni/prebuilt/lib/x86/ 37 | /ReactAndroid/src/main/gen 38 | 39 | # Android 40 | .idea 41 | .gradle 42 | local.properties 43 | *.iml 44 | /android/ 45 | 46 | # Node 47 | node_modules 48 | *.log 49 | .nvm 50 | /danger/node_modules/ 51 | 52 | # OS X 53 | .DS_Store 54 | 55 | # Test generated files 56 | /ReactAndroid/src/androidTest/assets/AndroidTestBundle.js 57 | *.js.meta -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | !**/*.xcodeproj 3 | !**/*.pbxproj 4 | !**/*.xcworkspacedata 5 | !**/*.xcsettings 6 | !**/*.xcscheme 7 | *.pbxuser 8 | !default.pbxuser 9 | *.mode1v3 10 | !default.mode1v3 11 | *.mode2v3 12 | !default.mode2v3 13 | *.perspectivev3 14 | !default.perspectivev3 15 | xcuserdata 16 | *.xccheckout 17 | *.moved-aside 18 | DerivedData 19 | *.hmap 20 | *.ipa 21 | *.xcuserstate 22 | project.xcworkspace 23 | 24 | # Gradle 25 | /build/ 26 | /RNTester/android/app/build/ 27 | /RNTester/android/app/gradle/ 28 | /RNTester/android/app/gradlew 29 | /RNTester/android/app/gradlew.bat 30 | /ReactAndroid/build/ 31 | 32 | # Buck 33 | .buckd 34 | buck-out 35 | /ReactAndroid/src/main/jni/prebuilt/lib/armeabi-v7a/ 36 | /ReactAndroid/src/main/jni/prebuilt/lib/x86/ 37 | /ReactAndroid/src/main/gen 38 | 39 | # Android 40 | .idea 41 | .gradle 42 | local.properties 43 | *.iml 44 | /android/ 45 | 46 | # Node 47 | node_modules 48 | *.log 49 | .nvm 50 | /danger/node_modules/ 51 | 52 | # OS X 53 | .DS_Store 54 | 55 | # Test generated files 56 | /ReactAndroid/src/androidTest/assets/AndroidTestBundle.js 57 | *.js.meta 58 | 59 | example -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Dan Hannigan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /example/android/app/src/main/java/com/example/MainApplication.java: -------------------------------------------------------------------------------- 1 | package com.example; 2 | 3 | import android.app.Application; 4 | 5 | import com.facebook.react.ReactApplication; 6 | import com.facebook.react.ReactNativeHost; 7 | import com.facebook.react.ReactPackage; 8 | import com.facebook.react.shell.MainReactPackage; 9 | import com.facebook.soloader.SoLoader; 10 | 11 | import java.util.Arrays; 12 | import java.util.List; 13 | 14 | public class MainApplication extends Application implements ReactApplication { 15 | 16 | private final ReactNativeHost mReactNativeHost = new ReactNativeHost(this) { 17 | @Override 18 | public boolean getUseDeveloperSupport() { 19 | return BuildConfig.DEBUG; 20 | } 21 | 22 | @Override 23 | protected List getPackages() { 24 | return Arrays.asList( 25 | new MainReactPackage() 26 | ); 27 | } 28 | }; 29 | 30 | @Override 31 | public ReactNativeHost getReactNativeHost() { 32 | return mReactNativeHost; 33 | } 34 | 35 | @Override 36 | public void onCreate() { 37 | super.onCreate(); 38 | SoLoader.init(this, /* native exopackage */ false); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 5 | 6 | 7 | 8 | 9 | 12 | 13 | 19 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /example/ios/example/AppDelegate.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import "AppDelegate.h" 11 | 12 | #import 13 | #import 14 | 15 | @implementation AppDelegate 16 | 17 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 18 | { 19 | NSURL *jsCodeLocation; 20 | 21 | jsCodeLocation = [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index.ios" fallbackResource:nil]; 22 | 23 | RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation 24 | moduleName:@"example" 25 | initialProperties:nil 26 | launchOptions:launchOptions]; 27 | rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1]; 28 | 29 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 30 | UIViewController *rootViewController = [UIViewController new]; 31 | rootViewController.view = rootView; 32 | self.window.rootViewController = rootViewController; 33 | [self.window makeKeyAndVisible]; 34 | return YES; 35 | } 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /example/.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | ; We fork some components by platform 3 | .*/*[.]android.js 4 | 5 | ; Ignore "BUCK" generated dirs 6 | /\.buckd/ 7 | 8 | ; Ignore unexpected extra "@providesModule" 9 | .*/node_modules/.*/node_modules/fbjs/.* 10 | 11 | ; Ignore duplicate module providers 12 | ; For RN Apps installed via npm, "Libraries" folder is inside 13 | ; "node_modules/react-native" but in the source repo it is in the root 14 | .*/Libraries/react-native/React.js 15 | .*/Libraries/react-native/ReactNative.js 16 | 17 | [include] 18 | 19 | [libs] 20 | node_modules/react-native/Libraries/react-native/react-native-interface.js 21 | node_modules/react-native/flow 22 | flow/ 23 | 24 | [options] 25 | emoji=true 26 | 27 | module.system=haste 28 | 29 | munge_underscores=true 30 | 31 | module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub' 32 | 33 | suppress_type=$FlowIssue 34 | suppress_type=$FlowFixMe 35 | suppress_type=$FixMe 36 | 37 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(4[0-9]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) 38 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(4[0-9]\\|[1-3][0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ 39 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy 40 | suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError 41 | 42 | unsafe.enable_getters_and_setters=true 43 | 44 | [version] 45 | ^0.49.1 46 | -------------------------------------------------------------------------------- /example/ios/example-tvOS/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UIViewControllerBasedStatusBarAppearance 38 | 39 | NSLocationWhenInUseUsageDescription 40 | 41 | NSAppTransportSecurity 42 | 43 | 44 | NSExceptionDomains 45 | 46 | localhost 47 | 48 | NSExceptionAllowsInsecureHTTPLoads 49 | 50 | 51 | 52 | 53 | 54 | 55 | -------------------------------------------------------------------------------- /example/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 | lib_deps = [] 12 | 13 | for jarfile in glob(['libs/*.jar']): 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 | 21 | for aarfile in glob(['libs/*.aar']): 22 | name = 'aars__' + aarfile[aarfile.rindex('/') + 1: aarfile.rindex('.aar')] 23 | lib_deps.append(':' + name) 24 | android_prebuilt_aar( 25 | name = name, 26 | aar = aarfile, 27 | ) 28 | 29 | android_library( 30 | name = "all-libs", 31 | exported_deps = lib_deps, 32 | ) 33 | 34 | android_library( 35 | name = "app-code", 36 | srcs = glob([ 37 | "src/main/java/**/*.java", 38 | ]), 39 | deps = [ 40 | ":all-libs", 41 | ":build_config", 42 | ":res", 43 | ], 44 | ) 45 | 46 | android_build_config( 47 | name = "build_config", 48 | package = "com.example", 49 | ) 50 | 51 | android_resource( 52 | name = "res", 53 | package = "com.example", 54 | res = "src/main/res", 55 | ) 56 | 57 | android_binary( 58 | name = "app", 59 | keystore = "//android/keystores:debug", 60 | manifest = "src/main/AndroidManifest.xml", 61 | package_type = "debug", 62 | deps = [ 63 | ":app-code", 64 | ], 65 | ) 66 | -------------------------------------------------------------------------------- /example/ios/example/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | example 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) 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 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UIViewControllerBasedStatusBarAppearance 40 | 41 | NSLocationWhenInUseUsageDescription 42 | 43 | NSAppTransportSecurity 44 | 45 | NSExceptionDomains 46 | 47 | localhost 48 | 49 | NSExceptionAllowsInsecureHTTPLoads 50 | 51 | 52 | 53 | 54 | UIAppFonts 55 | 56 | Bungee-Regular.ttf 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /example/ios/exampleTests/exampleTests.m: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) 2015-present, Facebook, Inc. 3 | * All rights reserved. 4 | * 5 | * This source code is licensed under the BSD-style license found in the 6 | * LICENSE file in the root directory of this source tree. An additional grant 7 | * of patent rights can be found in the PATENTS file in the same directory. 8 | */ 9 | 10 | #import 11 | #import 12 | 13 | #import 14 | #import 15 | 16 | #define TIMEOUT_SECONDS 600 17 | #define TEXT_TO_LOOK_FOR @"Welcome to React Native!" 18 | 19 | @interface exampleTests : XCTestCase 20 | 21 | @end 22 | 23 | @implementation exampleTests 24 | 25 | - (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test 26 | { 27 | if (test(view)) { 28 | return YES; 29 | } 30 | for (UIView *subview in [view subviews]) { 31 | if ([self findSubviewInView:subview matching:test]) { 32 | return YES; 33 | } 34 | } 35 | return NO; 36 | } 37 | 38 | - (void)testRendersWelcomeScreen 39 | { 40 | UIViewController *vc = [[[RCTSharedApplication() delegate] window] rootViewController]; 41 | NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; 42 | BOOL foundElement = NO; 43 | 44 | __block NSString *redboxError = nil; 45 | RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { 46 | if (level >= RCTLogLevelError) { 47 | redboxError = message; 48 | } 49 | }); 50 | 51 | while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { 52 | [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 53 | [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; 54 | 55 | foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { 56 | if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { 57 | return YES; 58 | } 59 | return NO; 60 | }]; 61 | } 62 | 63 | RCTSetLogFunction(RCTDefaultLogFunction); 64 | 65 | XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); 66 | XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); 67 | } 68 | 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /example/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /example/android/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | 19 | # Disabling obfuscation is useful if you collect stack traces from production crashes 20 | # (unless you are using a system that supports de-obfuscate the stack traces). 21 | -dontobfuscate 22 | 23 | # React Native 24 | 25 | # Keep our interfaces so they can be used by other ProGuard rules. 26 | # See http://sourceforge.net/p/proguard/bugs/466/ 27 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip 28 | -keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters 29 | -keep,allowobfuscation @interface com.facebook.common.internal.DoNotStrip 30 | 31 | # Do not strip any method/class that is annotated with @DoNotStrip 32 | -keep @com.facebook.proguard.annotations.DoNotStrip class * 33 | -keep @com.facebook.common.internal.DoNotStrip class * 34 | -keepclassmembers class * { 35 | @com.facebook.proguard.annotations.DoNotStrip *; 36 | @com.facebook.common.internal.DoNotStrip *; 37 | } 38 | 39 | -keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * { 40 | void set*(***); 41 | *** get*(); 42 | } 43 | 44 | -keep class * extends com.facebook.react.bridge.JavaScriptModule { *; } 45 | -keep class * extends com.facebook.react.bridge.NativeModule { *; } 46 | -keepclassmembers,includedescriptorclasses class * { native ; } 47 | -keepclassmembers class * { @com.facebook.react.uimanager.UIProp ; } 48 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp ; } 49 | -keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup ; } 50 | 51 | -dontwarn com.facebook.react.** 52 | 53 | # TextLayoutBuilder uses a non-public Android constructor within StaticLayout. 54 | # See libs/proxy/src/main/java/com/facebook/fbui/textlayoutbuilder/proxy for details. 55 | -dontwarn android.text.StaticLayout 56 | 57 | # okhttp 58 | 59 | -keepattributes Signature 60 | -keepattributes *Annotation* 61 | -keep class okhttp3.** { *; } 62 | -keep interface okhttp3.** { *; } 63 | -dontwarn okhttp3.** 64 | 65 | # okio 66 | 67 | -keep class sun.misc.Unsafe { *; } 68 | -dontwarn java.nio.file.* 69 | -dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement 70 | -dontwarn okio.** 71 | -------------------------------------------------------------------------------- /yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | asap@~2.0.3: 6 | version "2.0.6" 7 | resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46" 8 | 9 | core-js@^1.0.0: 10 | version "1.2.7" 11 | resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636" 12 | 13 | encoding@^0.1.11: 14 | version "0.1.12" 15 | resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb" 16 | dependencies: 17 | iconv-lite "~0.4.13" 18 | 19 | fbjs@^0.8.9: 20 | version "0.8.14" 21 | resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.14.tgz#d1dbe2be254c35a91e09f31f9cd50a40b2a0ed1c" 22 | dependencies: 23 | core-js "^1.0.0" 24 | isomorphic-fetch "^2.1.1" 25 | loose-envify "^1.0.0" 26 | object-assign "^4.1.0" 27 | promise "^7.1.1" 28 | setimmediate "^1.0.5" 29 | ua-parser-js "^0.7.9" 30 | 31 | iconv-lite@~0.4.13: 32 | version "0.4.18" 33 | resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.18.tgz#23d8656b16aae6742ac29732ea8f0336a4789cf2" 34 | 35 | is-stream@^1.0.1: 36 | version "1.1.0" 37 | resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" 38 | 39 | isomorphic-fetch@^2.1.1: 40 | version "2.2.1" 41 | resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz#611ae1acf14f5e81f729507472819fe9733558a9" 42 | dependencies: 43 | node-fetch "^1.0.1" 44 | whatwg-fetch ">=0.10.0" 45 | 46 | js-tokens@^3.0.0: 47 | version "3.0.2" 48 | resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" 49 | 50 | loose-envify@^1.0.0, loose-envify@^1.3.1: 51 | version "1.3.1" 52 | resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848" 53 | dependencies: 54 | js-tokens "^3.0.0" 55 | 56 | node-fetch@^1.0.1: 57 | version "1.7.1" 58 | resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.1.tgz#899cb3d0a3c92f952c47f1b876f4c8aeabd400d5" 59 | dependencies: 60 | encoding "^0.1.11" 61 | is-stream "^1.0.1" 62 | 63 | object-assign@^4.1.0: 64 | version "4.1.1" 65 | resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" 66 | 67 | promise@^7.1.1: 68 | version "7.3.1" 69 | resolved "https://registry.yarnpkg.com/promise/-/promise-7.3.1.tgz#064b72602b18f90f29192b8b1bc418ffd1ebd3bf" 70 | dependencies: 71 | asap "~2.0.3" 72 | 73 | prop-types@^15.5.10: 74 | version "15.5.10" 75 | resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.5.10.tgz#2797dfc3126182e3a95e3dfbb2e893ddd7456154" 76 | dependencies: 77 | fbjs "^0.8.9" 78 | loose-envify "^1.3.1" 79 | 80 | setimmediate@^1.0.5: 81 | version "1.0.5" 82 | resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" 83 | 84 | ua-parser-js@^0.7.9: 85 | version "0.7.14" 86 | resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.14.tgz#110d53fa4c3f326c121292bbeac904d2e03387ca" 87 | 88 | whatwg-fetch@>=0.10.0: 89 | version "2.0.3" 90 | resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz#9c84ec2dcf68187ff00bc64e1274b442176e1c84" 91 | -------------------------------------------------------------------------------- /example/ios/example/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 | -------------------------------------------------------------------------------- /example/ios/example.xcodeproj/xcshareddata/xcschemes/example.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 | -------------------------------------------------------------------------------- /example/ios/example.xcodeproj/xcshareddata/xcschemes/example-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 | -------------------------------------------------------------------------------- /example/android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | 3 | import com.android.build.OutputFile 4 | 5 | /** 6 | * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets 7 | * and bundleReleaseJsAndAssets). 8 | * These basically call `react-native bundle` with the correct arguments during the Android build 9 | * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the 10 | * bundle directly from the development server. Below you can see all the possible configurations 11 | * and their defaults. If you decide to add a configuration block, make sure to add it before the 12 | * `apply from: "../../node_modules/react-native/react.gradle"` line. 13 | * 14 | * project.ext.react = [ 15 | * // the name of the generated asset file containing your JS bundle 16 | * bundleAssetName: "index.android.bundle", 17 | * 18 | * // the entry file for bundle generation 19 | * entryFile: "index.android.js", 20 | * 21 | * // whether to bundle JS and assets in debug mode 22 | * bundleInDebug: false, 23 | * 24 | * // whether to bundle JS and assets in release mode 25 | * bundleInRelease: true, 26 | * 27 | * // whether to bundle JS and assets in another build variant (if configured). 28 | * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants 29 | * // The configuration property can be in the following formats 30 | * // 'bundleIn${productFlavor}${buildType}' 31 | * // 'bundleIn${buildType}' 32 | * // bundleInFreeDebug: true, 33 | * // bundleInPaidRelease: true, 34 | * // bundleInBeta: true, 35 | * 36 | * // whether to disable dev mode in custom build variants (by default only disabled in release) 37 | * // for example: to disable dev mode in the staging build type (if configured) 38 | * devDisabledInStaging: true, 39 | * // The configuration property can be in the following formats 40 | * // 'devDisabledIn${productFlavor}${buildType}' 41 | * // 'devDisabledIn${buildType}' 42 | * 43 | * // the root of your project, i.e. where "package.json" lives 44 | * root: "../../", 45 | * 46 | * // where to put the JS bundle asset in debug mode 47 | * jsBundleDirDebug: "$buildDir/intermediates/assets/debug", 48 | * 49 | * // where to put the JS bundle asset in release mode 50 | * jsBundleDirRelease: "$buildDir/intermediates/assets/release", 51 | * 52 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 53 | * // require('./image.png')), in debug mode 54 | * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug", 55 | * 56 | * // where to put drawable resources / React Native assets, e.g. the ones you use via 57 | * // require('./image.png')), in release mode 58 | * resourcesDirRelease: "$buildDir/intermediates/res/merged/release", 59 | * 60 | * // by default the gradle tasks are skipped if none of the JS files or assets change; this means 61 | * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to 62 | * // date; if you have any other folders that you want to ignore for performance reasons (gradle 63 | * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/ 64 | * // for example, you might want to remove it from here. 65 | * inputExcludes: ["android/**", "ios/**"], 66 | * 67 | * // override which node gets called and with what additional arguments 68 | * nodeExecutableAndArgs: ["node"], 69 | * 70 | * // supply additional arguments to the packager 71 | * extraPackagerArgs: [] 72 | * ] 73 | */ 74 | 75 | apply from: "../../node_modules/react-native/react.gradle" 76 | 77 | /** 78 | * Set this to true to create two separate APKs instead of one: 79 | * - An APK that only works on ARM devices 80 | * - An APK that only works on x86 devices 81 | * The advantage is the size of the APK is reduced by about 4MB. 82 | * Upload all the APKs to the Play Store and people will download 83 | * the correct one based on the CPU architecture of their device. 84 | */ 85 | def enableSeparateBuildPerCPUArchitecture = false 86 | 87 | /** 88 | * Run Proguard to shrink the Java bytecode in release builds. 89 | */ 90 | def enableProguardInReleaseBuilds = false 91 | 92 | android { 93 | compileSdkVersion 23 94 | buildToolsVersion "23.0.1" 95 | 96 | defaultConfig { 97 | applicationId "com.example" 98 | minSdkVersion 16 99 | targetSdkVersion 22 100 | versionCode 1 101 | versionName "1.0" 102 | ndk { 103 | abiFilters "armeabi-v7a", "x86" 104 | } 105 | } 106 | splits { 107 | abi { 108 | reset() 109 | enable enableSeparateBuildPerCPUArchitecture 110 | universalApk false // If true, also generate a universal APK 111 | include "armeabi-v7a", "x86" 112 | } 113 | } 114 | buildTypes { 115 | release { 116 | minifyEnabled enableProguardInReleaseBuilds 117 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 118 | } 119 | } 120 | // applicationVariants are e.g. debug, release 121 | applicationVariants.all { variant -> 122 | variant.outputs.each { output -> 123 | // For each separate APK per architecture, set a unique version code as described here: 124 | // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits 125 | def versionCodes = ["armeabi-v7a":1, "x86":2] 126 | def abi = output.getFilter(OutputFile.ABI) 127 | if (abi != null) { // null for the universal-debug, universal-release variants 128 | output.versionCodeOverride = 129 | versionCodes.get(abi) * 1048576 + defaultConfig.versionCode 130 | } 131 | } 132 | } 133 | } 134 | 135 | dependencies { 136 | compile fileTree(dir: "libs", include: ["*.jar"]) 137 | compile "com.android.support:appcompat-v7:23.0.1" 138 | compile "com.facebook.react:react-native:+" // From node_modules 139 | } 140 | 141 | // Run this once to be able to run the application with BUCK 142 | // puts all compile dependencies into folder libs for BUCK to use 143 | task copyDownloadableDepsToLibs(type: Copy) { 144 | from configurations.compile 145 | into 'libs' 146 | } 147 | -------------------------------------------------------------------------------- /UIStepper.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { View, StyleSheet, TouchableOpacity, Image, Text } from 'react-native'; 3 | import PropTypes from 'prop-types'; 4 | 5 | const styles = StyleSheet.create({ 6 | container: { 7 | flexDirection: 'row', 8 | }, 9 | button: { 10 | flex: 1, 11 | justifyContent: 'center', 12 | alignItems: 'center', 13 | }, 14 | valueContainer: { 15 | flex: 1, 16 | justifyContent: 'center', 17 | alignItems: 'center', 18 | }, 19 | }); 20 | 21 | class UIStepper extends Component { 22 | static propTypes = { 23 | initialValue: PropTypes.number, 24 | value: PropTypes.number, 25 | minimumValue: PropTypes.number, 26 | maximumValue: PropTypes.number, 27 | steps: PropTypes.number, 28 | tintColor: PropTypes.string, 29 | backgroundColor: PropTypes.string, 30 | decrementImage: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), 31 | incrementImage: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), 32 | imageWidth: PropTypes.number, 33 | imageHeight: PropTypes.number, 34 | width: PropTypes.number, 35 | height: PropTypes.number, 36 | borderColor: PropTypes.string, 37 | borderWidth: PropTypes.number, 38 | borderRadius: PropTypes.number, 39 | onValueChange: PropTypes.func, 40 | onDecrement: PropTypes.func, 41 | onIncrement: PropTypes.func, 42 | onMinimumReached: PropTypes.func, 43 | onMaximumReached: PropTypes.func, 44 | wraps: PropTypes.bool, 45 | displayValue: PropTypes.bool, 46 | textColor: PropTypes.string, 47 | fontSize: PropTypes.number, 48 | overrideTintColor: PropTypes.bool, 49 | vertical: PropTypes.bool, 50 | displayDecrementFirst: PropTypes.bool, 51 | fontFamily: PropTypes.string, 52 | innerRef: PropTypes.func, 53 | }; 54 | static defaultProps = { 55 | initialValue: 0, 56 | value: 0, 57 | minimumValue: 0, 58 | maximumValue: 100, 59 | steps: 1, 60 | tintColor: '#0076FF', 61 | backgroundColor: 'transparent', 62 | decrementImage: require('./assets/decrement.png'), 63 | incrementImage: require('./assets/increment.png'), 64 | imageWidth: 20, 65 | imageHeight: 15, 66 | width: 94, 67 | height: 29, 68 | borderColor: '#0076FF', 69 | borderWidth: 1, 70 | borderRadius: 4, 71 | onValueChange: null, 72 | onDecrement: null, 73 | onIncrement: null, 74 | onMinimumReached: null, 75 | onMaximumReached: null, 76 | wraps: false, 77 | displayValue: false, 78 | textColor: '#0076FF', 79 | fontSize: 15, 80 | overrideTintColor: false, 81 | vertical: false, 82 | displayDecrementFirst: false, 83 | fontFamily: 'System', 84 | innerRef: null, 85 | }; 86 | constructor(props) { 87 | super(props); 88 | this.state = { 89 | value: props.initialValue, 90 | }; 91 | } 92 | componentDidMount() { 93 | const { innerRef } = this.props; 94 | if (innerRef) { 95 | innerRef(this); 96 | } 97 | } 98 | componentWillUnmount() { 99 | const { innerRef } = this.props; 100 | if (innerRef) { 101 | innerRef(undefined); 102 | } 103 | } 104 | componentWillReceiveProps(nextProps) { 105 | const { value: currentValue } = this.props; 106 | const { value: nextValue } = nextProps; 107 | if (currentValue !== nextValue) { 108 | this.setState({ 109 | value: nextValue, 110 | }); 111 | } 112 | } 113 | decrement = () => { 114 | const { steps, onDecrement } = this.props; 115 | let value = this.state.value; 116 | value -= steps; 117 | this.validate(value, onDecrement); 118 | }; 119 | increment = () => { 120 | const { steps, onIncrement } = this.props; 121 | let value = this.state.value; 122 | value += steps; 123 | this.validate(value, onIncrement); 124 | }; 125 | isExternalImage = image => typeof image === 'string'; 126 | resolveImage = image => { 127 | if (this.isExternalImage(image)) { 128 | return { uri: image }; 129 | } 130 | return image; 131 | }; 132 | resolveStyles = image => { 133 | const { 134 | tintColor, 135 | height, 136 | width, 137 | overrideTintColor, 138 | imageHeight, 139 | imageWidth, 140 | buttonPadding, 141 | } = this.props; 142 | const containerHeight = height / 3; 143 | const containerWidth = width / 3; 144 | 145 | if (this.isExternalImage(image)) { 146 | const styles = { 147 | flex: 1, 148 | alignSelf: 'stretch', 149 | width: this.getImageWidth(), 150 | height: this.getImageHeight(), 151 | alignSelf: 'center', 152 | }; 153 | if (overrideTintColor) { 154 | styles.tintColor = tintColor; 155 | } 156 | return styles; 157 | } 158 | return { 159 | tintColor, 160 | width: this.getImageWidth(), 161 | height: this.getImageHeight(), 162 | }; 163 | }; 164 | getImageHeight = () => { 165 | const { imageHeight, height } = this.props; 166 | const containerHeight = height; 167 | 168 | if (imageHeight > containerHeight) { 169 | return height; 170 | } 171 | return imageHeight; 172 | }; 173 | getImageWidth = () => { 174 | const { imageWidth, width } = this.props; 175 | const containerWidth = width / 3; 176 | 177 | if (imageWidth > containerWidth) { 178 | return containerWidth; 179 | } 180 | return imageWidth; 181 | }; 182 | validate = (value, callback) => { 183 | const { 184 | minimumValue: min, 185 | maximumValue: max, 186 | onValueChange, 187 | onMinimumReached, 188 | onMaximumReached, 189 | wraps, 190 | } = this.props; 191 | if (min <= value && max >= value) { 192 | this.setState({ 193 | value 194 | }); 195 | if (onValueChange) { 196 | onValueChange(value); 197 | } 198 | if (callback) { 199 | callback(value); 200 | } 201 | return; 202 | } 203 | if (value < min) { 204 | if (wraps) { 205 | this.setState({ 206 | value: max, 207 | }); 208 | if (onValueChange) { 209 | onValueChange(max); 210 | } 211 | if (callback) { 212 | callback(max); 213 | } 214 | return; 215 | } 216 | onMinimumReached && onMinimumReached(value); 217 | } 218 | if (value > max) { 219 | if (wraps) { 220 | this.setState({ 221 | value: min, 222 | }); 223 | if (onValueChange) { 224 | onValueChange(min); 225 | } 226 | if (callback) { 227 | callback(min); 228 | } 229 | return; 230 | } 231 | onMaximumReached && onMaximumReached(value); 232 | } 233 | }; 234 | setValue = (value, callback) => { 235 | const { onValueChange } = this.props; 236 | this.setState({ 237 | value: value, 238 | }); 239 | if (onValueChange) { 240 | onValueChange(value); 241 | } 242 | if (callback) { 243 | callback(value); 244 | } 245 | }; 246 | resetValue = () => { 247 | const { initialValue } = this.props; 248 | this.setState({ 249 | value: initialValue, 250 | }); 251 | }; 252 | render() { 253 | const { 254 | tintColor, 255 | backgroundColor, 256 | decrementImage, 257 | dividerImage, 258 | incrementImage, 259 | imageWidth, 260 | imageHeight, 261 | width, 262 | height, 263 | borderColor, 264 | borderWidth, 265 | borderRadius, 266 | displayValue, 267 | textColor, 268 | fontSize, 269 | vertical, 270 | displayDecrementFirst, 271 | fontFamily, 272 | } = this.props; 273 | return ( 274 | 290 | 301 | 306 | 307 | {displayValue && ( 308 | 309 | 310 | {this.state.value} 311 | 312 | 313 | )} 314 | 325 | 330 | 331 | 332 | ); 333 | } 334 | } 335 | 336 | export default UIStepper; 337 | -------------------------------------------------------------------------------- /example/pages/UIStepper.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { View, StyleSheet, TouchableOpacity, Image, Text } from 'react-native'; 3 | import PropTypes from 'prop-types'; 4 | 5 | const styles = StyleSheet.create({ 6 | container: { 7 | flexDirection: 'row', 8 | }, 9 | button: { 10 | flex: 1, 11 | justifyContent: 'center', 12 | alignItems: 'center', 13 | }, 14 | valueContainer: { 15 | flex: 1, 16 | justifyContent: 'center', 17 | alignItems: 'center', 18 | }, 19 | }); 20 | 21 | class UIStepper extends Component { 22 | static propTypes = { 23 | initialValue: PropTypes.number, 24 | value: PropTypes.number, 25 | minimumValue: PropTypes.number, 26 | maximumValue: PropTypes.number, 27 | steps: PropTypes.number, 28 | tintColor: PropTypes.string, 29 | backgroundColor: PropTypes.string, 30 | decrementImage: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), 31 | incrementImage: PropTypes.oneOfType([PropTypes.number, PropTypes.string]), 32 | imageWidth: PropTypes.number, 33 | imageHeight: PropTypes.number, 34 | width: PropTypes.number, 35 | height: PropTypes.number, 36 | borderColor: PropTypes.string, 37 | borderWidth: PropTypes.number, 38 | borderRadius: PropTypes.number, 39 | onValueChange: PropTypes.func, 40 | onDecrement: PropTypes.func, 41 | onIncrement: PropTypes.func, 42 | onMinimumReached: PropTypes.func, 43 | onMaximumReached: PropTypes.func, 44 | wraps: PropTypes.bool, 45 | displayValue: PropTypes.bool, 46 | textColor: PropTypes.string, 47 | fontSize: PropTypes.number, 48 | overrideTintColor: PropTypes.bool, 49 | vertical: PropTypes.bool, 50 | displayDecrementFirst: PropTypes.bool, 51 | fontFamily: PropTypes.string, 52 | innerRef: PropTypes.func, 53 | }; 54 | static defaultProps = { 55 | initialValue: 0, 56 | value: 0, 57 | minimumValue: 0, 58 | maximumValue: 100, 59 | steps: 1, 60 | tintColor: '#0076FF', 61 | backgroundColor: 'transparent', 62 | decrementImage: require('./assets/decrement.png'), 63 | incrementImage: require('./assets/increment.png'), 64 | imageWidth: 20, 65 | imageHeight: 15, 66 | width: 94, 67 | height: 29, 68 | borderColor: '#0076FF', 69 | borderWidth: 1, 70 | borderRadius: 4, 71 | onValueChange: null, 72 | onDecrement: null, 73 | onIncrement: null, 74 | onMinimumReached: null, 75 | onMaximumReached: null, 76 | wraps: false, 77 | displayValue: false, 78 | textColor: '#0076FF', 79 | fontSize: 15, 80 | overrideTintColor: false, 81 | vertical: false, 82 | displayDecrementFirst: false, 83 | fontFamily: 'System', 84 | innerRef: null, 85 | }; 86 | constructor(props) { 87 | super(props); 88 | this.state = { 89 | value: props.initialValue, 90 | }; 91 | } 92 | componentDidMount() { 93 | const { innerRef } = this.props; 94 | if (innerRef) { 95 | innerRef(this); 96 | } 97 | } 98 | componentWillUnmount() { 99 | const { innerRef } = this.props; 100 | if (innerRef) { 101 | innerRef(undefined); 102 | } 103 | } 104 | componentWillReceiveProps(nextProps) { 105 | const { value: currentValue } = this.props; 106 | const { value: nextValue } = nextProps; 107 | if (currentValue !== nextValue) { 108 | this.setState({ 109 | value: nextValue, 110 | }); 111 | } 112 | } 113 | decrement = () => { 114 | const { steps, onDecrement } = this.props; 115 | let value = this.state.value; 116 | value -= steps; 117 | this.validate(value, onDecrement); 118 | }; 119 | increment = () => { 120 | const { steps, onIncrement } = this.props; 121 | let value = this.state.value; 122 | value += steps; 123 | this.validate(value, onIncrement); 124 | }; 125 | isExternalImage = image => typeof image === 'string'; 126 | resolveImage = image => { 127 | if (this.isExternalImage(image)) { 128 | return { uri: image }; 129 | } 130 | return image; 131 | }; 132 | resolveStyles = image => { 133 | const { 134 | tintColor, 135 | height, 136 | width, 137 | overrideTintColor, 138 | imageHeight, 139 | imageWidth, 140 | buttonPadding, 141 | } = this.props; 142 | const containerHeight = height / 3; 143 | const containerWidth = width / 3; 144 | 145 | if (this.isExternalImage(image)) { 146 | const styles = { 147 | flex: 1, 148 | alignSelf: 'stretch', 149 | width: this.getImageWidth(), 150 | height: this.getImageHeight(), 151 | alignSelf: 'center', 152 | }; 153 | if (overrideTintColor) { 154 | styles.tintColor = tintColor; 155 | } 156 | return styles; 157 | } 158 | return { 159 | tintColor, 160 | width: this.getImageWidth(), 161 | height: this.getImageHeight(), 162 | }; 163 | }; 164 | getImageHeight = () => { 165 | const { imageHeight, height } = this.props; 166 | const containerHeight = height; 167 | 168 | if (imageHeight > containerHeight) { 169 | return height; 170 | } 171 | return imageHeight; 172 | }; 173 | getImageWidth = () => { 174 | const { imageWidth, width } = this.props; 175 | const containerWidth = width / 3; 176 | 177 | if (imageWidth > containerWidth) { 178 | return containerWidth; 179 | } 180 | return imageWidth; 181 | }; 182 | validate = (value, callback) => { 183 | const { 184 | minimumValue: min, 185 | maximumValue: max, 186 | onValueChange, 187 | onMinimumReached, 188 | onMaximumReached, 189 | wraps, 190 | } = this.props; 191 | if (min <= value && max >= value) { 192 | this.setState({ 193 | value, 194 | }); 195 | if (onValueChange) { 196 | onValueChange(value); 197 | } 198 | if (callback) { 199 | callback(value); 200 | } 201 | return; 202 | } 203 | if (value < min) { 204 | if (wraps) { 205 | this.setState({ 206 | value: max, 207 | }); 208 | if (onValueChange) { 209 | onValueChange(max); 210 | } 211 | if (callback) { 212 | callback(max); 213 | } 214 | return; 215 | } 216 | onMinimumReached && onMinimumReached(value); 217 | } 218 | if (value > max) { 219 | if (wraps) { 220 | this.setState({ 221 | value: min, 222 | }); 223 | if (onValueChange) { 224 | onValueChange(min); 225 | } 226 | if (callback) { 227 | callback(min); 228 | } 229 | return; 230 | } 231 | onMaximumReached && onMaximumReached(value); 232 | } 233 | }; 234 | setValue = (value, callback) => { 235 | const { onValueChange } = this.props; 236 | this.setState({ 237 | value: value, 238 | }); 239 | if (onValueChange) { 240 | onValueChange(value); 241 | } 242 | if (callback) { 243 | callback(value); 244 | } 245 | }; 246 | resetValue = () => { 247 | const { initialValue } = this.props; 248 | this.setState({ 249 | value: initialValue, 250 | }); 251 | }; 252 | render() { 253 | const { 254 | tintColor, 255 | backgroundColor, 256 | decrementImage, 257 | dividerImage, 258 | incrementImage, 259 | imageWidth, 260 | imageHeight, 261 | width, 262 | height, 263 | borderColor, 264 | borderWidth, 265 | borderRadius, 266 | displayValue, 267 | textColor, 268 | fontSize, 269 | vertical, 270 | displayDecrementFirst, 271 | fontFamily, 272 | } = this.props; 273 | return ( 274 | 290 | 301 | 306 | 307 | {displayValue && ( 308 | 309 | 310 | {this.state.value} 311 | 312 | 313 | )} 314 | 325 | 330 | 331 | 332 | ); 333 | } 334 | } 335 | 336 | export default UIStepper; 337 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # react-native-ui-stepper 2 | 3 | [![npm version](https://img.shields.io/npm/v/react-native-ui-stepper.svg)](https://www.npmjs.com/package/react-native-ui-stepper) 4 | [![npm version](https://img.shields.io/npm/dt/react-native-ui-stepper.svg)](https://img.shields.io/npm/dt/react-native-ui-stepper.svg) 5 | 6 | ![Examples](https://i.imgur.com/D7OdHoh.png "Examples") 7 | 8 | A react-native component which mirrors the functionality of [UIStepper](https://developer.apple.com/reference/uikit/uistepper) from iOS. 9 | 10 | > A stepper control provides a user interface for incrementing or decrementing a value. A stepper displays two buttons, one with a minus (“–”) symbol and one with a plus (“+”) symbol. 11 | 12 | **You can now configure your react-native-ui-stepper to be vertical** 13 | 14 | ## Installation 15 | 16 | `npm i react-native-ui-stepper` 17 | 18 | ## Usage 19 | 20 | ```javascript 21 | import UIStepper from 'react-native-ui-stepper'; 22 | ... 23 | setValue = (value) => { 24 | // do something with value 25 | } 26 | render() { 27 | return ( 28 | { this.setValue(value) }} 30 | /> 31 | ) 32 | } 33 | ``` 34 | 35 | You can now use custom images, from your local file system or from the Internet. See [Props](#props) for more details. 36 | 37 | ## Demo 38 | 39 | ![Demo example](http://g.recordit.co/ipvGlYfRpa.gif "Demo example") 40 | 41 | ## Props 42 | 43 | | Name | Type | Description | Default | 44 | | ----------------------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- | 45 | | `initialValue` | Number | Start value | 0 | 46 | | `value` | Number | Forcibly override the value | 0 | 47 | | `minimumValue` | Number | Minimum value | 0 | 48 | | `maximumValue` | Number | Maximum value | 100 | 49 | | `steps` | Number | Increment value | 1 | 50 | | `displayValue` | Boolean | Displays the stepper value between the increment and decrement button | false | 51 | | `incrementImage` | String or Number | Override the default increment image | require('./assets/increment.png') | 52 | | `decrementImage` | String or Number | Override the default decrement image | require('./assets/decrement.png') | 53 | | `wraps` | Boolean | When set to true, incrementing beyond the `maximumValue` will set the value to `minimumValue` and vice versa | false | 54 | | `tintColor` | String | Changes the color of all the non-transparent pixels to the tintColor. | #0076FF | 55 | | `overrideTintColor` | Boolean | When using an external image, set whether you want the tintColor to be applied to non-transparent pixels. | false | 56 | | `backgroundColor` | String | Background color | transparent | 57 | | `vertical` | Boolean | Display a vertical UI Stepper. You **must** specify a height and a width. | false | 58 | | `displayDecrementFirst` | Boolean | Display the decrement button above the increment button, only works when `vertical` is `true` | false | 59 | | `width` | Number | Width | 94 | 60 | | `height` | Number | Height | 29 | 61 | | `textColor` | String | The desired text colour which will be used when `displayValue` is set to `true` | #0076FF | 62 | | `fontFamily` | String | The font family used on the value displayed when `displayValue` is set to `true` | System | 63 | | `fontSize` | Number | The font size used on the value displayed when `displayValue` is set to `true` | 15 | 64 | | `borderColor` | String | Color used for the border | #0076FF | 65 | | `borderWidth` | Number | Width of the border | 1 | 66 | | `borderRadius` | Number | Radius of the border | 4 | 67 | | `onValueChange` | Function | Executed when the value changes. The value is passed as a parameter | null | 68 | | `onIncrement` | Function | Executed when the User clicks the increment (+) button. The value is passed as a parameter | null | 69 | | `onDecrement` | Function | Executed when the User clicks the decrement (+) button. The value is passed as a parameter | null | 70 | | `onMinimumReached` | Function | Executed when the `minimumValue` is reached. The value is passed as a parameter | null | 71 | | `onMaximumReached` | Function | Executed when the `maximumValue` is reached. The value is passed as a parameter | null | 72 | | `innerRef` | Function | A reference to the rendered UIStepper. You can use this to gain access to class-based methods. `increment()`, `decrement()`, `resetValue()` and `setValue()` are most commonly used | null | 73 | 74 | ## Contributing 75 | 76 | There are no requirements for contributing to the react-native-ui-stepper package. You can [browse](https://github.com/hannigand/react-native-ui-stepper/issues/) or raise issues that you are would like to contribute to. 77 | 78 | 1. Fork the repository on Github 79 | 2. Clone the project 80 | 3. Commit changes to your forked branch 81 | 4. Push your changes to your branch 82 | 5. Submit a Pull Request so that it can be merged into react-native-ui-stepper 83 | 84 | ## Run Example 85 | 86 | ``` 87 | $ git clone https://github.com/hannigand/react-native-ui-stepper.git 88 | $ cd example 89 | $ yarn # or npm install 90 | $ react-native run-ios 91 | ``` 92 | -------------------------------------------------------------------------------- /example/pages/MainPage.js: -------------------------------------------------------------------------------- 1 | import React, { Component } from 'react'; 2 | import { Text, View, TouchableOpacity, Linking, Button } from 'react-native'; 3 | import UIStepper from './UIStepper'; 4 | 5 | import Container from '../components/Container'; 6 | import Header from '../components/Header'; 7 | import Item from '../components/Item'; 8 | 9 | class MainPage extends Component { 10 | static navigationOptions = { 11 | title: 'Welcome', 12 | }; 13 | constructor() { 14 | super(); 15 | this.state = { 16 | value: 0, 17 | }; 18 | } 19 | componentDidMount() { 20 | setInterval(() => { 21 | this.setState({ value: this.state.value + 1 }); 22 | }, 1500); 23 | } 24 | increment = () => { 25 | this.setState({ value: this.state.value + 1 }); 26 | }; 27 | decrement = () => { 28 | this.setState({ value: this.state.value - 1 }); 29 | }; 30 | render() { 31 | return ( 32 | 33 | 34 |
35 | 36 | 37 | Basic usage 38 | 39 | 40 | 41 | 42 | Display stepper value 43 | 44 | 45 | 46 | 52 | 53 | Custom colors 54 | 55 | 56 | 57 | 64 | 65 | Custom Font Family 66 | 67 | 68 | 69 | 75 | 76 | Custom colors (all different) 77 | 78 | 79 | 80 | 87 | 88 | Custom colors (all the same), large font 89 | 90 | 91 | 92 | 97 | 98 | Rounded off corners 99 | 100 | 101 | 102 | 108 | 109 | Recolor images 110 | 111 | 112 | 113 | 121 | 122 | Custom images 123 | 124 | 125 | 126 | 133 | 134 | This uses two images from Iconfinder, loaded over the Internet 135 | 136 | 137 | 138 | 147 | 148 | This uses SAME two images as the above, from Iconfinder, loaded 149 | over the Internet 150 | 151 | 152 | 153 | 161 | 162 | Mixture of a local and network image 163 | 164 | 165 | 166 | 167 | 168 | Basic usage - vertical (Just add a 'vertical' prop) 169 | 170 | 171 | 172 | 182 | 183 | Mixture of a local and network image 184 | 185 | 186 | 187 | 198 | 199 | Display the decrement button above the increment 200 | 201 | 202 | 203 | { 206 | this.stepper = stepper; 207 | }} 208 | /> 209 |