├── .gitattributes ├── example ├── windows │ ├── SliderTestWindows │ │ ├── .gitignore │ │ ├── pch.cpp │ │ ├── App.idl │ │ ├── Assets │ │ │ ├── StoreLogo.png │ │ │ ├── SplashScreen.scale-200.png │ │ │ ├── LockScreenLogo.scale-200.png │ │ │ ├── Square44x44Logo.scale-200.png │ │ │ ├── Wide310x150Logo.scale-200.png │ │ │ ├── Square150x150Logo.scale-200.png │ │ │ └── Square44x44Logo.targetsize-24_altform-unplated.png │ │ ├── SliderTestWindows_TemporaryKey.pfx │ │ ├── packages.config │ │ ├── App.h │ │ ├── AutolinkedNativeModules.g.h │ │ ├── AutolinkedNativeModules.g.cpp │ │ ├── App.xaml │ │ ├── ReactPackageProvider.cpp │ │ ├── ReactPackageProvider.h │ │ ├── PropertySheet.props │ │ ├── pch.h │ │ ├── App.cpp │ │ ├── Package.appxmanifest │ │ ├── SliderTestWindows.vcxproj.filters │ │ └── SliderTestWindows.vcxproj │ └── .gitignore ├── slider.png ├── twitter.png ├── slider-left.png ├── slider-right.png ├── sliderWindows.JPG ├── uie_thumb_big.png ├── android │ ├── 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 │ │ │ │ │ │ └── example │ │ │ │ │ │ ├── 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 │ ├── gradle.properties │ ├── build.gradle │ ├── gradlew.bat │ └── gradlew ├── ios │ ├── example │ │ ├── Images.xcassets │ │ │ ├── Contents.json │ │ │ └── AppIcon.appiconset │ │ │ │ └── Contents.json │ │ ├── AppDelegate.h │ │ ├── main.m │ │ ├── AppDelegate.m │ │ ├── Info.plist │ │ └── Base.lproj │ │ │ └── LaunchScreen.xib │ ├── example.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── Podfile │ └── example.xcodeproj │ │ └── xcshareddata │ │ └── xcschemes │ │ ├── example.xcscheme │ │ └── example-tvOS.xcscheme ├── app.json ├── babel.config.js ├── e2e │ ├── testCases │ │ └── example.e2e.js │ ├── config.json │ └── init.js ├── index.js ├── index.web.js ├── react-native.config.js ├── package.json ├── App.js ├── metro.config.windows.js └── SliderExample.js ├── src ├── windows │ └── SliderWindows │ │ ├── pch.cpp │ │ ├── pch.h │ │ ├── SliderWindows.def │ │ ├── packages.config │ │ ├── ReactPackageProvider.idl │ │ ├── SliderView.idl │ │ ├── ReactPackageProvider.cpp │ │ ├── PropertySheet.props │ │ ├── ReactPackageProvider.h │ │ ├── readme.txt │ │ ├── SliderWindows.vcxproj.filters │ │ ├── SliderViewManager.h │ │ ├── SliderView.h │ │ ├── SliderViewManager.cpp │ │ └── SliderView.cpp ├── babel.config.js ├── android │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── src │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ └── java │ │ │ └── com │ │ │ └── reactnativecommunity │ │ │ └── slider │ │ │ ├── ReactSliderPackage.java │ │ │ ├── ReactSlidingStartEvent.java │ │ │ ├── ReactSlidingCompleteEvent.java │ │ │ ├── ReactSliderEvent.java │ │ │ ├── ReactSlider.java │ │ │ └── ReactSliderManager.java │ ├── gradle.properties │ ├── build.gradle │ ├── gradlew.bat │ └── gradlew ├── ios │ ├── RNCSliderManager.h │ ├── RNCSlider.h │ ├── RNCSlider.m │ ├── RNCSliderManager.m │ └── RNCSlider.xcodeproj │ │ └── project.pbxproj ├── react-native-slider.podspec ├── js │ ├── __tests__ │ │ ├── Slider.test.js │ │ └── __snapshots__ │ │ │ └── Slider.test.js.snap │ ├── RNCSliderNativeComponent.js │ └── Slider.js ├── package.json ├── typings │ └── index.d.ts └── .gitignore ├── .npmignore ├── .eslintignore ├── babel.config.js ├── .github ├── ISSUE_TEMPLATE │ ├── QUESTION.md │ ├── FEATURE_REQUEST.md │ └── BUG_REPORT.md └── PULL_REQUEST_TEMPLATE.md ├── metro.config.js ├── .eslintrc.json ├── LICENSE.md ├── .gitignore ├── package.json ├── .flowconfig └── .circleci └── config.yml /.gitattributes: -------------------------------------------------------------------------------- 1 | *.pbxproj -text 2 | -------------------------------------------------------------------------------- /example/windows/SliderTestWindows/.gitignore: -------------------------------------------------------------------------------- 1 | /Bundle 2 | -------------------------------------------------------------------------------- /src/windows/SliderWindows/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | -------------------------------------------------------------------------------- /example/windows/SliderTestWindows/pch.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | -------------------------------------------------------------------------------- /example/windows/SliderTestWindows/App.idl: -------------------------------------------------------------------------------- 1 | namespace SliderTestWindows 2 | { 3 | } 4 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | /.circleci 2 | /.github 3 | /example 4 | /src/android/build 5 | **/__tests__/**/* 6 | -------------------------------------------------------------------------------- /example/slider.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-slider/trunk/example/slider.png -------------------------------------------------------------------------------- /example/twitter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-slider/trunk/example/twitter.png -------------------------------------------------------------------------------- /example/slider-left.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-slider/trunk/example/slider-left.png -------------------------------------------------------------------------------- /example/slider-right.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-slider/trunk/example/slider-right.png -------------------------------------------------------------------------------- /example/sliderWindows.JPG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-slider/trunk/example/sliderWindows.JPG -------------------------------------------------------------------------------- /example/uie_thumb_big.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-slider/trunk/example/uie_thumb_big.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | example 3 | 4 | -------------------------------------------------------------------------------- /src/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: ['@babel/preset-flow', 'module:metro-react-native-babel-preset'], 3 | }; 4 | -------------------------------------------------------------------------------- /example/ios/example/Images.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /example/android/app/debug.keystore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-slider/trunk/example/android/app/debug.keystore -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | coverage/ 3 | dist/ 4 | lib/ 5 | web-build/ 6 | web-report/ 7 | 8 | .expo/ 9 | .yarn/ 10 | .vscode/ 11 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | presets: [ 3 | "@babel/preset-flow", 4 | 'module:metro-react-native-babel-preset' 5 | ], 6 | }; 7 | -------------------------------------------------------------------------------- /example/app.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "displayName": "example", 4 | "expo": { 5 | "name": "example", 6 | "slug": "example" 7 | } 8 | } -------------------------------------------------------------------------------- /example/babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = function(api) { 2 | api.cache(true); 3 | return { 4 | presets: ['babel-preset-expo'], 5 | }; 6 | }; 7 | -------------------------------------------------------------------------------- /example/e2e/testCases/example.e2e.js: -------------------------------------------------------------------------------- 1 | it('finds text in example app', async () => { 2 | await expect(element(by.id('testTextId'))).toBeVisible(); 3 | }); 4 | -------------------------------------------------------------------------------- /src/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-slider/trunk/src/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /src/windows/SliderWindows/pch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | #include 5 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-slider/trunk/example/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /example/e2e/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "testRegex": "/testCases/.+\\.e2e\\.js", 3 | "testMatch": null, 4 | "setupFilesAfterEnv": ["./init.js"], 5 | "testEnvironment": "node" 6 | } -------------------------------------------------------------------------------- /example/windows/SliderTestWindows/Assets/StoreLogo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-slider/trunk/example/windows/SliderTestWindows/Assets/StoreLogo.png -------------------------------------------------------------------------------- /src/android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-slider/trunk/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/wordpress-mobile/react-native-slider/trunk/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /src/windows/SliderWindows/SliderWindows.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | DllCanUnloadNow = WINRT_CanUnloadNow PRIVATE 3 | DllGetActivationFactory = WINRT_GetActivationFactory PRIVATE 4 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-slider/trunk/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/wordpress-mobile/react-native-slider/trunk/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /src/android/gradle.properties: -------------------------------------------------------------------------------- 1 | ReactNativeSlider_compileSdkVersion=28 2 | ReactNativeSlider_buildToolsVersion=28.0.3 3 | ReactNativeSlider_targetSdkVersion=27 4 | ReactNativeSlider_minSdkVersion=16 -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-slider/trunk/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-slider/trunk/example/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-slider/trunk/example/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-slider/trunk/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/windows/SliderTestWindows/Assets/SplashScreen.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-slider/trunk/example/windows/SliderTestWindows/Assets/SplashScreen.scale-200.png -------------------------------------------------------------------------------- /src/windows/SliderWindows/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-slider/trunk/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-slider/trunk/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /example/windows/SliderTestWindows/Assets/LockScreenLogo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-slider/trunk/example/windows/SliderTestWindows/Assets/LockScreenLogo.scale-200.png -------------------------------------------------------------------------------- /example/windows/SliderTestWindows/Assets/Square44x44Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-slider/trunk/example/windows/SliderTestWindows/Assets/Square44x44Logo.scale-200.png -------------------------------------------------------------------------------- /example/windows/SliderTestWindows/Assets/Wide310x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-slider/trunk/example/windows/SliderTestWindows/Assets/Wide310x150Logo.scale-200.png -------------------------------------------------------------------------------- /example/windows/SliderTestWindows/SliderTestWindows_TemporaryKey.pfx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-slider/trunk/example/windows/SliderTestWindows/SliderTestWindows_TemporaryKey.pfx -------------------------------------------------------------------------------- /example/windows/SliderTestWindows/Assets/Square150x150Logo.scale-200.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-slider/trunk/example/windows/SliderTestWindows/Assets/Square150x150Logo.scale-200.png -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/QUESTION.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 💬 Question 3 | about: You need to ask a question about React Native Slider. 4 | labels: 'question' 5 | --- 6 | 7 | ## Ask your Question 8 | 9 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/windows/SliderTestWindows/Assets/Square44x44Logo.targetsize-24_altform-unplated.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/wordpress-mobile/react-native-slider/trunk/example/windows/SliderTestWindows/Assets/Square44x44Logo.targetsize-24_altform-unplated.png -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'example' 2 | apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); 3 | // set custom root because we're in a monorepo 4 | applyNativeModulesSettingsGradle(settings) 5 | include ':app' 6 | 7 | -------------------------------------------------------------------------------- /src/windows/SliderWindows/ReactPackageProvider.idl: -------------------------------------------------------------------------------- 1 | namespace SliderWindows 2 | { 3 | [webhosthidden] 4 | [default_interface] 5 | runtimeclass ReactPackageProvider : Microsoft.ReactNative.IReactPackageProvider 6 | { 7 | ReactPackageProvider(); 8 | }; 9 | } 10 | -------------------------------------------------------------------------------- /example/windows/SliderTestWindows/packages.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /src/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Sat Feb 09 14:36:05 CET 2019 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip 7 | -------------------------------------------------------------------------------- /example/windows/SliderTestWindows/App.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "App.xaml.g.h" 4 | 5 | namespace winrt::SliderTestWindows::implementation 6 | { 7 | struct App : AppT 8 | { 9 | App() noexcept; 10 | }; 11 | } // namespace winrt::SliderTestWindows::implementation 12 | 13 | 14 | -------------------------------------------------------------------------------- /example/ios/example.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /example/ios/example.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/ios/RNCSliderManager.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 | 10 | @interface RNCSliderManager : RCTViewManager 11 | 12 | @end 13 | -------------------------------------------------------------------------------- /example/index.web.js: -------------------------------------------------------------------------------- 1 | import {registerRootComponent} from 'expo'; 2 | 3 | import App from './App'; 4 | 5 | // registerRootComponent calls AppRegistry.registerComponent('main', () => App); 6 | // It also ensures that whether you load the app in the Expo client or in a native build, 7 | // the environment is set up appropriately 8 | registerRootComponent(App); 9 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/FEATURE_REQUEST.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🗣 Feature request 3 | about: Request a React Native Slider feature. 4 | labels: 'feature request' 5 | --- 6 | 7 | ## Describe the Feature 8 | 9 | 10 | ## Possible Implementations 11 | 12 | 13 | ## Related Issues 14 | -------------------------------------------------------------------------------- /example/windows/SliderTestWindows/AutolinkedNativeModules.g.h: -------------------------------------------------------------------------------- 1 | // AutolinkedNativeModules.g.h contents generated by "react-native autolink-windows" 2 | #pragma once 3 | 4 | 5 | namespace winrt::Microsoft::ReactNative 6 | { 7 | 8 | void RegisterAutolinkedNativeModulePackages(winrt::Windows::Foundation::Collections::IVector const& packageProviders); 9 | 10 | } 11 | -------------------------------------------------------------------------------- /.eslintrc.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "@react-native-community", 3 | "env": { 4 | "es6": true, 5 | "jest": true 6 | }, 7 | "globals": { 8 | "it": true, 9 | "expect": true, 10 | "element": true, 11 | "describe": true, 12 | "by": true, 13 | "device": true, 14 | "beforeAll": true, 15 | "beforeEach": true, 16 | "afterAll": true, 17 | "jest": true, 18 | "jasmine": true 19 | } 20 | } -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/windows/SliderWindows/SliderView.idl: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | namespace SliderWindows { 5 | 6 | [default_interface] 7 | runtimeclass SliderView : Windows.UI.Xaml.Controls.Slider { 8 | SliderView(Microsoft.ReactNative.IReactContext context); 9 | void UpdateProperties(Microsoft.ReactNative.IJSValueReader reader); 10 | }; 11 | } 12 | -------------------------------------------------------------------------------- /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) 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 | -------------------------------------------------------------------------------- /example/ios/example/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 | -------------------------------------------------------------------------------- /example/windows/SliderTestWindows/AutolinkedNativeModules.g.cpp: -------------------------------------------------------------------------------- 1 | // AutolinkedNativeModules.g.cpp contents generated by "react-native autolink-windows" 2 | #include "pch.h" 3 | #include "AutolinkedNativeModules.g.h" 4 | 5 | 6 | namespace winrt::Microsoft::ReactNative 7 | { 8 | 9 | void RegisterAutolinkedNativeModulePackages(winrt::Windows::Foundation::Collections::IVector const& packageProviders) 10 | { 11 | } 12 | 13 | } 14 | -------------------------------------------------------------------------------- /example/e2e/init.js: -------------------------------------------------------------------------------- 1 | const detox = require('detox'); 2 | const config = require('../../package.json').detox; 3 | const adapter = require('detox/runners/jest/adapter'); 4 | 5 | jest.setTimeout(300000); 6 | jasmine.getEnv().addReporter(adapter); 7 | 8 | beforeAll(async () => { 9 | await detox.init(config); 10 | }); 11 | 12 | beforeEach(async () => { 13 | await adapter.beforeEach(); 14 | }); 15 | 16 | afterAll(async () => { 17 | await adapter.afterAll(); 18 | await detox.cleanup(); 19 | }); 20 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /example/windows/SliderTestWindows/App.xaml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/windows/SliderTestWindows/ReactPackageProvider.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | #include "ReactPackageProvider.h" 3 | #include "NativeModules.h" 4 | 5 | 6 | using namespace winrt::Microsoft::ReactNative; 7 | 8 | namespace winrt::SliderTestWindows::implementation 9 | { 10 | 11 | void ReactPackageProvider::CreatePackage(IReactPackageBuilder const &packageBuilder) noexcept 12 | { 13 | AddAttributedModules(packageBuilder); 14 | } 15 | 16 | } // namespace winrt::SliderTestWindows::implementation 17 | 18 | 19 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Summary: 2 | --------- 3 | 4 | 6 | 7 | 8 | Test Plan: 9 | ---------- 10 | 11 | -------------------------------------------------------------------------------- /example/windows/SliderTestWindows/ReactPackageProvider.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "winrt/Microsoft.ReactNative.h" 4 | 5 | 6 | namespace winrt::SliderTestWindows::implementation 7 | { 8 | struct ReactPackageProvider : winrt::implements 9 | { 10 | public: // IReactPackageProvider 11 | void CreatePackage(winrt::Microsoft::ReactNative::IReactPackageBuilder const &packageBuilder) noexcept; 12 | }; 13 | } // namespace winrt::SliderTestWindows::implementation 14 | 15 | 16 | -------------------------------------------------------------------------------- /example/react-native.config.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const windowsSwitch = '--use-react-native-windows'; 4 | 5 | if (process.argv.includes(windowsSwitch)) { 6 | process.argv = process.argv.filter(arg => arg !== windowsSwitch); 7 | process.argv.push('--config=metro.config.windows.js'); 8 | module.exports = { 9 | reactNativePath: '../node_modules/react-native-windows', 10 | }; 11 | } else { 12 | module.exports = { 13 | project: { 14 | android: {sourceDir: './android'}, 15 | ios: {project: './ios/example.xcodeproj'}, 16 | }, 17 | }; 18 | } 19 | -------------------------------------------------------------------------------- /src/windows/SliderWindows/ReactPackageProvider.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #include "pch.h" 5 | #include "ReactPackageProvider.h" 6 | #include "ReactPackageProvider.g.cpp" 7 | 8 | #include "SliderViewManager.h" 9 | 10 | using namespace winrt::Microsoft::ReactNative; 11 | 12 | namespace winrt::SliderWindows::implementation { 13 | 14 | void ReactPackageProvider::CreatePackage(IReactPackageBuilder const& packageBuilder) noexcept { 15 | packageBuilder.AddViewManager(L"SliderViewManager", []() { return winrt::make(); }); 16 | } 17 | 18 | } -------------------------------------------------------------------------------- /src/react-native-slider.podspec: -------------------------------------------------------------------------------- 1 | require 'json' 2 | 3 | package = JSON.parse(File.read(File.join(__dir__, 'package.json'))) 4 | 5 | Pod::Spec.new do |s| 6 | s.name = "react-native-slider" 7 | s.version = package['version'] 8 | s.summary = package['description'] 9 | s.license = package['license'] 10 | 11 | s.authors = package['author'] 12 | s.homepage = package['homepage'] 13 | s.platform = :ios, "9.0" 14 | 15 | s.source = { :git => "https://github.com/react-native-community/react-native-slider.git", :tag => "v#{s.version}" } 16 | s.source_files = "ios/**/*.{h,m}" 17 | 18 | s.dependency 'React-Core' 19 | end 20 | -------------------------------------------------------------------------------- /src/windows/SliderWindows/PropertySheet.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /example/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/windows/SliderTestWindows/PropertySheet.props: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/BUG_REPORT.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: 🐛 Report a bug 3 | about: Report a reproducible or regression bug in React Native Slider.' 4 | labels: 'bug report' 5 | --- 6 | 7 | ## Environment 8 | 9 | 10 | 11 | ## Description 12 | 13 | 16 | 17 | 18 | ## Reproducible Demo 19 | 20 | 24 | -------------------------------------------------------------------------------- /example/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "name": "example", 4 | "version": "0.0.1", 5 | "scripts": { 6 | "start": "node ../node_modules/react-native/local-cli/cli.js start", 7 | "run:android": "react-native run-android", 8 | "run:windows": "npx react-native run-windows", 9 | "run:ios": "react-native run-ios", 10 | "run:web": "expo web" 11 | }, 12 | "dependencies": { 13 | "@react-native-community/slider": "^4.0.0-rc.2", 14 | "babel-preset-expo": "^8.2.1", 15 | "expo": "^37.0.12", 16 | "react-dom": "~16.9.0", 17 | "react": "^16.11.0", 18 | "react-native": "^0.62.2", 19 | "react-native-windows": "^0.62.0", 20 | "react-native-web": "~0.11" 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/windows/SliderWindows/ReactPackageProvider.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | 6 | #include "ReactPackageProvider.g.h" 7 | 8 | using namespace winrt::Microsoft::ReactNative; 9 | 10 | namespace winrt::SliderWindows::implementation 11 | { 12 | struct ReactPackageProvider : ReactPackageProviderT 13 | { 14 | ReactPackageProvider() = default; 15 | 16 | void CreatePackage(IReactPackageBuilder const& packageBuilder) noexcept; 17 | }; 18 | } 19 | 20 | namespace winrt::SliderWindows::factory_implementation 21 | { 22 | struct ReactPackageProvider : ReactPackageProviderT {}; 23 | } 24 | -------------------------------------------------------------------------------- /example/ios/example/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 | } -------------------------------------------------------------------------------- /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.useAndroidX=true 21 | android.enableJetifier=true 22 | -------------------------------------------------------------------------------- /example/windows/SliderTestWindows/pch.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #define NOMINMAX 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | #include 21 | 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | #include "winrt/SliderWindows.h" 29 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 13 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | google() 4 | jcenter() 5 | } 6 | 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:3.2.1' 9 | } 10 | } 11 | 12 | def getExtOrDefault(name) { 13 | return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties['ReactNativeSlider_' + name] 14 | } 15 | 16 | def getExtOrIntegerDefault(name) { 17 | return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties['ReactNativeSlider_' + name]).toInteger() 18 | } 19 | 20 | apply plugin: 'com.android.library' 21 | 22 | android { 23 | compileSdkVersion getExtOrIntegerDefault('compileSdkVersion') 24 | buildToolsVersion getExtOrDefault('buildToolsVersion') 25 | 26 | defaultConfig { 27 | minSdkVersion getExtOrIntegerDefault('minSdkVersion') 28 | targetSdkVersion getExtOrIntegerDefault('targetSdkVersion') 29 | } 30 | } 31 | 32 | repositories { 33 | google() 34 | jcenter() 35 | mavenCentral() 36 | } 37 | 38 | dependencies { 39 | //noinspection GradleDynamicVersion 40 | api 'com.facebook.react:react-native:+' 41 | } -------------------------------------------------------------------------------- /src/js/__tests__/Slider.test.js: -------------------------------------------------------------------------------- 1 | /* @flow */ 2 | 3 | import * as React from 'react'; 4 | import renderer from 'react-test-renderer'; 5 | import Slider from '../Slider'; 6 | 7 | describe('', () => { 8 | it('renders enabled slider', () => { 9 | const tree = renderer.create().toJSON(); 10 | 11 | expect(tree).toMatchSnapshot(); 12 | }); 13 | 14 | it('renders disabled slider', () => { 15 | const tree = renderer.create().toJSON(); 16 | 17 | expect(tree).toMatchSnapshot(); 18 | }); 19 | 20 | it('renders a slider with custom props', () => { 21 | const tree = renderer 22 | .create( 23 | {}} 32 | onValueChange={() => {}} 33 | />, 34 | ) 35 | .toJSON(); 36 | 37 | expect(tree).toMatchSnapshot(); 38 | }); 39 | }); 40 | -------------------------------------------------------------------------------- /src/ios/RNCSlider.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 | 10 | #import 11 | 12 | @interface RNCSlider : UISlider 13 | 14 | @property (nonatomic, copy) RCTBubblingEventBlock onRNCSliderValueChange; 15 | @property (nonatomic, copy) RCTBubblingEventBlock onRNCSliderSlidingStart; 16 | @property (nonatomic, copy) RCTBubblingEventBlock onRNCSliderSlidingComplete; 17 | 18 | @property (nonatomic, assign) float step; 19 | @property (nonatomic, assign) float lastValue; 20 | 21 | @property (nonatomic, strong) UIImage *trackImage; 22 | @property (nonatomic, strong) UIImage *minimumTrackImage; 23 | @property (nonatomic, strong) UIImage *maximumTrackImage; 24 | @property (nonatomic, strong) UIImage *thumbImage; 25 | @property (nonatomic, assign) bool tapToSeek; 26 | @property (nonatomic, strong) NSString *accessibilityUnits; 27 | @property (nonatomic, strong) NSArray *accessibilityIncrements; 28 | 29 | @end 30 | -------------------------------------------------------------------------------- /src/android/src/main/java/com/reactnativecommunity/slider/ReactSliderPackage.java: -------------------------------------------------------------------------------- 1 | package com.reactnativecommunity.slider; 2 | 3 | import java.util.Arrays; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | import com.facebook.react.ReactPackage; 8 | import com.facebook.react.bridge.NativeModule; 9 | import com.facebook.react.bridge.ReactApplicationContext; 10 | import com.facebook.react.uimanager.ViewManager; 11 | import com.facebook.react.bridge.JavaScriptModule; 12 | 13 | public class ReactSliderPackage implements ReactPackage { 14 | @Override 15 | public List createNativeModules(ReactApplicationContext reactContext) { 16 | return Collections.emptyList(); 17 | } 18 | 19 | // Deprecated from RN 0.47 20 | public List> createJSModules() { 21 | return Collections.emptyList(); 22 | } 23 | 24 | @Override 25 | @SuppressWarnings("rawtypes") 26 | public List createViewManagers(ReactApplicationContext reactContext) { 27 | return Arrays.asList(new ReactSliderManager()); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 react-native-community 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. -------------------------------------------------------------------------------- /.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 | !debug.keystore 44 | 45 | # fastlane 46 | # 47 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 48 | # screenshots whenever they are needed. 49 | # For more information about the recommended setup visit: 50 | # https://docs.fastlane.tools/best-practices/source-control/ 51 | 52 | */fastlane/report.xml 53 | */fastlane/Preview.html 54 | */fastlane/screenshots 55 | 56 | # Bundle artifact 57 | *.jsbundle 58 | .tmp/ 59 | src/dist 60 | 61 | */ios/Pods 62 | 63 | # Expo 64 | .expo 65 | web-build 66 | -------------------------------------------------------------------------------- /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 | 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 | -------------------------------------------------------------------------------- /example/windows/.gitignore: -------------------------------------------------------------------------------- 1 | *AppPackages* 2 | *BundleArtifacts* 3 | 4 | #OS junk files 5 | [Tt]humbs.db 6 | *.DS_Store 7 | 8 | #Visual Studio files 9 | *.[Oo]bj 10 | *.user 11 | *.aps 12 | *.pch 13 | *.vspscc 14 | *.vssscc 15 | *_i.c 16 | *_p.c 17 | *.ncb 18 | *.suo 19 | *.tlb 20 | *.tlh 21 | *.bak 22 | *.[Cc]ache 23 | *.ilk 24 | *.log 25 | *.lib 26 | *.sbr 27 | *.sdf 28 | *.opensdf 29 | *.opendb 30 | *.unsuccessfulbuild 31 | ipch/ 32 | [Oo]bj/ 33 | [Bb]in 34 | [Dd]ebug*/ 35 | [Rr]elease*/ 36 | Ankh.NoLoad 37 | 38 | # Visual C++ cache files 39 | ipch/ 40 | *.aps 41 | *.ncb 42 | *.opendb 43 | *.opensdf 44 | *.sdf 45 | *.cachefile 46 | *.VC.db 47 | *.VC.VC.opendb 48 | 49 | #MonoDevelop 50 | *.pidb 51 | *.userprefs 52 | 53 | #Tooling 54 | _ReSharper*/ 55 | *.resharper 56 | [Tt]est[Rr]esult* 57 | *.sass-cache 58 | 59 | #Project files 60 | [Bb]uild/ 61 | 62 | #Subversion files 63 | .svn 64 | 65 | # Office Temp Files 66 | ~$* 67 | 68 | # vim Temp Files 69 | *~ 70 | 71 | #NuGet 72 | packages/ 73 | *.nupkg 74 | 75 | #ncrunch 76 | *ncrunch* 77 | *crunch*.local.xml 78 | 79 | # visual studio database projects 80 | *.dbmdl 81 | 82 | #Test files 83 | *.testsettings 84 | 85 | #Other files 86 | *.DotSettings 87 | .vs/ 88 | *project.lock.json 89 | 90 | #Files generated by the VS build 91 | **/Generated Files/** 92 | 93 | -------------------------------------------------------------------------------- /src/windows/SliderWindows/readme.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | C++/WinRT SliderWindows Project Overview 3 | ======================================================================== 4 | 5 | This project demonstrates how to get started authoring Windows Runtime 6 | classes directly with standard C++, using the C++/WinRT SDK component 7 | to generate implementation headers from interface (IDL) files. The 8 | generated Windows Runtime component binary and WinMD files should then 9 | be bundled with the Universal Windows Platform (UWP) app consuming them. 10 | 11 | Steps: 12 | 1. Create an interface (IDL) file to define your Windows Runtime class, 13 | its default interface, and any other interfaces it implements. 14 | 2. Build the project once to generate module.g.cpp, module.h.cpp, and 15 | implementation templates under the "Generated Files" folder, as 16 | well as skeleton class definitions under "Generated Files\sources". 17 | 3. Use the skeleton class definitions for reference to implement your 18 | Windows Runtime classes. 19 | 20 | ======================================================================== 21 | Learn more about C++/WinRT here: 22 | http://aka.ms/cppwinrt/ 23 | ======================================================================== 24 | -------------------------------------------------------------------------------- /example/App.js: -------------------------------------------------------------------------------- 1 | import React, {Component} from 'react'; 2 | import {StyleSheet, Text, ScrollView, View, Platform} from 'react-native'; 3 | import {examples} from './SliderExample'; 4 | 5 | type Props = {}; 6 | export default class App extends Component { 7 | render() { 8 | return ( 9 | 12 | 13 | {''} 14 | 15 | {examples 16 | .filter(e => !e.platform || e.platform === Platform.OS) 17 | .map((e, i) => ( 18 | 19 | {e.title} 20 | {e.render()} 21 | 22 | ))} 23 | 24 | ); 25 | } 26 | } 27 | 28 | const styles = StyleSheet.create({ 29 | scrollView: { 30 | backgroundColor: '#F5FCFF', 31 | }, 32 | container: { 33 | justifyContent: 'center', 34 | alignItems: 'center', 35 | paddingVertical: 20, 36 | }, 37 | title: { 38 | fontSize: 20, 39 | textAlign: 'center', 40 | width: '100%', 41 | marginVertical: 20, 42 | }, 43 | instructions: { 44 | textAlign: 'center', 45 | color: '#333333', 46 | marginBottom: 5, 47 | }, 48 | }); 49 | -------------------------------------------------------------------------------- /example/windows/SliderTestWindows/App.cpp: -------------------------------------------------------------------------------- 1 | #include "pch.h" 2 | 3 | #include "App.h" 4 | 5 | #include "AutolinkedNativeModules.g.h" 6 | #include "ReactPackageProvider.h" 7 | 8 | 9 | using namespace winrt::SliderTestWindows; 10 | using namespace winrt::SliderTestWindows::implementation; 11 | 12 | /// 13 | /// Initializes the singleton application object. This is the first line of 14 | /// authored code executed, and as such is the logical equivalent of main() or 15 | /// WinMain(). 16 | /// 17 | App::App() noexcept 18 | { 19 | MainComponentName(L"example"); 20 | 21 | #if BUNDLE 22 | JavaScriptBundleFile(L"index.windows"); 23 | InstanceSettings().UseWebDebugger(false); 24 | InstanceSettings().UseFastRefresh(false); 25 | #else 26 | JavaScriptMainModuleName(L"example/index"); 27 | InstanceSettings().UseWebDebugger(true); 28 | InstanceSettings().UseFastRefresh(true); 29 | #endif 30 | 31 | #if _DEBUG 32 | InstanceSettings().EnableDeveloperMenu(true); 33 | #else 34 | InstanceSettings().EnableDeveloperMenu(false); 35 | #endif 36 | 37 | RegisterAutolinkedNativeModulePackages(PackageProviders()); // Includes any autolinked modules 38 | 39 | PackageProviders().Append(make()); // Includes all modules in this project 40 | PackageProviders().Append(winrt::SliderWindows::ReactPackageProvider()); 41 | InitializeComponent(); 42 | } 43 | -------------------------------------------------------------------------------- /src/windows/SliderWindows/SliderWindows.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | accd3aa8-1ba0-4223-9bbe-0c431709210b 6 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tga;tiff;tif;png;wav;mfcribbon-ms 7 | 8 | 9 | {926ab91d-31b4-48c3-b9a4-e681349f27f0} 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /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.PackageList; 6 | import com.facebook.react.ReactApplication; 7 | import com.facebook.react.ReactNativeHost; 8 | import com.facebook.react.ReactPackage; 9 | import com.facebook.soloader.SoLoader; 10 | import com.reactnativecommunity.slider.ReactSliderPackage; 11 | 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 | @SuppressWarnings("UnnecessaryLocalVariable") 25 | List packages = new PackageList(this).getPackages(); 26 | // Packages that cannot be autolinked yet can be added manually here, for example: 27 | // packages.add(new MyReactNativePackage()); 28 | return packages; 29 | } 30 | 31 | @Override 32 | protected String getJSMainModuleName() { 33 | return "example/index"; 34 | } 35 | }; 36 | 37 | @Override 38 | public ReactNativeHost getReactNativeHost() { 39 | return mReactNativeHost; 40 | } 41 | 42 | @Override 43 | public void onCreate() { 44 | super.onCreate(); 45 | SoLoader.init(this, /* native exopackage */ false); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /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 | 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.example", 39 | ) 40 | 41 | android_resource( 42 | name = "res", 43 | package = "com.example", 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 | -------------------------------------------------------------------------------- /example/ios/example/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:@"example" 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:@"example/index" fallbackResource:nil]; 37 | #else 38 | return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; 39 | #endif 40 | } 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /src/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@react-native-community/slider", 3 | "version": "4.0.0-rc.2", 4 | "license": "MIT", 5 | "author": "react-native-community", 6 | "homepage": "https://github.com/react-native-community/react-native-slider", 7 | "description": "React Native component used to select a single value from a range of values.", 8 | "publishConfig": { 9 | "access": "public" 10 | }, 11 | "main": "dist/Slider.js", 12 | "types": "typings/index.d.ts", 13 | "keywords": [ 14 | "react-native", 15 | "react native", 16 | "slider" 17 | ], 18 | "scripts": { 19 | "prepare": "babel --out-dir dist js" 20 | }, 21 | "peerDependencies": { 22 | "react": "^16.11.0", 23 | "react-native": "^0.62.2", 24 | "react-native-windows": "^0.62.0" 25 | }, 26 | "devDependencies": { 27 | "@babel/cli": "^7.8.4", 28 | "@babel/core": "^7.6.2", 29 | "@babel/preset-flow": "^7.9.0", 30 | "@babel/runtime": "^7.6.2", 31 | "@react-native-community/eslint-config": "0.0.5", 32 | "babel-jest": "^24.9.0", 33 | "babel-plugin-module-resolver": "3.1.3", 34 | "detox": "^18.9.0", 35 | "eslint": "^6.5.1", 36 | "flow-bin": "0.113.0", 37 | "jest": "^24.9.0", 38 | "metro-react-native-babel-preset": "^0.56.0", 39 | "react": "^16.11.0", 40 | "react-native": "^0.62.2", 41 | "react-native-windows": "^0.62.0-0", 42 | "react-test-renderer": "16.9.0" 43 | }, 44 | "repository": { 45 | "type": "git", 46 | "url": "https://github.com/react-native-community/react-native-slider.git" 47 | }, 48 | "dependencies": { 49 | "flow-bin": "0.113.0" 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /example/metro.config.windows.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Metro configuration for React Native 3 | * https://github.com/facebook/react-native 4 | * 5 | * @format 6 | */ 7 | const fs = require('fs'); 8 | const path = require('path'); 9 | const blacklist = require('metro-config/src/defaults/blacklist'); 10 | 11 | const rnPath = fs.realpathSync( 12 | path.resolve(require.resolve('react-native/package.json'), '..'), 13 | ); 14 | 15 | const rnwPath = fs.realpathSync( 16 | path.resolve(require.resolve('react-native-windows/package.json'), '..'), 17 | ); 18 | 19 | module.exports = { 20 | resolver: { 21 | extraNodeModules: { 22 | // Redirect react-native to react-native-windows 23 | 'react-native': rnwPath, 24 | 'react-native-windows': rnwPath, 25 | }, 26 | // Include the macos platform in addition to the defaults because the fork includes macos, but doesn't declare it 27 | platforms: ['ios', 'android', 'windows', 'web', 'macos'], 28 | // Since there are multiple copies of react-native, we need to ensure that metro only sees one of them 29 | // This should go in RN 0.62 when haste is removed 30 | blacklistRE: blacklist([ 31 | new RegExp( 32 | `${path.join(path.resolve(rnPath), path.sep).replace(/[/\\]/g, '/')}.*`, 33 | ), 34 | 35 | // This stops "react-native run-windows" from causing the metro server to crash if its already running 36 | new RegExp( 37 | `${path.resolve(__dirname, 'windows').replace(/[/\\]/g, '/')}.*`, 38 | ), 39 | ]), 40 | }, 41 | transformer: { 42 | getTransformOptions: async () => ({ 43 | transform: { 44 | experimentalImportSupport: false, 45 | inlineRequires: false, 46 | }, 47 | }), 48 | }, 49 | }; 50 | -------------------------------------------------------------------------------- /example/windows/SliderTestWindows/Package.appxmanifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 8 | 9 | 13 | 14 | 15 | 16 | 17 | SliderTestWindows 18 | igklemen 19 | Assets\StoreLogo.png 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 34 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /src/android/src/main/java/com/reactnativecommunity/slider/ReactSlidingStartEvent.java: -------------------------------------------------------------------------------- 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 | package com.reactnativecommunity.slider; 9 | 10 | import com.facebook.react.bridge.Arguments; 11 | import com.facebook.react.bridge.WritableMap; 12 | import com.facebook.react.uimanager.events.Event; 13 | import com.facebook.react.uimanager.events.RCTEventEmitter; 14 | 15 | /** 16 | * Event emitted when the user starts dragging the slider. 17 | */ 18 | 19 | public class ReactSlidingStartEvent extends Event { 20 | public static final String EVENT_NAME = "topSlidingStart"; 21 | 22 | private final double mValue; 23 | 24 | public ReactSlidingStartEvent(int viewId, double value) { 25 | super(viewId); 26 | mValue = value; 27 | } 28 | 29 | public double getValue() { 30 | return mValue; 31 | } 32 | 33 | @Override 34 | public String getEventName() { 35 | return EVENT_NAME; 36 | } 37 | 38 | @Override 39 | public short getCoalescingKey() { 40 | return 0; 41 | } 42 | 43 | @Override 44 | public boolean canCoalesce() { 45 | return false; 46 | } 47 | 48 | @Override 49 | public void dispatch(RCTEventEmitter rctEventEmitter) { 50 | rctEventEmitter.receiveEvent(getViewTag(), getEventName(), serializeEventData()); 51 | } 52 | 53 | private WritableMap serializeEventData() { 54 | WritableMap eventData = Arguments.createMap(); 55 | eventData.putInt("target", getViewTag()); 56 | eventData.putDouble("value", getValue()); 57 | return eventData; 58 | } 59 | 60 | } -------------------------------------------------------------------------------- /src/android/src/main/java/com/reactnativecommunity/slider/ReactSlidingCompleteEvent.java: -------------------------------------------------------------------------------- 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 | package com.reactnativecommunity.slider; 9 | 10 | import com.facebook.react.bridge.Arguments; 11 | import com.facebook.react.bridge.WritableMap; 12 | import com.facebook.react.uimanager.events.Event; 13 | import com.facebook.react.uimanager.events.RCTEventEmitter; 14 | 15 | /** 16 | * Event emitted when the user finishes dragging the slider. 17 | */ 18 | public class ReactSlidingCompleteEvent extends Event { 19 | 20 | public static final String EVENT_NAME = "topSlidingComplete"; 21 | 22 | private final double mValue; 23 | 24 | public ReactSlidingCompleteEvent(int viewId, double value) { 25 | super(viewId); 26 | mValue = value; 27 | } 28 | 29 | public double getValue() { 30 | return mValue; 31 | } 32 | 33 | @Override 34 | public String getEventName() { 35 | return EVENT_NAME; 36 | } 37 | 38 | @Override 39 | public short getCoalescingKey() { 40 | return 0; 41 | } 42 | 43 | @Override 44 | public boolean canCoalesce() { 45 | return false; 46 | } 47 | 48 | @Override 49 | public void dispatch(RCTEventEmitter rctEventEmitter) { 50 | rctEventEmitter.receiveEvent(getViewTag(), getEventName(), serializeEventData()); 51 | } 52 | 53 | private WritableMap serializeEventData() { 54 | WritableMap eventData = Arguments.createMap(); 55 | eventData.putInt("target", getViewTag()); 56 | eventData.putDouble("value", getValue()); 57 | return eventData; 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /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 | $(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 | -------------------------------------------------------------------------------- /src/android/src/main/java/com/reactnativecommunity/slider/ReactSliderEvent.java: -------------------------------------------------------------------------------- 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 | package com.reactnativecommunity.slider; 9 | 10 | import com.facebook.react.bridge.Arguments; 11 | import com.facebook.react.bridge.WritableMap; 12 | import com.facebook.react.uimanager.events.Event; 13 | import com.facebook.react.uimanager.events.RCTEventEmitter; 14 | 15 | /** 16 | * Event emitted by a ReactSliderManager when user changes slider position. 17 | */ 18 | public class ReactSliderEvent extends Event { 19 | 20 | public static final String EVENT_NAME = "topChange"; 21 | 22 | private final double mValue; 23 | private final boolean mFromUser; 24 | 25 | public ReactSliderEvent(int viewId, double value, boolean fromUser) { 26 | super(viewId); 27 | mValue = value; 28 | mFromUser = fromUser; 29 | } 30 | 31 | public double getValue() { 32 | return mValue; 33 | } 34 | 35 | public boolean isFromUser() { 36 | return mFromUser; 37 | } 38 | 39 | 40 | @Override 41 | public String getEventName() { 42 | return EVENT_NAME; 43 | } 44 | 45 | @Override 46 | public short getCoalescingKey() { 47 | return 0; 48 | } 49 | @Override 50 | public void dispatch(RCTEventEmitter rctEventEmitter) { 51 | rctEventEmitter.receiveEvent(getViewTag(), getEventName(), serializeEventData()); 52 | } 53 | 54 | private WritableMap serializeEventData() { 55 | WritableMap eventData = Arguments.createMap(); 56 | eventData.putInt("target", getViewTag()); 57 | eventData.putDouble("value", getValue()); 58 | eventData.putBoolean("fromUser", isFromUser()); 59 | return eventData; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/js/__tests__/__snapshots__/Slider.test.js.snap: -------------------------------------------------------------------------------- 1 | // Jest Snapshot v1, https://goo.gl/fbAQLP 2 | 3 | exports[` renders a slider with custom props 1`] = ` 4 | 29 | `; 30 | 31 | exports[` renders disabled slider 1`] = ` 32 | 54 | `; 55 | 56 | exports[` renders enabled slider 1`] = ` 57 | 79 | `; 80 | -------------------------------------------------------------------------------- /src/windows/SliderWindows/SliderViewManager.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | 6 | #include "winrt/Microsoft.ReactNative.h" 7 | #include "NativeModules.h" 8 | 9 | namespace winrt::SliderWindows::implementation { 10 | 11 | class SliderViewManager : public winrt::implements< 12 | SliderViewManager, 13 | winrt::Microsoft::ReactNative::IViewManager, 14 | winrt::Microsoft::ReactNative::IViewManagerWithReactContext, 15 | winrt::Microsoft::ReactNative::IViewManagerWithNativeProperties, 16 | winrt::Microsoft::ReactNative::IViewManagerWithExportedEventTypeConstants> { 17 | public: 18 | SliderViewManager(); 19 | 20 | // IViewManager 21 | winrt::hstring Name() noexcept; 22 | winrt::Windows::UI::Xaml::FrameworkElement CreateView() noexcept; 23 | 24 | // IViewManagerWithReactContext 25 | winrt::Microsoft::ReactNative::IReactContext ReactContext() noexcept; 26 | void ReactContext(winrt::Microsoft::ReactNative::IReactContext reactContext) noexcept; 27 | 28 | // IViewManagerWithNativeProperties 29 | winrt::Windows::Foundation::Collections:: 30 | IMapView 31 | NativeProps() noexcept; 32 | 33 | void UpdateProperties( 34 | winrt::Windows::UI::Xaml::FrameworkElement const& view, 35 | winrt::Microsoft::ReactNative::IJSValueReader const& propertyMapReader) noexcept; 36 | 37 | // IViewManagerWithExportedEventTypeConstants 38 | winrt::Microsoft::ReactNative::ConstantProviderDelegate ExportedCustomBubblingEventTypeConstants() noexcept; 39 | winrt::Microsoft::ReactNative::ConstantProviderDelegate ExportedCustomDirectEventTypeConstants() noexcept; 40 | 41 | private: 42 | winrt::Microsoft::ReactNative::IReactContext m_reactContext{ nullptr }; 43 | }; 44 | } 45 | -------------------------------------------------------------------------------- /src/js/RNCSliderNativeComponent.js: -------------------------------------------------------------------------------- 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 | * @format 8 | * @flow 9 | */ 10 | 11 | 'use strict'; 12 | 13 | import {requireNativeComponent} from 'react-native'; 14 | 15 | import type {ColorValue} from 'react-native/Libraries/StyleSheet/StyleSheetTypes'; 16 | import type {ImageSource} from 'react-native/Libraries/Image/ImageSource'; 17 | import type {NativeComponent} from 'react-native/Libraries/Renderer/shims/ReactNative'; 18 | import type {SyntheticEvent} from 'react-native/Libraries/Types/CoreEventTypes'; 19 | import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes'; 20 | 21 | type Event = SyntheticEvent< 22 | $ReadOnly<{| 23 | value: number, 24 | fromUser?: boolean, 25 | |}>, 26 | >; 27 | 28 | type NativeProps = $ReadOnly<{| 29 | ...ViewProps, 30 | accessibilityUnits?: string, 31 | accessibilityIncrements?: Array, 32 | disabled?: ?boolean, 33 | enabled?: ?boolean, 34 | inverted?: ?boolean, 35 | vertical?: ?boolean, 36 | maximumTrackImage?: ?ImageSource, 37 | maximumTrackTintColor?: ?ColorValue, 38 | maximumValue?: ?number, 39 | minimumTrackImage?: ?ImageSource, 40 | minimumTrackTintColor?: ?ColorValue, 41 | minimumValue?: ?number, 42 | onChange?: ?(event: Event) => void, 43 | onRNCSliderSlidingStart?: ?(event: Event) => void, 44 | onRNCSliderSlidingComplete?: ?(event: Event) => void, 45 | onRNCSliderValueChange?: ?(event: Event) => void, 46 | step?: ?number, 47 | testID?: ?string, 48 | thumbImage?: ?ImageSource, 49 | thumbTintColor?: ?ColorValue, 50 | trackImage?: ?ImageSource, 51 | value?: ?number, 52 | |}>; 53 | 54 | type RNCSliderType = Class>; 55 | 56 | const RNCSliderNativeComponent = ((requireNativeComponent( 57 | 'RNCSlider', 58 | ): any): RNCSliderType); 59 | export default RNCSliderNativeComponent; 60 | -------------------------------------------------------------------------------- /src/windows/SliderWindows/SliderView.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #pragma once 5 | 6 | #include "SliderView.g.h" 7 | #include "winrt/Microsoft.ReactNative.h" 8 | #include "NativeModules.h" 9 | 10 | namespace winrt::SliderWindows::implementation { 11 | 12 | namespace xaml = winrt::Windows::UI::Xaml; 13 | 14 | class SliderView : public SliderViewT { 15 | public: 16 | SliderView(Microsoft::ReactNative::IReactContext const& reactContext); 17 | void UpdateProperties(Microsoft::ReactNative::IJSValueReader const& reader); 18 | 19 | private: 20 | Microsoft::ReactNative::IReactContext m_reactContext{ nullptr }; 21 | bool m_updating{ false }; 22 | 23 | xaml::Controls::Primitives::RangeBase::ValueChanged_revoker m_sliderValueChangedRevoker{}; 24 | xaml::UIElement::ManipulationStarting_revoker m_sliderManipulationStartingRevoker{}; 25 | xaml::UIElement::ManipulationCompleted_revoker m_sliderManipulationCompletedRevoker{}; 26 | 27 | void RegisterEvents(); 28 | void OnValueChangedHandler( 29 | winrt::Windows::Foundation::IInspectable const& sender, 30 | xaml::Controls::Primitives::RangeBaseValueChangedEventArgs const& args); 31 | void OnManipulationStartingHandler( 32 | winrt::Windows::Foundation::IInspectable const& sender, 33 | xaml::Input::ManipulationStartingRoutedEventArgs const& args); 34 | void OnManipulationCompletedHandler( 35 | winrt::Windows::Foundation::IInspectable const& sender, 36 | xaml::Input::ManipulationCompletedRoutedEventArgs const& args); 37 | 38 | const double CalculateStepFrequencyPercentageValue(const double& stepPropertyValue) const noexcept; 39 | 40 | double m_maxValue, m_minValue; 41 | double m_value; 42 | }; 43 | } 44 | 45 | namespace winrt::SliderWindows::factory_implementation { 46 | struct SliderView : SliderViewT {}; 47 | } -------------------------------------------------------------------------------- /example/windows/SliderTestWindows/SliderTestWindows.vcxproj.filters: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | Assets 25 | 26 | 27 | Assets 28 | 29 | 30 | Assets 31 | 32 | 33 | Assets 34 | 35 | 36 | Assets 37 | 38 | 39 | Assets 40 | 41 | 42 | Assets 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | {e48dc53e-40b1-40cb-970a-f89935452892} 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "private": true, 3 | "workspaces": ["src", "example"], 4 | "scripts": { 5 | "validate:eslint": "eslint src example", 6 | "validate:flow": "flow check src", 7 | "test:jest": "jest src", 8 | "test": "yarn validate:eslint && yarn validate:flow && yarn test:jest" 9 | }, 10 | "jest": { 11 | "preset": "react-native", 12 | "modulePathIgnorePatterns": [ 13 | "/e2e/" 14 | ] 15 | }, 16 | "prettier": { 17 | "singleQuote": true, 18 | "trailingComma": "all", 19 | "bracketSpacing": false, 20 | "jsxBracketSameLine": true, 21 | "parser": "flow" 22 | }, 23 | "detox": { 24 | "test-runner": "jest", 25 | "runner-config": "example/e2e/config.json", 26 | "configurations": { 27 | "ios.sim.debug": { 28 | "binaryPath": "example/ios/build/Build/Products/Debug-iphonesimulator/example.app", 29 | "build": "export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -workspace example/ios/example.xcworkspace -destination 'platform=iOS Simulator,name=iPhone X' -scheme example -parallelizeTargets -configuration Debug -derivedDataPath example/ios/build -UseModernBuildSystem=YES", 30 | "type": "ios.simulator", 31 | "name": "iPhone X" 32 | }, 33 | "ios.sim.release": { 34 | "binaryPath": "example/ios/build/Build/Products/Release-iphonesimulator/example.app", 35 | "build": "export RCT_NO_LAUNCH_PACKAGER=true && xcodebuild -project example/ios/example.xcworkspace -destination 'platform=iOS Simulator,name=iPhone X' -scheme example -parallelizeTargets -configuration Release -derivedDataPath example/ios/build -UseModernBuildSystem=YES", 36 | "type": "ios.simulator", 37 | "name": "iPhone X" 38 | }, 39 | "android.emu.debug": { 40 | "binaryPath": "example/android/app/build/outputs/apk/debug/app-debug.apk", 41 | "build": "export RCT_NO_LAUNCH_PACKAGER=true && pushd example/android && ./gradlew assembleDebug assembleAndroidTest -DtestBuildType=debug && popd", 42 | "type": "android.emulator", 43 | "name": "TestingAVD" 44 | }, 45 | "android.emu.release": { 46 | "binaryPath": "example/android/app/build/outputs/apk/release/app-release.apk", 47 | "build": "export RCT_NO_LAUNCH_PACKAGER=true && pushd example/android && ./gradlew assembleRelease assembleAndroidTest -DtestBuildType=release && popd", 48 | "type": "android.emulator", 49 | "name": "TestingAVD" 50 | } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /.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 | ; These should not be required directly 19 | ; require from fbjs/lib instead: require('fbjs/lib/warning') 20 | node_modules/warning/.* 21 | 22 | ; Flow doesn't support platforms 23 | .*/Libraries/Utilities/HMRLoadingView.js 24 | 25 | [untyped] 26 | .*/node_modules/@react-native-community/cli/.*/.* 27 | 28 | [include] 29 | 30 | [libs] 31 | node_modules/react-native/interface.js 32 | node_modules/react-native/flow/ 33 | 34 | [options] 35 | module.system.node.resolve_dirname=node_modules 36 | module.system.node.resolve_dirname=src 37 | emoji=true 38 | 39 | esproposal.optional_chaining=enable 40 | esproposal.nullish_coalescing=enable 41 | 42 | module.file_ext=.js 43 | module.file_ext=.json 44 | module.file_ext=.ios.js 45 | 46 | munge_underscores=true 47 | 48 | module.name_mapper='^react-native/\(.*\)$' -> '/node_modules/react-native/\1' 49 | 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' 50 | 51 | suppress_type=$FlowIssue 52 | suppress_type=$FlowFixMe 53 | suppress_type=$FlowFixMeProps 54 | suppress_type=$FlowFixMeState 55 | 56 | suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\) 57 | suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+ 58 | suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError 59 | 60 | [lints] 61 | sketchy-null-number=warn 62 | sketchy-null-mixed=warn 63 | sketchy-number=warn 64 | untyped-type-import=warn 65 | nonstrict-import=warn 66 | deprecated-type=warn 67 | unsafe-getters-setters=warn 68 | inexact-spread=warn 69 | unnecessary-invariant=warn 70 | signature-verification-failure=warn 71 | deprecated-utility=error 72 | 73 | [strict] 74 | deprecated-type 75 | nonstrict-import 76 | sketchy-null 77 | unclear-type 78 | unsafe-getters-setters 79 | untyped-import 80 | untyped-type-import 81 | 82 | [version] 83 | ^0.113.0 -------------------------------------------------------------------------------- /src/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 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 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 Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | platform :ios, '9.0' 2 | $node_modules_path = '../../node_modules' 3 | 4 | require_relative "#{$node_modules_path}/@react-native-community/cli-platform-ios/native_modules" 5 | 6 | 7 | target 'example' do 8 | # Pods for example 9 | pod 'FBLazyVector', :path => "#{$node_modules_path}/react-native/Libraries/FBLazyVector" 10 | pod 'FBReactNativeSpec', :path => "#{$node_modules_path}/react-native/Libraries/FBReactNativeSpec" 11 | pod 'RCTRequired', :path => "#{$node_modules_path}/react-native/Libraries/RCTRequired" 12 | pod 'RCTTypeSafety', :path => "#{$node_modules_path}/react-native/Libraries/TypeSafety" 13 | 14 | pod 'React', :path => "#{$node_modules_path}/react-native" 15 | pod 'React-CoreModules', :path => "#{$node_modules_path}/react-native/React/CoreModules" 16 | pod 'React-Core/DevSupport', :path => "#{$node_modules_path}/react-native/" 17 | pod 'React-RCTActionSheet', :path => "#{$node_modules_path}/react-native/Libraries/ActionSheetIOS" 18 | pod 'React-RCTAnimation', :path => "#{$node_modules_path}/react-native/Libraries/NativeAnimation" 19 | pod 'React-RCTBlob', :path => "#{$node_modules_path}/react-native/Libraries/Blob" 20 | pod 'React-RCTImage', :path => "#{$node_modules_path}/react-native/Libraries/Image" 21 | pod 'React-RCTLinking', :path => "#{$node_modules_path}/react-native/Libraries/LinkingIOS" 22 | pod 'React-RCTNetwork', :path => "#{$node_modules_path}/react-native/Libraries/Network" 23 | pod 'React-RCTSettings', :path => "#{$node_modules_path}/react-native/Libraries/Settings" 24 | pod 'React-RCTText', :path => "#{$node_modules_path}/react-native/Libraries/Text" 25 | pod 'React-RCTVibration', :path => "#{$node_modules_path}/react-native/Libraries/Vibration" 26 | pod 'React-Core/RCTWebSocket', :path => "#{$node_modules_path}/react-native/" 27 | 28 | pod 'React-cxxreact', :path => "#{$node_modules_path}/react-native/ReactCommon/cxxreact" 29 | pod 'React-jsi', :path => "#{$node_modules_path}/react-native/ReactCommon/jsi" 30 | pod 'React-jsiexecutor', :path => "#{$node_modules_path}/react-native/ReactCommon/jsiexecutor" 31 | pod 'React-jsinspector', :path => "#{$node_modules_path}/react-native/ReactCommon/jsinspector" 32 | pod 'ReactCommon/callinvoker', :path => "#{$node_modules_path}/react-native/ReactCommon" 33 | pod 'ReactCommon/turbomodule/core', :path => "#{$node_modules_path}/react-native/ReactCommon" 34 | pod 'Yoga', :path => "#{$node_modules_path}/react-native/ReactCommon/yoga" 35 | 36 | pod 'DoubleConversion', :podspec => "#{$node_modules_path}/react-native/third-party-podspecs/DoubleConversion.podspec" 37 | pod 'glog', :podspec => "#{$node_modules_path}/react-native/third-party-podspecs/glog.podspec" 38 | pod 'Folly', :podspec => "#{$node_modules_path}/react-native/third-party-podspecs/Folly.podspec" 39 | 40 | use_native_modules! 41 | end 42 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2.1 2 | 3 | orbs: 4 | rn: react-native-community/react-native@5.1.0 5 | 6 | jobs: 7 | checkout_code: 8 | executor: rn/linux_js 9 | steps: 10 | - checkout 11 | - persist_to_workspace: 12 | root: . 13 | paths: . 14 | analyse: 15 | executor: rn/linux_js 16 | steps: 17 | - attach_workspace: 18 | at: . 19 | - rn/yarn_install 20 | - run: 21 | name: Lint JS Code (ESLint) 22 | command: yarn run validate:eslint 23 | - run: 24 | name: Flow 25 | command: yarn run validate:flow 26 | - run: 27 | name: Jest 28 | command: yarn run test:jest 29 | # TODO: Uncomment after fixing detox setup 30 | # - run: 31 | # name: Build Android JavaScript Bundle 32 | # command: yarn run test:detox:android:bundle:release 33 | # - run: 34 | # name: Build iOS JavaScript Bundle 35 | # command: yarn run test:detox:ios:bundle:release 36 | 37 | # To be uncommented as a part of https://github.com/react-native-community/react-native-slider/issues/34 38 | # publish: 39 | # executor: rn/linux_js 40 | # steps: 41 | # - attach_workspace: 42 | # at: . 43 | # - rn/yarn_install 44 | # - run: 45 | # name: Publish to NPM 46 | # command: yarn ci:publish 47 | 48 | workflows: 49 | test: 50 | jobs: 51 | - checkout_code 52 | - analyse: 53 | requires: 54 | - checkout_code 55 | # Disabled until Detox works correctly with 0.60 56 | # - rn/android_build: 57 | # name: build_android_debug 58 | # project_path: "example/android" 59 | # build_type: debug 60 | # requires: 61 | # - analyse 62 | # - rn/android_build: 63 | # name: build_android_release 64 | # project_path: "example/android" 65 | # build_type: release 66 | # requires: 67 | # - analyse 68 | # - rn/android_test: 69 | # detox_configuration: "android.emu.release" 70 | # detox_loglevel: "trace" 71 | # requires: 72 | # - build_android_release 73 | # - rn/ios_build_and_test: 74 | # project_path: "example/ios/example.xcworkspace" 75 | # derived_data_path: "example/ios/build" 76 | # device: "iPhone X" 77 | # build_configuration: "Release" 78 | # scheme: "example" 79 | # detox_configuration: "ios.sim.release" 80 | # detox_loglevel: "trace" 81 | # requires: 82 | # - analyse 83 | # To be uncommented as a part of https://github.com/react-native-community/react-native-slider/issues/34 84 | # - publish: 85 | # requires: 86 | # - analyse 87 | # - rn/android_test 88 | # - rn/ios_build_and_test 89 | # filters: 90 | # branches: 91 | # only: master 92 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /src/windows/SliderWindows/SliderViewManager.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #include "pch.h" 5 | #include "SliderViewManager.h" 6 | #include "NativeModules.h" 7 | #include "SliderView.h" 8 | 9 | namespace winrt { 10 | using namespace Microsoft::ReactNative; 11 | using namespace Windows::Foundation::Collections; 12 | 13 | namespace xaml = winrt::Windows::UI::Xaml; 14 | } 15 | 16 | namespace winrt::SliderWindows::implementation { 17 | 18 | SliderViewManager::SliderViewManager() {} 19 | 20 | // IViewManager 21 | winrt::hstring SliderViewManager::Name() noexcept { 22 | return L"RNCSlider"; 23 | } 24 | 25 | xaml::FrameworkElement SliderViewManager::CreateView() noexcept { 26 | return winrt::SliderWindows::SliderView(m_reactContext); 27 | } 28 | 29 | // IViewManagerWithReactContext 30 | winrt::IReactContext SliderViewManager::ReactContext() noexcept { 31 | return m_reactContext; 32 | } 33 | 34 | void SliderViewManager::ReactContext(IReactContext reactContext) noexcept { 35 | m_reactContext = reactContext; 36 | } 37 | 38 | // IViewManagerWithNativeProperties 39 | IMapView SliderViewManager::NativeProps() noexcept { 40 | auto nativeProps = winrt::single_threaded_map(); 41 | 42 | nativeProps.Insert(L"maximumValue", ViewManagerPropertyType::Number); 43 | nativeProps.Insert(L"minimumValue", ViewManagerPropertyType::Number); 44 | nativeProps.Insert(L"value", ViewManagerPropertyType::Number); 45 | nativeProps.Insert(L"step", ViewManagerPropertyType::Number); 46 | 47 | nativeProps.Insert(L"inverted", ViewManagerPropertyType::Boolean); 48 | nativeProps.Insert(L"disabled", ViewManagerPropertyType::Boolean); 49 | nativeProps.Insert(L"vertical", ViewManagerPropertyType::Boolean); 50 | 51 | nativeProps.Insert(L"minimumTrackTintColor", ViewManagerPropertyType::Color); 52 | nativeProps.Insert(L"maximumTrackTintColor", ViewManagerPropertyType::Color); 53 | nativeProps.Insert(L"thumbTintColor", ViewManagerPropertyType::Color); 54 | nativeProps.Insert(L"thumbImage", ViewManagerPropertyType::Map); 55 | 56 | return nativeProps.GetView(); 57 | } 58 | 59 | void SliderViewManager::UpdateProperties(xaml::FrameworkElement const& view, 60 | IJSValueReader const& propertyMapReader) noexcept { 61 | if (auto sliderView = view.try_as()) { 62 | sliderView->UpdateProperties(propertyMapReader); 63 | } else { 64 | OutputDebugStringW(L"Type deduction for SliderView failed."); 65 | } 66 | } 67 | 68 | // IViewManagerWithExportedEventTypeConstants 69 | ConstantProviderDelegate SliderViewManager::ExportedCustomBubblingEventTypeConstants() noexcept { 70 | return nullptr; 71 | } 72 | 73 | ConstantProviderDelegate SliderViewManager::ExportedCustomDirectEventTypeConstants() noexcept { 74 | return [](winrt::IJSValueWriter const& constantWriter) { 75 | WriteCustomDirectEventTypeConstant(constantWriter, "onChange"); 76 | WriteCustomDirectEventTypeConstant(constantWriter, L"topSlidingStart", L"onRNCSliderSlidingStart"); 77 | WriteCustomDirectEventTypeConstant(constantWriter, L"topSlidingComplete", L"onRNCSliderSlidingComplete"); 78 | }; 79 | } 80 | 81 | } 82 | -------------------------------------------------------------------------------- /example/ios/example.xcodeproj/xcshareddata/xcschemes/example.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /src/ios/RNCSlider.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 "RNCSlider.h" 9 | 10 | @implementation RNCSlider 11 | { 12 | float _unclippedValue; 13 | bool _minimumTrackImageSet; 14 | bool _maximumTrackImageSet; 15 | } 16 | 17 | - (instancetype)initWithFrame:(CGRect)frame 18 | { 19 | return [super initWithFrame:frame]; 20 | } 21 | 22 | - (void)setValue:(float)value 23 | { 24 | _unclippedValue = value; 25 | super.value = value; 26 | [self setupAccessibility:value]; 27 | } 28 | 29 | - (void)setValue:(float)value animated:(BOOL)animated 30 | { 31 | _unclippedValue = value; 32 | [super setValue:value animated:animated]; 33 | [self setupAccessibility:value]; 34 | } 35 | 36 | - (void)setupAccessibility:(float)value 37 | { 38 | if (self.accessibilityUnits && self.accessibilityIncrements && [self.accessibilityIncrements count] - 1 == (int)self.maximumValue) { 39 | int index = (int)value; 40 | NSString *sliderValue = (NSString *)[self.accessibilityIncrements objectAtIndex:index]; 41 | NSUInteger stringLength = [self.accessibilityUnits length]; 42 | 43 | NSString *spokenUnits = [NSString stringWithString:self.accessibilityUnits]; 44 | if (sliderValue && [sliderValue intValue] == 1) { 45 | spokenUnits = [spokenUnits substringToIndex:stringLength-1]; 46 | } 47 | 48 | self.accessibilityValue = [NSString stringWithFormat:@"%@ %@", sliderValue, spokenUnits]; 49 | } 50 | } 51 | 52 | - (void)setMinimumValue:(float)minimumValue 53 | { 54 | super.minimumValue = minimumValue; 55 | super.value = _unclippedValue; 56 | } 57 | 58 | - (void)setMaximumValue:(float)maximumValue 59 | { 60 | super.maximumValue = maximumValue; 61 | super.value = _unclippedValue; 62 | } 63 | 64 | - (void)setTrackImage:(UIImage *)trackImage 65 | { 66 | if (trackImage != _trackImage) { 67 | _trackImage = trackImage; 68 | CGFloat width = trackImage.size.width / 2; 69 | if (!_minimumTrackImageSet) { 70 | UIImage *minimumTrackImage = [trackImage resizableImageWithCapInsets:(UIEdgeInsets){ 71 | 0, width, 0, width 72 | } resizingMode:UIImageResizingModeStretch]; 73 | [self setMinimumTrackImage:minimumTrackImage forState:UIControlStateNormal]; 74 | } 75 | if (!_maximumTrackImageSet) { 76 | UIImage *maximumTrackImage = [trackImage resizableImageWithCapInsets:(UIEdgeInsets){ 77 | 0, width, 0, width 78 | } resizingMode:UIImageResizingModeStretch]; 79 | [self setMaximumTrackImage:maximumTrackImage forState:UIControlStateNormal]; 80 | } 81 | } 82 | } 83 | 84 | - (void)setMinimumTrackImage:(UIImage *)minimumTrackImage 85 | { 86 | _trackImage = nil; 87 | _minimumTrackImageSet = true; 88 | minimumTrackImage = [minimumTrackImage resizableImageWithCapInsets:(UIEdgeInsets){ 89 | 0, minimumTrackImage.size.width, 0, 0 90 | } resizingMode:UIImageResizingModeStretch]; 91 | [self setMinimumTrackImage:minimumTrackImage forState:UIControlStateNormal]; 92 | } 93 | 94 | - (UIImage *)minimumTrackImage 95 | { 96 | return [self thumbImageForState:UIControlStateNormal]; 97 | } 98 | 99 | - (void)setMaximumTrackImage:(UIImage *)maximumTrackImage 100 | { 101 | _trackImage = nil; 102 | _maximumTrackImageSet = true; 103 | maximumTrackImage = [maximumTrackImage resizableImageWithCapInsets:(UIEdgeInsets){ 104 | 0, 0, 0, maximumTrackImage.size.width 105 | } resizingMode:UIImageResizingModeStretch]; 106 | [self setMaximumTrackImage:maximumTrackImage forState:UIControlStateNormal]; 107 | } 108 | 109 | - (UIImage *)maximumTrackImage 110 | { 111 | return [self thumbImageForState:UIControlStateNormal]; 112 | } 113 | 114 | - (void)setThumbImage:(UIImage *)thumbImage 115 | { 116 | [self setThumbImage:thumbImage forState:UIControlStateNormal]; 117 | } 118 | 119 | - (UIImage *)thumbImage 120 | { 121 | return [self thumbImageForState:UIControlStateNormal]; 122 | } 123 | 124 | - (void)setInverted:(BOOL)inverted 125 | { 126 | if (inverted) { 127 | self.transform = CGAffineTransformMakeScale(-1, 1); 128 | } else { 129 | self.transform = CGAffineTransformMakeScale(1, 1); 130 | } 131 | } 132 | 133 | @end 134 | -------------------------------------------------------------------------------- /src/typings/index.d.ts: -------------------------------------------------------------------------------- 1 | import * as React from "react"; 2 | import * as ReactNative from "react-native"; 3 | 4 | export interface SliderPropsAndroid extends ReactNative.ViewProps { 5 | /** 6 | * Color of the foreground switch grip. 7 | */ 8 | thumbTintColor?: string; 9 | } 10 | 11 | export interface SliderRef { 12 | updateValue(value: number): void; 13 | } 14 | 15 | export interface SliderPropsIOS extends ReactNative.ViewProps { 16 | /** 17 | * Assigns a maximum track image. Only static images are supported. 18 | * The leftmost pixel of the image will be stretched to fill the track. 19 | */ 20 | maximumTrackImage?: ReactNative.ImageURISource; 21 | 22 | /** 23 | * Assigns a minimum track image. Only static images are supported. 24 | * The rightmost pixel of the image will be stretched to fill the track. 25 | */ 26 | minimumTrackImage?: ReactNative.ImageURISource; 27 | 28 | /** 29 | * Permits tapping on the slider track to set the thumb position. 30 | * Defaults to false on iOS. No effect on Android or Windows. 31 | */ 32 | tapToSeek?: boolean; 33 | 34 | /** 35 | * Sets an image for the thumb. Only static images are supported. 36 | */ 37 | thumbImage?: ReactNative.ImageURISource; 38 | 39 | /** 40 | * Assigns a single image for the track. Only static images 41 | * are supported. The center pixel of the image will be stretched 42 | * to fill the track. 43 | */ 44 | trackImage?: ReactNative.ImageURISource; 45 | } 46 | 47 | export interface SliderPropsWindows extends ReactNative.ViewProps { 48 | /** 49 | * Controls the orientation of the slider, default value is 'false' (horizontal). 50 | */ 51 | vertical?: boolean; 52 | } 53 | 54 | 55 | export interface SliderProps extends SliderPropsIOS, SliderPropsAndroid, SliderPropsWindows { 56 | /** 57 | * If true the user won't be able to move the slider. 58 | * Default value is false. 59 | */ 60 | disabled?: boolean; 61 | 62 | /** 63 | * The color used for the track to the right of the button. 64 | * Overrides the default blue gradient image. 65 | */ 66 | maximumTrackTintColor?: string; 67 | 68 | /** 69 | * Initial maximum value of the slider. Default value is 1. 70 | */ 71 | maximumValue?: number; 72 | 73 | /** 74 | * The color used for the track to the left of the button. 75 | * Overrides the default blue gradient image. 76 | */ 77 | minimumTrackTintColor?: string; 78 | 79 | /** 80 | * Initial minimum value of the slider. Default value is 0. 81 | */ 82 | minimumValue?: number; 83 | 84 | /** 85 | * Callback that is called when the user picks up the slider. 86 | * The initial value is passed as an argument to the callback handler. 87 | */ 88 | onSlidingStart?: (value: number) => void; 89 | 90 | /** 91 | * Callback called when the user finishes changing the value (e.g. when the slider is released). 92 | */ 93 | onSlidingComplete?: (value: number) => void; 94 | 95 | /** 96 | * Callback continuously called while the user is dragging the slider. 97 | */ 98 | onValueChange?: (value: number) => void; 99 | 100 | /** 101 | * Step value of the slider. The value should be between 0 and (maximumValue - minimumValue). Default value is 0. 102 | */ 103 | step?: number; 104 | 105 | /** 106 | * Used to style and layout the Slider. See StyleSheet.js and ViewStylePropTypes.js for more info. 107 | */ 108 | style?: ReactNative.StyleProp; 109 | 110 | /** 111 | * Used to locate this view in UI automation tests. 112 | */ 113 | testID?: string; 114 | 115 | /** 116 | * Initial value of the slider. The value should be between minimumValue 117 | * and maximumValue, which default to 0 and 1 respectively. 118 | * Default value is 0. 119 | * This is not a controlled component, you don't need to update 120 | * the value during dragging. 121 | */ 122 | value?: number; 123 | 124 | /** 125 | * Reverses the direction of the slider. 126 | */ 127 | inverted?: boolean; 128 | 129 | /** 130 | * A string of one or more words to be announced by the screen reader. 131 | * Otherwise, it will announce the value as a percentage. 132 | * Requires passing a value to `accessibilityIncrements` to work correctly. 133 | * Should be a plural word, as singular units will be handled. 134 | */ 135 | accessibilityUnits?: string; 136 | 137 | /** 138 | * A string of one or more words to be announced by the screen reader. 139 | * Otherwise, it will announce the value as a percentage. 140 | * Requires passing a value to `accessibilityIncrements` to work correctly. 141 | * Should be a plural word, as singular units will be handled. 142 | */ 143 | accessibilityIncrements?: Array; 144 | 145 | /** 146 | * Reference object. 147 | */ 148 | ref?: React.MutableRefObject; 149 | } 150 | 151 | /** 152 | * A component used to select a single value from a range of values. 153 | */ 154 | declare class SliderComponent extends React.Component {} 155 | declare const SliderBase: ReactNative.Constructor & typeof SliderComponent; 156 | export default class Slider extends SliderBase {} 157 | export type SliderIOS = Slider; 158 | -------------------------------------------------------------------------------- /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/SliderExample.js: -------------------------------------------------------------------------------- 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 | 9 | 'use strict'; 10 | 11 | import React from 'react'; 12 | import {Text, StyleSheet, View} from 'react-native'; 13 | import Slider from '@react-native-community/slider'; 14 | 15 | import type {Element} from 'react'; 16 | class SliderExample extends React.Component<$FlowFixMeProps, $FlowFixMeState> { 17 | static defaultProps = { 18 | value: 0, 19 | }; 20 | 21 | state = { 22 | value: this.props.value, 23 | }; 24 | 25 | render() { 26 | return ( 27 | 28 | 29 | {this.state.value && +this.state.value.toFixed(3)} 30 | 31 | this.setState({value: value})} 36 | /> 37 | 38 | ); 39 | } 40 | } 41 | 42 | class SlidingStartExample extends React.Component< 43 | $FlowFixMeProps, 44 | $FlowFixMeState, 45 | > { 46 | state = { 47 | slideStartingValue: 0, 48 | slideStartingCount: 0, 49 | }; 50 | 51 | render() { 52 | return ( 53 | 54 | 57 | this.setState({ 58 | slideStartingValue: value, 59 | slideStartingCount: this.state.slideStartingCount + 1, 60 | }) 61 | } 62 | /> 63 | 64 | Starts: {this.state.slideStartingCount} Value:{' '} 65 | {this.state.slideStartingValue} 66 | 67 | 68 | ); 69 | } 70 | } 71 | 72 | class SlidingCompleteExample extends React.Component< 73 | $FlowFixMeProps, 74 | $FlowFixMeState, 75 | > { 76 | state = { 77 | slideCompletionValue: 0, 78 | slideCompletionCount: 0, 79 | }; 80 | 81 | render() { 82 | return ( 83 | 84 | 87 | this.setState({ 88 | slideCompletionValue: value, 89 | slideCompletionCount: this.state.slideCompletionCount + 1, 90 | }) 91 | } 92 | /> 93 | 94 | Completions: {this.state.slideCompletionCount} Value:{' '} 95 | {this.state.slideCompletionValue} 96 | 97 | 98 | ); 99 | } 100 | } 101 | 102 | const styles = StyleSheet.create({ 103 | slider: { 104 | width: 300, 105 | opacity: 1, 106 | height: 50, 107 | marginTop: 50, 108 | }, 109 | text: { 110 | fontSize: 14, 111 | textAlign: 'center', 112 | fontWeight: '500', 113 | margin: 10, 114 | }, 115 | }); 116 | 117 | export const title = ''; 118 | export const displayName = 'SliderExample'; 119 | export const description = 'Slider input for numeric values'; 120 | export const examples = [ 121 | { 122 | title: 'Default settings', 123 | render(): Element { 124 | return ; 125 | }, 126 | }, 127 | { 128 | title: 'Initial value: 0.5', 129 | render(): Element { 130 | return ; 131 | }, 132 | }, 133 | { 134 | title: 'minimumValue: -1, maximumValue: 2', 135 | render(): Element { 136 | return ; 137 | }, 138 | }, 139 | { 140 | title: 'step: 0.25, tap to seek on iOS', 141 | render(): Element { 142 | return ; 143 | }, 144 | }, 145 | { 146 | title: 'onSlidingStart', 147 | render(): Element { 148 | return ; 149 | }, 150 | }, 151 | { 152 | title: 'onSlidingComplete', 153 | render(): Element { 154 | return ; 155 | }, 156 | }, 157 | { 158 | title: 'Custom min/max track tint color', 159 | render(): Element { 160 | return ( 161 | 166 | ); 167 | }, 168 | }, 169 | { 170 | title: 'Custom thumb tint color', 171 | render(): Element { 172 | return ; 173 | }, 174 | }, 175 | { 176 | title: 'Custom thumb image', 177 | render(): Element { 178 | return ; 179 | }, 180 | }, 181 | { 182 | title: 'Custom thumb (network image)', 183 | platform: 'windows', 184 | render(): Element { 185 | return ( 186 | 191 | ); 192 | }, 193 | }, 194 | { 195 | title: 'Custom track image', 196 | platform: 'ios', 197 | render(): Element { 198 | return ; 199 | }, 200 | }, 201 | { 202 | title: 'Custom min/max track image', 203 | platform: 'ios', 204 | render(): Element { 205 | return ( 206 | 210 | ); 211 | }, 212 | }, 213 | { 214 | title: 'Inverted slider direction', 215 | render(): Element { 216 | return ; 217 | }, 218 | }, 219 | { 220 | title: 'Vertical slider', 221 | platform: 'windows', 222 | render(): Element { 223 | return ; 224 | }, 225 | }, 226 | ]; 227 | -------------------------------------------------------------------------------- /src/ios/RNCSliderManager.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 "RNCSliderManager.h" 9 | 10 | #import 11 | #import 12 | #import "RNCSlider.h" 13 | #import 14 | 15 | @implementation RNCSliderManager 16 | { 17 | BOOL _isSliding; 18 | } 19 | 20 | RCT_EXPORT_MODULE() 21 | 22 | - (UIView *)view 23 | { 24 | RNCSlider *slider = [RNCSlider new]; 25 | [slider addTarget:self action:@selector(sliderValueChanged:) 26 | forControlEvents:UIControlEventValueChanged]; 27 | [slider addTarget:self action:@selector(sliderTouchStart:) 28 | forControlEvents:UIControlEventTouchDown]; 29 | [slider addTarget:self action:@selector(sliderTouchEnd:) 30 | forControlEvents:(UIControlEventTouchUpInside | 31 | UIControlEventTouchUpOutside | 32 | UIControlEventTouchCancel)]; 33 | 34 | UITapGestureRecognizer *tapGesturer; 35 | tapGesturer = [[UITapGestureRecognizer alloc] initWithTarget: self action:@selector(tapHandler:)]; 36 | [tapGesturer setNumberOfTapsRequired: 1]; 37 | [slider addGestureRecognizer:tapGesturer]; 38 | 39 | return slider; 40 | } 41 | 42 | - (void)tapHandler:(UITapGestureRecognizer *)gesture { 43 | // Ignore this tap if in the middle of a slide. 44 | if (_isSliding) { 45 | return; 46 | } 47 | 48 | // Bail out if the source view of the gesture isn't an RNCSlider. 49 | if ([gesture.view class] != [RNCSlider class]) { 50 | return; 51 | } 52 | RNCSlider *slider = (RNCSlider *)gesture.view; 53 | 54 | if (!slider.tapToSeek) { 55 | return; 56 | } 57 | 58 | CGPoint touchPoint = [gesture locationInView:slider]; 59 | float rangeWidth = slider.maximumValue - slider.minimumValue; 60 | float sliderPercent = touchPoint.x / slider.bounds.size.width; 61 | float value = slider.minimumValue + (rangeWidth * sliderPercent); 62 | 63 | [slider setValue:discreteValue(slider, value) animated: YES]; 64 | 65 | // Trigger onValueChange to address https://github.com/react-native-community/react-native-slider/issues/212 66 | if (slider.onRNCSliderValueChange) { 67 | slider.onRNCSliderValueChange(@{ 68 | @"value": @(slider.value), 69 | }); 70 | } 71 | 72 | if (slider.onRNCSliderSlidingComplete) { 73 | slider.onRNCSliderSlidingComplete(@{ 74 | @"value": @(slider.value), 75 | }); 76 | } 77 | } 78 | 79 | static float discreteValue(RNCSlider *sender, float value) { 80 | // If step is set and less than or equal to difference between max and min values, 81 | // pick the closest discrete multiple of step to return. 82 | 83 | if (sender.step > 0 && sender.step <= (sender.maximumValue - sender.minimumValue)) { 84 | 85 | // Round up when increase, round down when decrease. 86 | double (^_round)(double) = ^(double x) { 87 | if (!UIAccessibilityIsVoiceOverRunning()) { 88 | return round(x); 89 | } else if (sender.lastValue > value) { 90 | return floor(x); 91 | } else { 92 | return ceil(x); 93 | } 94 | }; 95 | 96 | return 97 | MAX(sender.minimumValue, 98 | MIN(sender.maximumValue, 99 | sender.minimumValue + _round((value - sender.minimumValue) / sender.step) * sender.step 100 | ) 101 | ); 102 | } 103 | 104 | // Otherwise, leave value unchanged. 105 | return value; 106 | } 107 | 108 | static void RNCSendSliderEvent(RNCSlider *sender, BOOL continuous, BOOL isSlidingStart) 109 | { 110 | float value = discreteValue(sender, sender.value); 111 | 112 | [sender setValue:value animated:NO]; 113 | 114 | if (continuous) { 115 | if (sender.onRNCSliderValueChange && sender.lastValue != value) { 116 | sender.onRNCSliderValueChange(@{ 117 | @"value": @(value), 118 | }); 119 | } 120 | } else { 121 | if (sender.onRNCSliderSlidingComplete && !isSlidingStart) { 122 | sender.onRNCSliderSlidingComplete(@{ 123 | @"value": @(value), 124 | }); 125 | } 126 | if (sender.onRNCSliderSlidingStart && isSlidingStart) { 127 | sender.onRNCSliderSlidingStart(@{ 128 | @"value": @(value), 129 | }); 130 | } 131 | } 132 | 133 | sender.lastValue = value; 134 | } 135 | 136 | - (void)sliderValueChanged:(RNCSlider *)sender 137 | { 138 | RNCSendSliderEvent(sender, YES, NO); 139 | } 140 | 141 | - (void)sliderTouchStart:(RNCSlider *)sender 142 | { 143 | RNCSendSliderEvent(sender, NO, YES); 144 | _isSliding = YES; 145 | } 146 | 147 | - (void)sliderTouchEnd:(RNCSlider *)sender 148 | { 149 | RNCSendSliderEvent(sender, NO, NO); 150 | _isSliding = NO; 151 | } 152 | 153 | RCT_EXPORT_VIEW_PROPERTY(value, float); 154 | RCT_EXPORT_VIEW_PROPERTY(step, float); 155 | RCT_EXPORT_VIEW_PROPERTY(trackImage, UIImage); 156 | RCT_EXPORT_VIEW_PROPERTY(minimumTrackImage, UIImage); 157 | RCT_EXPORT_VIEW_PROPERTY(maximumTrackImage, UIImage); 158 | RCT_EXPORT_VIEW_PROPERTY(minimumValue, float); 159 | RCT_EXPORT_VIEW_PROPERTY(maximumValue, float); 160 | RCT_EXPORT_VIEW_PROPERTY(minimumTrackTintColor, UIColor); 161 | RCT_EXPORT_VIEW_PROPERTY(maximumTrackTintColor, UIColor); 162 | RCT_EXPORT_VIEW_PROPERTY(onRNCSliderValueChange, RCTBubblingEventBlock); 163 | RCT_EXPORT_VIEW_PROPERTY(onRNCSliderSlidingStart, RCTBubblingEventBlock); 164 | RCT_EXPORT_VIEW_PROPERTY(onRNCSliderSlidingComplete, RCTBubblingEventBlock); 165 | RCT_EXPORT_VIEW_PROPERTY(thumbTintColor, UIColor); 166 | RCT_EXPORT_VIEW_PROPERTY(thumbImage, UIImage); 167 | RCT_EXPORT_VIEW_PROPERTY(inverted, BOOL); 168 | RCT_EXPORT_VIEW_PROPERTY(tapToSeek, BOOL); 169 | RCT_EXPORT_VIEW_PROPERTY(accessibilityUnits, NSString); 170 | RCT_EXPORT_VIEW_PROPERTY(accessibilityIncrements, NSArray); 171 | 172 | RCT_CUSTOM_VIEW_PROPERTY(disabled, BOOL, RNCSlider) 173 | { 174 | if (json) { 175 | view.enabled = !([RCTConvert BOOL:json]); 176 | } else { 177 | view.enabled = defaultView.enabled; 178 | } 179 | } 180 | 181 | @end 182 | -------------------------------------------------------------------------------- /src/android/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn () { 37 | echo "$*" 38 | } 39 | 40 | die () { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 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 | # Escape application args 158 | save () { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /src/.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Mono auto generated files 17 | mono_crash.* 18 | 19 | # Build results 20 | [Dd]ebug/ 21 | [Dd]ebugPublic/ 22 | [Rr]elease/ 23 | [Rr]eleases/ 24 | x64/ 25 | x86/ 26 | [Ww][Ii][Nn]32/ 27 | [Aa][Rr][Mm]/ 28 | [Aa][Rr][Mm]64/ 29 | bld/ 30 | [Bb]in/ 31 | [Oo]bj/ 32 | [Ll]og/ 33 | [Ll]ogs/ 34 | 35 | # Visual Studio 2015/2017 cache/options directory 36 | .vs/ 37 | # Uncomment if you have tasks that create the project's static files in wwwroot 38 | #wwwroot/ 39 | 40 | # Visual Studio 2017 auto generated files 41 | Generated\ Files/ 42 | 43 | # MSTest test Results 44 | [Tt]est[Rr]esult*/ 45 | [Bb]uild[Ll]og.* 46 | 47 | # NUnit 48 | *.VisualState.xml 49 | TestResult.xml 50 | nunit-*.xml 51 | 52 | # Build Results of an ATL Project 53 | [Dd]ebugPS/ 54 | [Rr]eleasePS/ 55 | dlldata.c 56 | 57 | # Benchmark Results 58 | BenchmarkDotNet.Artifacts/ 59 | 60 | # .NET Core 61 | project.lock.json 62 | project.fragment.lock.json 63 | artifacts/ 64 | 65 | # ASP.NET Scaffolding 66 | ScaffoldingReadMe.txt 67 | 68 | # StyleCop 69 | StyleCopReport.xml 70 | 71 | # Files built by Visual Studio 72 | *_i.c 73 | *_p.c 74 | *_h.h 75 | *.ilk 76 | *.meta 77 | *.obj 78 | *.iobj 79 | *.pch 80 | *.pdb 81 | *.ipdb 82 | *.pgc 83 | *.pgd 84 | *.rsp 85 | *.sbr 86 | *.tlb 87 | *.tli 88 | *.tlh 89 | *.tmp 90 | *.tmp_proj 91 | *_wpftmp.csproj 92 | *.log 93 | *.vspscc 94 | *.vssscc 95 | .builds 96 | *.pidb 97 | *.svclog 98 | *.scc 99 | 100 | # Chutzpah Test files 101 | _Chutzpah* 102 | 103 | # Visual C++ cache files 104 | ipch/ 105 | *.aps 106 | *.ncb 107 | *.opendb 108 | *.opensdf 109 | *.sdf 110 | *.cachefile 111 | *.VC.db 112 | *.VC.VC.opendb 113 | 114 | # Visual Studio profiler 115 | *.psess 116 | *.vsp 117 | *.vspx 118 | *.sap 119 | 120 | # Visual Studio Trace Files 121 | *.e2e 122 | 123 | # TFS 2012 Local Workspace 124 | $tf/ 125 | 126 | # Guidance Automation Toolkit 127 | *.gpState 128 | 129 | # ReSharper is a .NET coding add-in 130 | _ReSharper*/ 131 | *.[Rr]e[Ss]harper 132 | *.DotSettings.user 133 | 134 | # TeamCity is a build add-in 135 | _TeamCity* 136 | 137 | # DotCover is a Code Coverage Tool 138 | *.dotCover 139 | 140 | # AxoCover is a Code Coverage Tool 141 | .axoCover/* 142 | !.axoCover/settings.json 143 | 144 | # Coverlet is a free, cross platform Code Coverage Tool 145 | coverage*.json 146 | coverage*.xml 147 | coverage*.info 148 | 149 | # Visual Studio code coverage results 150 | *.coverage 151 | *.coveragexml 152 | 153 | # NCrunch 154 | _NCrunch_* 155 | .*crunch*.local.xml 156 | nCrunchTemp_* 157 | 158 | # MightyMoose 159 | *.mm.* 160 | AutoTest.Net/ 161 | 162 | # Web workbench (sass) 163 | .sass-cache/ 164 | 165 | # Installshield output folder 166 | [Ee]xpress/ 167 | 168 | # DocProject is a documentation generator add-in 169 | DocProject/buildhelp/ 170 | DocProject/Help/*.HxT 171 | DocProject/Help/*.HxC 172 | DocProject/Help/*.hhc 173 | DocProject/Help/*.hhk 174 | DocProject/Help/*.hhp 175 | DocProject/Help/Html2 176 | DocProject/Help/html 177 | 178 | # Click-Once directory 179 | publish/ 180 | 181 | # Publish Web Output 182 | *.[Pp]ublish.xml 183 | *.azurePubxml 184 | # Note: Comment the next line if you want to checkin your web deploy settings, 185 | # but database connection strings (with potential passwords) will be unencrypted 186 | *.pubxml 187 | *.publishproj 188 | 189 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 190 | # checkin your Azure Web App publish settings, but sensitive information contained 191 | # in these scripts will be unencrypted 192 | PublishScripts/ 193 | 194 | # NuGet Packages 195 | *.nupkg 196 | # NuGet Symbol Packages 197 | *.snupkg 198 | # The packages folder can be ignored because of Package Restore 199 | **/[Pp]ackages/* 200 | # except build/, which is used as an MSBuild target. 201 | !**/[Pp]ackages/build/ 202 | # Uncomment if necessary however generally it will be regenerated when needed 203 | #!**/[Pp]ackages/repositories.config 204 | # NuGet v3's project.json files produces more ignorable files 205 | *.nuget.props 206 | *.nuget.targets 207 | 208 | # Microsoft Azure Build Output 209 | csx/ 210 | *.build.csdef 211 | 212 | # Microsoft Azure Emulator 213 | ecf/ 214 | rcf/ 215 | 216 | # Windows Store app package directories and files 217 | AppPackages/ 218 | BundleArtifacts/ 219 | Package.StoreAssociation.xml 220 | _pkginfo.txt 221 | *.appx 222 | *.appxbundle 223 | *.appxupload 224 | 225 | # Visual Studio cache files 226 | # files ending in .cache can be ignored 227 | *.[Cc]ache 228 | # but keep track of directories ending in .cache 229 | !?*.[Cc]ache/ 230 | 231 | # Others 232 | ClientBin/ 233 | ~$* 234 | *~ 235 | *.dbmdl 236 | *.dbproj.schemaview 237 | *.jfm 238 | *.pfx 239 | *.publishsettings 240 | orleans.codegen.cs 241 | 242 | # Including strong name files can present a security risk 243 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 244 | #*.snk 245 | 246 | # Since there are multiple workflows, uncomment next line to ignore bower_components 247 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 248 | #bower_components/ 249 | 250 | # RIA/Silverlight projects 251 | Generated_Code/ 252 | 253 | # Backup & report files from converting an old project file 254 | # to a newer Visual Studio version. Backup files are not needed, 255 | # because we have git ;-) 256 | _UpgradeReport_Files/ 257 | Backup*/ 258 | UpgradeLog*.XML 259 | UpgradeLog*.htm 260 | ServiceFabricBackup/ 261 | *.rptproj.bak 262 | 263 | # SQL Server files 264 | *.mdf 265 | *.ldf 266 | *.ndf 267 | 268 | # Business Intelligence projects 269 | *.rdl.data 270 | *.bim.layout 271 | *.bim_*.settings 272 | *.rptproj.rsuser 273 | *- [Bb]ackup.rdl 274 | *- [Bb]ackup ([0-9]).rdl 275 | *- [Bb]ackup ([0-9][0-9]).rdl 276 | 277 | # Microsoft Fakes 278 | FakesAssemblies/ 279 | 280 | # GhostDoc plugin setting file 281 | *.GhostDoc.xml 282 | 283 | # Node.js Tools for Visual Studio 284 | .ntvs_analysis.dat 285 | node_modules/ 286 | 287 | # Visual Studio 6 build log 288 | *.plg 289 | 290 | # Visual Studio 6 workspace options file 291 | *.opt 292 | 293 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 294 | *.vbw 295 | 296 | # Visual Studio LightSwitch build output 297 | **/*.HTMLClient/GeneratedArtifacts 298 | **/*.DesktopClient/GeneratedArtifacts 299 | **/*.DesktopClient/ModelManifest.xml 300 | **/*.Server/GeneratedArtifacts 301 | **/*.Server/ModelManifest.xml 302 | _Pvt_Extensions 303 | 304 | # Paket dependency manager 305 | .paket/paket.exe 306 | paket-files/ 307 | 308 | # FAKE - F# Make 309 | .fake/ 310 | 311 | # CodeRush personal settings 312 | .cr/personal 313 | 314 | # Python Tools for Visual Studio (PTVS) 315 | __pycache__/ 316 | *.pyc 317 | 318 | # Cake - Uncomment if you are using it 319 | # tools/** 320 | # !tools/packages.config 321 | 322 | # Tabs Studio 323 | *.tss 324 | 325 | # Telerik's JustMock configuration file 326 | *.jmconfig 327 | 328 | # BizTalk build output 329 | *.btp.cs 330 | *.btm.cs 331 | *.odx.cs 332 | *.xsd.cs 333 | 334 | # OpenCover UI analysis results 335 | OpenCover/ 336 | 337 | # Azure Stream Analytics local run output 338 | ASALocalRun/ 339 | 340 | # MSBuild Binary and Structured Log 341 | *.binlog 342 | 343 | # NVidia Nsight GPU debugger configuration file 344 | *.nvuser 345 | 346 | # MFractors (Xamarin productivity tool) working folder 347 | .mfractor/ 348 | 349 | # Local History for Visual Studio 350 | .localhistory/ 351 | 352 | # BeatPulse healthcheck temp database 353 | healthchecksdb 354 | 355 | # Backup folder for Package Reference Convert tool in Visual Studio 2017 356 | MigrationBackup/ 357 | 358 | # Ionide (cross platform F# VS Code tools) working folder 359 | .ionide/ 360 | 361 | # Fody - auto-generated XML schema 362 | FodyWeavers.xsd -------------------------------------------------------------------------------- /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 | * // 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: "example/index.js", 80 | // TODO: remove once @esemesek's patch is merged 81 | cliPath: "../node_modules/react-native/cli.js" 82 | ] 83 | 84 | apply from: "../../../node_modules/react-native/react.gradle" 85 | 86 | /** 87 | * Set this to true to create two separate APKs instead of one: 88 | * - An APK that only works on ARM devices 89 | * - An APK that only works on x86 devices 90 | * The advantage is the size of the APK is reduced by about 4MB. 91 | * Upload all the APKs to the Play Store and people will download 92 | * the correct one based on the CPU architecture of their device. 93 | */ 94 | def enableSeparateBuildPerCPUArchitecture = false 95 | 96 | /** 97 | * Run Proguard to shrink the Java bytecode in release builds. 98 | */ 99 | def enableProguardInReleaseBuilds = false 100 | 101 | /** 102 | * Use international variant JavaScriptCore 103 | * International variant includes ICU i18n library and necessary data allowing to use 104 | * e.g. Date.toLocaleString and String.localeCompare that give correct results 105 | * when using with locales other than en-US. 106 | * Note that this variant is about 6MiB larger per architecture than default. 107 | */ 108 | def useIntlJsc = false 109 | 110 | android { 111 | compileSdkVersion rootProject.ext.compileSdkVersion 112 | 113 | compileOptions { 114 | sourceCompatibility JavaVersion.VERSION_1_8 115 | targetCompatibility JavaVersion.VERSION_1_8 116 | } 117 | 118 | defaultConfig { 119 | applicationId "com.example" 120 | minSdkVersion rootProject.ext.minSdkVersion 121 | targetSdkVersion rootProject.ext.targetSdkVersion 122 | versionCode 1 123 | versionName "1.0" 124 | } 125 | splits { 126 | abi { 127 | reset() 128 | enable enableSeparateBuildPerCPUArchitecture 129 | universalApk false // If true, also generate a universal APK 130 | include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" 131 | } 132 | } 133 | signingConfigs { 134 | debug { 135 | storeFile file('debug.keystore') 136 | storePassword 'android' 137 | keyAlias 'androiddebugkey' 138 | keyPassword 'android' 139 | } 140 | } 141 | buildTypes { 142 | debug { 143 | signingConfig signingConfigs.debug 144 | } 145 | release { 146 | // Caution! In production, you need to generate your own keystore file. 147 | // see https://facebook.github.io/react-native/docs/signed-apk-android. 148 | signingConfig signingConfigs.debug 149 | minifyEnabled enableProguardInReleaseBuilds 150 | proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" 151 | } 152 | } 153 | // applicationVariants are e.g. debug, release 154 | applicationVariants.all { variant -> 155 | variant.outputs.each { output -> 156 | // For each separate APK per architecture, set a unique version code as described here: 157 | // https://developer.android.com/studio/build/configure-apk-splits.html 158 | def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] 159 | def abi = output.getFilter(OutputFile.ABI) 160 | if (abi != null) { // null for the universal-debug, universal-release variants 161 | output.versionCodeOverride = 162 | versionCodes.get(abi) * 1048576 + defaultConfig.versionCode 163 | } 164 | } 165 | } 166 | } 167 | 168 | dependencies { 169 | implementation fileTree(dir: "libs", include: ["*.jar"]) 170 | implementation "com.facebook.react:react-native:+" // From node_modules 171 | 172 | // JSC from node_modules 173 | if (useIntlJsc) { 174 | implementation 'org.webkit:android-jsc-intl:+' 175 | } else { 176 | implementation 'org.webkit:android-jsc:+' 177 | } 178 | } 179 | 180 | // Run this once to be able to run the application with BUCK 181 | // puts all compile dependencies into folder libs for BUCK to use 182 | task copyDownloadableDepsToLibs(type: Copy) { 183 | from configurations.compile 184 | into 'libs' 185 | } 186 | 187 | apply from: file("../../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); 188 | // set custom root because we're in a monorepo 189 | applyNativeModulesAppBuildGradle(project) 190 | -------------------------------------------------------------------------------- /src/android/src/main/java/com/reactnativecommunity/slider/ReactSlider.java: -------------------------------------------------------------------------------- 1 | /** 2 | * Copyright (c) Facebook, Inc. and its affiliates. 3 | * 4 | *

This source code is licensed under the MIT license found in the LICENSE file in the root 5 | * directory of this source tree. 6 | */ 7 | package com.reactnativecommunity.slider; 8 | 9 | import android.content.Context; 10 | import android.graphics.Bitmap; 11 | import android.graphics.BitmapFactory; 12 | import android.graphics.drawable.BitmapDrawable; 13 | import android.os.Build; 14 | import android.util.AttributeSet; 15 | import android.view.accessibility.AccessibilityEvent; 16 | import android.view.accessibility.AccessibilityManager; 17 | import androidx.appcompat.widget.AppCompatSeekBar; 18 | import java.net.URL; 19 | import java.util.List; 20 | import java.util.Timer; 21 | import java.util.TimerTask; 22 | import java.util.concurrent.Callable; 23 | import java.util.concurrent.ExecutorService; 24 | import java.util.concurrent.Executors; 25 | import java.util.concurrent.Future; 26 | import javax.annotation.Nullable; 27 | 28 | /** 29 | * Slider that behaves more like the iOS one, for consistency. 30 | * 31 | *

On iOS, the value is 0..1. Android SeekBar only supports integer values. For consistency, we 32 | * pretend in JS that the value is 0..1 but set the SeekBar value to 0..100. 33 | * 34 | *

Note that the slider is _not_ a controlled component (setValue isn't called during dragging). 35 | */ 36 | public class ReactSlider extends AppCompatSeekBar { 37 | 38 | /** 39 | * If step is 0 (unset) we default to this total number of steps. Don't use 100 which leads to 40 | * rounding errors (0.200000000001). 41 | */ 42 | private static int DEFAULT_TOTAL_STEPS = 128; 43 | 44 | /** 45 | * We want custom min..max range. Android only supports 0..max range so we implement this 46 | * ourselves. 47 | */ 48 | private double mMinValue = 0; 49 | 50 | private double mMaxValue = 0; 51 | 52 | /** 53 | * Value sent from JS (setState). Doesn't get updated during drag (slider is not a controlled 54 | * component). 55 | */ 56 | private double mValue = 0; 57 | 58 | /** If zero it's determined automatically. */ 59 | private double mStep = 0; 60 | 61 | private double mStepCalculated = 0; 62 | 63 | private String mAccessibilityUnits; 64 | 65 | private List mAccessibilityIncrements; 66 | 67 | public ReactSlider(Context context, @Nullable AttributeSet attrs, int style) { 68 | super(context, attrs, style); 69 | disableStateListAnimatorIfNeeded(); 70 | } 71 | 72 | private void disableStateListAnimatorIfNeeded() { 73 | // We disable the state list animator for Android 6 and 7; this is a hack to prevent T37452851 74 | // and https://github.com/facebook/react-native/issues/9979 75 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M 76 | && Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { 77 | super.setStateListAnimator(null); 78 | } 79 | } 80 | 81 | /* package */ void setMaxValue(double max) { 82 | mMaxValue = max; 83 | updateAll(); 84 | } 85 | 86 | /* package */ void setMinValue(double min) { 87 | mMinValue = min; 88 | updateAll(); 89 | } 90 | 91 | /* package */ void setValue(double value) { 92 | mValue = value; 93 | updateValue(); 94 | } 95 | 96 | /* package */ void setStep(double step) { 97 | mStep = step; 98 | updateAll(); 99 | } 100 | 101 | void setAccessibilityUnits(String accessibilityUnits) { 102 | mAccessibilityUnits = accessibilityUnits; 103 | } 104 | 105 | void setAccessibilityIncrements(List accessibilityIncrements) { 106 | mAccessibilityIncrements = accessibilityIncrements; 107 | } 108 | 109 | @Override 110 | public void onPopulateAccessibilityEvent(AccessibilityEvent event) { 111 | super.onPopulateAccessibilityEvent(event); 112 | if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED || 113 | (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SELECTED && this.isAccessibilityFocused())) { 114 | this.setupAccessibility(); 115 | } 116 | } 117 | 118 | @Override 119 | public void announceForAccessibility(CharSequence text) { 120 | Context ctx = this.getContext(); 121 | final AccessibilityManager manager = (AccessibilityManager) ctx.getSystemService(Context.ACCESSIBILITY_SERVICE); 122 | 123 | if (manager.isEnabled()) { 124 | final AccessibilityEvent e = AccessibilityEvent.obtain(); 125 | e.setEventType(AccessibilityEvent.TYPE_ANNOUNCEMENT); 126 | e.setClassName(this.getClass().getName()); 127 | e.setPackageName(ctx.getPackageName()); 128 | e.getText().add(text); 129 | 130 | TimerTask task = new TimerTask() { 131 | @Override 132 | public void run() { 133 | manager.sendAccessibilityEvent(e); 134 | } 135 | }; 136 | 137 | Timer timer = new Timer(); 138 | timer.schedule(task, 1000); 139 | } 140 | } 141 | 142 | private void setupAccessibility() { 143 | if (mAccessibilityUnits != null && mAccessibilityIncrements != null && mAccessibilityIncrements.size() - 1 == (int)mMaxValue) { 144 | int index = (int)mValue; 145 | String sliderValue = mAccessibilityIncrements.get(index); 146 | int stringLength = mAccessibilityUnits.length(); 147 | 148 | String spokenUnits = mAccessibilityUnits; 149 | if (sliderValue != null && Integer.parseInt(sliderValue) == 1) { 150 | spokenUnits = spokenUnits.substring(0, stringLength - 1); 151 | } 152 | 153 | this.announceForAccessibility(String.format("%s %s", sliderValue, spokenUnits)); 154 | } 155 | } 156 | 157 | 158 | 159 | /** 160 | * Convert SeekBar's native progress value (e.g. 0..100) to a value passed to JS (e.g. -1.0..2.5). 161 | */ 162 | public double toRealProgress(int seekBarProgress) { 163 | if (seekBarProgress == getMax()) { 164 | return mMaxValue; 165 | } 166 | return seekBarProgress * getStepValue() + mMinValue; 167 | } 168 | 169 | /** Update underlying native SeekBar's values. */ 170 | private void updateAll() { 171 | if (mStep == 0) { 172 | mStepCalculated = (mMaxValue - mMinValue) / (double) DEFAULT_TOTAL_STEPS; 173 | } 174 | setMax(getTotalSteps()); 175 | updateValue(); 176 | } 177 | 178 | /** Update value only (optimization in case only value is set). */ 179 | private void updateValue() { 180 | setProgress((int) Math.round((mValue - mMinValue) / (mMaxValue - mMinValue) * getTotalSteps())); 181 | } 182 | 183 | private int getTotalSteps() { 184 | return (int) Math.ceil((mMaxValue - mMinValue) / getStepValue()); 185 | } 186 | 187 | private double getStepValue() { 188 | return mStep > 0 ? mStep : mStepCalculated; 189 | } 190 | 191 | private BitmapDrawable getBitmapDrawable(final String uri) { 192 | BitmapDrawable bitmapDrawable = null; 193 | ExecutorService executorService = Executors.newSingleThreadExecutor(); 194 | Future future = executorService.submit(new Callable() { 195 | @Override 196 | public BitmapDrawable call() { 197 | BitmapDrawable bitmapDrawable = null; 198 | try { 199 | Bitmap bitmap = null; 200 | if (uri.startsWith("http://") || uri.startsWith("https://") || 201 | uri.startsWith("file://") || uri.startsWith("asset://") || uri.startsWith("data:")) { 202 | bitmap = BitmapFactory.decodeStream(new URL(uri).openStream()); 203 | } else { 204 | int drawableId = getResources() 205 | .getIdentifier(uri, "drawable", getContext() 206 | .getPackageName()); 207 | bitmap = BitmapFactory.decodeResource(getResources(), drawableId); 208 | } 209 | 210 | bitmapDrawable = new BitmapDrawable(getResources(), bitmap); 211 | } catch (Exception e) { 212 | e.printStackTrace(); 213 | } 214 | return bitmapDrawable; 215 | } 216 | }); 217 | try { 218 | bitmapDrawable = future.get(); 219 | } catch (Exception e) { 220 | e.printStackTrace(); 221 | } 222 | return bitmapDrawable; 223 | } 224 | 225 | public void setThumbImage(final String uri) { 226 | if (uri != null) { 227 | setThumb(getBitmapDrawable(uri)); 228 | // Enable alpha channel for the thumbImage 229 | if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { 230 | setSplitTrack(false); 231 | } 232 | } else { 233 | setThumb(getThumb()); 234 | } 235 | } 236 | } 237 | -------------------------------------------------------------------------------- /src/android/src/main/java/com/reactnativecommunity/slider/ReactSliderManager.java: -------------------------------------------------------------------------------- 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 | package com.reactnativecommunity.slider; 9 | 10 | import android.os.Build; 11 | import android.graphics.PorterDuff; 12 | import android.graphics.drawable.Drawable; 13 | import android.graphics.drawable.LayerDrawable; 14 | import android.view.View; 15 | import android.widget.SeekBar; 16 | import com.facebook.react.bridge.ReactContext; 17 | import com.facebook.react.bridge.ReadableArray; 18 | import com.facebook.react.bridge.ReadableMap; 19 | import com.facebook.react.common.MapBuilder; 20 | import com.facebook.react.uimanager.LayoutShadowNode; 21 | import com.facebook.react.uimanager.SimpleViewManager; 22 | import com.facebook.react.uimanager.ThemedReactContext; 23 | import com.facebook.react.uimanager.UIManagerModule; 24 | import com.facebook.react.uimanager.ViewProps; 25 | import com.facebook.react.uimanager.annotations.ReactProp; 26 | import com.facebook.yoga.YogaMeasureFunction; 27 | import com.facebook.yoga.YogaMeasureMode; 28 | import com.facebook.yoga.YogaMeasureOutput; 29 | import com.facebook.yoga.YogaNode; 30 | import java.util.ArrayList; 31 | import java.util.List; 32 | import java.util.Map; 33 | import javax.annotation.Nullable; 34 | 35 | /** 36 | * Manages instances of {@code ReactSlider}. 37 | * 38 | * Note that the slider is _not_ a controlled component. 39 | */ 40 | public class ReactSliderManager extends SimpleViewManager { 41 | 42 | private static final int STYLE = android.R.attr.seekBarStyle; 43 | 44 | public static final String REACT_CLASS = "RNCSlider"; 45 | 46 | static class ReactSliderShadowNode extends LayoutShadowNode implements 47 | YogaMeasureFunction { 48 | 49 | private int mWidth; 50 | private int mHeight; 51 | private boolean mMeasured; 52 | 53 | private ReactSliderShadowNode() { 54 | initMeasureFunction(); 55 | } 56 | 57 | private void initMeasureFunction() { 58 | setMeasureFunction(this); 59 | } 60 | 61 | @Override 62 | public long measure( 63 | YogaNode node, 64 | float width, 65 | YogaMeasureMode widthMode, 66 | float height, 67 | YogaMeasureMode heightMode) { 68 | if (!mMeasured) { 69 | SeekBar reactSlider = new ReactSlider(getThemedContext(), null, STYLE); 70 | final int spec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); 71 | reactSlider.measure(spec, spec); 72 | mWidth = reactSlider.getMeasuredWidth(); 73 | mHeight = reactSlider.getMeasuredHeight(); 74 | mMeasured = true; 75 | } 76 | 77 | return YogaMeasureOutput.make(mWidth, mHeight); 78 | } 79 | } 80 | 81 | private static final SeekBar.OnSeekBarChangeListener ON_CHANGE_LISTENER = 82 | new SeekBar.OnSeekBarChangeListener() { 83 | @Override 84 | public void onProgressChanged(SeekBar seekbar, int progress, boolean fromUser) { 85 | ReactContext reactContext = (ReactContext) seekbar.getContext(); 86 | reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher().dispatchEvent( 87 | new ReactSliderEvent( 88 | seekbar.getId(), 89 | ((ReactSlider) seekbar).toRealProgress(progress), 90 | fromUser)); 91 | } 92 | 93 | @Override 94 | public void onStartTrackingTouch(SeekBar seekbar) { 95 | ReactContext reactContext = (ReactContext) seekbar.getContext(); 96 | reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher().dispatchEvent( 97 | new ReactSlidingStartEvent( 98 | seekbar.getId(), 99 | ((ReactSlider) seekbar).toRealProgress(seekbar.getProgress()))); 100 | } 101 | 102 | @Override 103 | public void onStopTrackingTouch(SeekBar seekbar) { 104 | ReactContext reactContext = (ReactContext) seekbar.getContext(); 105 | reactContext.getNativeModule(UIManagerModule.class).getEventDispatcher().dispatchEvent( 106 | new ReactSlidingCompleteEvent( 107 | seekbar.getId(), 108 | ((ReactSlider) seekbar).toRealProgress(seekbar.getProgress()))); 109 | } 110 | }; 111 | 112 | @Override 113 | public String getName() { 114 | return REACT_CLASS; 115 | } 116 | 117 | @Override 118 | public LayoutShadowNode createShadowNodeInstance() { 119 | return new ReactSliderShadowNode(); 120 | } 121 | 122 | @Override 123 | public Class getShadowNodeClass() { 124 | return ReactSliderShadowNode.class; 125 | } 126 | 127 | @Override 128 | protected ReactSlider createViewInstance(ThemedReactContext context) { 129 | ReactSlider slider = new ReactSlider(context, null, STYLE); 130 | 131 | if (Build.VERSION.SDK_INT >= 21) { 132 | /** 133 | * The "splitTrack" parameter should have "false" value, 134 | * otherwise the SeekBar progress line doesn't appear when it is rotated. 135 | */ 136 | slider.setSplitTrack(false); 137 | } 138 | 139 | return slider; 140 | } 141 | 142 | @ReactProp(name = ViewProps.ENABLED, defaultBoolean = true) 143 | public void setEnabled(ReactSlider view, boolean enabled) { 144 | view.setEnabled(enabled); 145 | } 146 | 147 | @ReactProp(name = "value", defaultDouble = 0d) 148 | public void setValue(ReactSlider view, double value) { 149 | view.setOnSeekBarChangeListener(null); 150 | view.setValue(value); 151 | view.setOnSeekBarChangeListener(ON_CHANGE_LISTENER); 152 | } 153 | 154 | @ReactProp(name = "minimumValue", defaultDouble = 0d) 155 | public void setMinimumValue(ReactSlider view, double value) { 156 | view.setMinValue(value); 157 | } 158 | 159 | @ReactProp(name = "maximumValue", defaultDouble = 1d) 160 | public void setMaximumValue(ReactSlider view, double value) { 161 | view.setMaxValue(value); 162 | } 163 | 164 | @ReactProp(name = "step", defaultDouble = 0d) 165 | public void setStep(ReactSlider view, double value) { 166 | view.setStep(value); 167 | } 168 | 169 | @ReactProp(name = "thumbTintColor", customType = "Color") 170 | public void setThumbTintColor(ReactSlider view, Integer color) { 171 | if (view.getThumb() != null) { 172 | if (color == null) { 173 | view.getThumb().clearColorFilter(); 174 | } else { 175 | view.getThumb().setColorFilter(color, PorterDuff.Mode.SRC_IN); 176 | } 177 | } 178 | } 179 | 180 | @ReactProp(name = "minimumTrackTintColor", customType = "Color") 181 | public void setMinimumTrackTintColor(ReactSlider view, Integer color) { 182 | LayerDrawable drawable = (LayerDrawable) view.getProgressDrawable().getCurrent(); 183 | Drawable progress = drawable.findDrawableByLayerId(android.R.id.progress); 184 | if (color == null) { 185 | progress.clearColorFilter(); 186 | } else { 187 | progress.setColorFilter(color, PorterDuff.Mode.SRC_IN); 188 | } 189 | } 190 | 191 | @ReactProp(name = "thumbImage") 192 | public void setThumbImage(ReactSlider view, @Nullable ReadableMap source) { 193 | String uri = null; 194 | if (source != null) { 195 | uri = source.getString("uri"); 196 | } 197 | view.setThumbImage(uri); 198 | } 199 | 200 | @ReactProp(name = "maximumTrackTintColor", customType = "Color") 201 | public void setMaximumTrackTintColor(ReactSlider view, Integer color) { 202 | LayerDrawable drawable = (LayerDrawable) view.getProgressDrawable().getCurrent(); 203 | Drawable background = drawable.findDrawableByLayerId(android.R.id.background); 204 | if (color == null) { 205 | background.clearColorFilter(); 206 | } else { 207 | background.setColorFilter(color, PorterDuff.Mode.SRC_IN); 208 | } 209 | } 210 | 211 | @ReactProp(name = "inverted", defaultBoolean = false) 212 | public void setInverted(ReactSlider view, boolean inverted) { 213 | if (inverted) view.setScaleX(-1f); 214 | else view.setScaleX(1f); 215 | } 216 | 217 | @ReactProp(name = "accessibilityUnits") 218 | public void setAccessibilityUnits(ReactSlider view, String accessibilityUnits) { 219 | view.setAccessibilityUnits(accessibilityUnits); 220 | } 221 | 222 | @ReactProp(name = "accessibilityIncrements") 223 | public void setAccessibilityIncrements(ReactSlider view, ReadableArray accessibilityIncrements) { 224 | List objectList = accessibilityIncrements.toArrayList(); 225 | List stringList = new ArrayList<>(); 226 | for(Object item: objectList) { 227 | stringList.add((String)item); 228 | } 229 | view.setAccessibilityIncrements(stringList); 230 | } 231 | 232 | @Override 233 | protected void addEventEmitters(final ThemedReactContext reactContext, final ReactSlider view) { 234 | view.setOnSeekBarChangeListener(ON_CHANGE_LISTENER); 235 | } 236 | 237 | @Override 238 | public Map getExportedCustomDirectEventTypeConstants() { 239 | return MapBuilder.of(ReactSlidingCompleteEvent.EVENT_NAME, MapBuilder.of("registrationName", "onRNCSliderSlidingComplete"), 240 | ReactSlidingStartEvent.EVENT_NAME, MapBuilder.of("registrationName", "onRNCSliderSlidingStart")); 241 | } 242 | } 243 | -------------------------------------------------------------------------------- /src/js/Slider.js: -------------------------------------------------------------------------------- 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 | * @format 8 | * @flow 9 | */ 10 | 11 | 'use strict'; 12 | 13 | import React from 'react'; 14 | import {Image, Platform, StyleSheet} from 'react-native'; 15 | import RCTSliderNativeComponent from './RNCSliderNativeComponent'; 16 | 17 | import type {Ref} from 'react'; 18 | import type {NativeComponent} from 'react-native/Libraries/Renderer/shims/ReactNative'; 19 | import type {ImageSource} from 'react-native/Libraries/Image/ImageSource'; 20 | import type {ViewStyleProp} from 'react-native/Libraries/StyleSheet/StyleSheet'; 21 | import type {ColorValue} from 'react-native/Libraries/StyleSheet/StyleSheetTypes'; 22 | import type {ViewProps} from 'react-native/Libraries/Components/View/ViewPropTypes'; 23 | import type {SyntheticEvent} from 'react-native/Libraries/Types/CoreEventTypes'; 24 | 25 | type Event = SyntheticEvent< 26 | $ReadOnly<{| 27 | value: number, 28 | /** 29 | * Android Only. 30 | */ 31 | fromUser?: boolean, 32 | |}>, 33 | >; 34 | 35 | type WindowsProps = $ReadOnly<{| 36 | /** 37 | * If true the slider will be inverted. 38 | * Default value is false. 39 | */ 40 | vertical?: ?boolean, 41 | |}>; 42 | 43 | type IOSProps = $ReadOnly<{| 44 | /** 45 | * Assigns a single image for the track. Only static images are supported. 46 | * The center pixel of the image will be stretched to fill the track. 47 | */ 48 | trackImage?: ?ImageSource, 49 | 50 | /** 51 | * Assigns a minimum track image. Only static images are supported. The 52 | * rightmost pixel of the image will be stretched to fill the track. 53 | */ 54 | minimumTrackImage?: ?ImageSource, 55 | 56 | /** 57 | * Assigns a maximum track image. Only static images are supported. The 58 | * leftmost pixel of the image will be stretched to fill the track. 59 | */ 60 | maximumTrackImage?: ?ImageSource, 61 | |}>; 62 | 63 | type Props = $ReadOnly<{| 64 | ...ViewProps, 65 | ...IOSProps, 66 | ...WindowsProps, 67 | 68 | /** 69 | * Used to style and layout the `Slider`. See `StyleSheet.js` and 70 | * `DeprecatedViewStylePropTypes.js` for more info. 71 | */ 72 | style?: ?ViewStyleProp, 73 | 74 | /** 75 | * Initial value of the slider. The value should be between minimumValue 76 | * and maximumValue, which default to 0 and 1 respectively. 77 | * Default value is 0. 78 | * 79 | * *This is not a controlled component*, you don't need to update the 80 | * value during dragging. 81 | */ 82 | value?: ?number, 83 | 84 | /** 85 | * Step value of the slider. The value should be 86 | * between 0 and (maximumValue - minimumValue). 87 | * Default value is 0. 88 | */ 89 | step?: ?number, 90 | 91 | /** 92 | * Initial minimum value of the slider. Default value is 0. 93 | */ 94 | minimumValue?: ?number, 95 | 96 | /** 97 | * Initial maximum value of the slider. Default value is 1. 98 | */ 99 | maximumValue?: ?number, 100 | 101 | /** 102 | * The color used for the track to the left of the button. 103 | * Overrides the default blue gradient image on iOS. 104 | */ 105 | minimumTrackTintColor?: ?ColorValue, 106 | 107 | /** 108 | * The color used for the track to the right of the button. 109 | * Overrides the default blue gradient image on iOS. 110 | */ 111 | maximumTrackTintColor?: ?ColorValue, 112 | /** 113 | * The color used to tint the default thumb images on iOS, or the 114 | * color of the foreground switch grip on Android. 115 | */ 116 | thumbTintColor?: ?ColorValue, 117 | 118 | /** 119 | * If true the user won't be able to move the slider. 120 | * Default value is false. 121 | */ 122 | disabled?: ?boolean, 123 | 124 | /** 125 | * Callback continuously called while the user is dragging the slider. 126 | */ 127 | onValueChange?: ?(value: number) => void, 128 | 129 | /** 130 | * Callback that is called when the user touches the slider, 131 | * regardless if the value has changed. The current value is passed 132 | * as an argument to the callback handler. 133 | */ 134 | 135 | onSlidingStart?: ?(value: number) => void, 136 | 137 | /** 138 | * Callback that is called when the user releases the slider, 139 | * regardless if the value has changed. The current value is passed 140 | * as an argument to the callback handler. 141 | */ 142 | onSlidingComplete?: ?(value: number) => void, 143 | 144 | /** 145 | * Used to locate this view in UI automation tests. 146 | */ 147 | testID?: ?string, 148 | 149 | /** 150 | * Sets an image for the thumb. Only static images are supported. 151 | */ 152 | thumbImage?: ?ImageSource, 153 | 154 | /** 155 | * If true the slider will be inverted. 156 | * Default value is false. 157 | */ 158 | inverted?: ?boolean, 159 | 160 | /** 161 | * A string of one or more words to be announced by the screen reader. 162 | * Otherwise, it will announce the value as a percentage. 163 | * Requires passing a value to `accessibilityIncrements` to work correctly. 164 | * Should be a plural word, as singular units will be handled. 165 | */ 166 | accessibilityUnits?: string, 167 | 168 | /** 169 | * An array of values that represent the different increments displayed 170 | * by the slider. All the values passed into this prop must be strings. 171 | * Requires passing a value to `accessibilityUnits` to work correctly. 172 | * The number of elements must be the same as `maximumValue`. 173 | */ 174 | accessibilityIncrements?: Array, 175 | |}>; 176 | 177 | /** 178 | * A component used to select a single value from a range of values. 179 | * 180 | * ### Usage 181 | * 182 | * The example below shows how to use `Slider` to change 183 | * a value used by `Text`. The value is stored using 184 | * the state of the root component (`App`). The same component 185 | * subscribes to the `onValueChange` of `Slider` and changes 186 | * the value using `setState`. 187 | * 188 | *``` 189 | * import React from 'react'; 190 | * import { StyleSheet, Text, View, Slider } from 'react-native'; 191 | * 192 | * export default class App extends React.Component { 193 | * constructor(props) { 194 | * super(props); 195 | * this.state = { 196 | * value: 50 197 | * } 198 | * } 199 | * 200 | * change(value) { 201 | * this.setState(() => { 202 | * return { 203 | * value: parseFloat(value) 204 | * }; 205 | * }); 206 | * } 207 | * 208 | * render() { 209 | * const {value} = this.state; 210 | * return ( 211 | * 212 | * {String(value)} 213 | * 218 | * 219 | * ); 220 | * } 221 | * } 222 | * 223 | * const styles = StyleSheet.create({ 224 | * container: { 225 | * flex: 1, 226 | * flexDirection: 'column', 227 | * justifyContent: 'center' 228 | * }, 229 | * text: { 230 | * fontSize: 50, 231 | * textAlign: 'center' 232 | * } 233 | * }); 234 | *``` 235 | * 236 | */ 237 | const SliderComponent = ( 238 | props: Props, 239 | forwardedRef?: ?Ref, 240 | ) => { 241 | const style = StyleSheet.compose( 242 | styles.slider, 243 | props.style, 244 | ); 245 | 246 | const { 247 | onValueChange, 248 | onSlidingStart, 249 | onSlidingComplete, 250 | ...localProps 251 | } = props; 252 | 253 | const onValueChangeEvent = onValueChange 254 | ? (event: Event) => { 255 | let userEvent = true; 256 | if (Platform.OS === 'android') { 257 | // On Android there's a special flag telling us the user is 258 | // dragging the slider. 259 | userEvent = 260 | event.nativeEvent.fromUser != null && event.nativeEvent.fromUser; 261 | } 262 | userEvent && onValueChange(event.nativeEvent.value); 263 | } 264 | : null; 265 | 266 | const onChangeEvent = onValueChangeEvent; 267 | const onSlidingStartEvent = onSlidingStart 268 | ? (event: Event) => { 269 | onSlidingStart(event.nativeEvent.value); 270 | } 271 | : null; 272 | const onSlidingCompleteEvent = onSlidingComplete 273 | ? (event: Event) => { 274 | onSlidingComplete(event.nativeEvent.value); 275 | } 276 | : null; 277 | 278 | return ( 279 | true} 294 | onResponderTerminationRequest={() => false} 295 | /> 296 | ); 297 | }; 298 | 299 | const SliderWithRef = React.forwardRef(SliderComponent); 300 | 301 | /* $FlowFixMe(>=0.89.0 site=react_native_fb) This comment suppresses an error 302 | * found when Flow v0.89 was deployed. To see the error, delete this comment 303 | * and run Flow. */ 304 | 305 | SliderWithRef.defaultProps = { 306 | disabled: false, 307 | value: 0, 308 | minimumValue: 0, 309 | maximumValue: 1, 310 | step: 0, 311 | inverted: false, 312 | tapToSeek: false, 313 | }; 314 | 315 | let styles; 316 | if (Platform.OS === 'ios') { 317 | styles = StyleSheet.create({ 318 | slider: { 319 | height: 40, 320 | }, 321 | }); 322 | } else { 323 | styles = StyleSheet.create({ 324 | slider: {}, 325 | }); 326 | } 327 | 328 | /* $FlowFixMe(>=0.89.0 site=react_native_fb) This comment suppresses an error 329 | * found when Flow v0.89 was deployed. To see the error, delete this comment 330 | * and run Flow. */ 331 | const Slider = (SliderWithRef: Class>); 332 | export default Slider; 333 | -------------------------------------------------------------------------------- /src/ios/RNCSlider.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 50; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 28C79A22220DC7760061DE82 /* RNCSliderManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 28C79A1F220DC7760061DE82 /* RNCSliderManager.m */; }; 11 | 28C79A23220DC7760061DE82 /* RNCSlider.m in Sources */ = {isa = PBXBuildFile; fileRef = 28C79A21220DC7760061DE82 /* RNCSlider.m */; }; 12 | /* End PBXBuildFile section */ 13 | 14 | /* Begin PBXCopyFilesBuildPhase section */ 15 | 28C79A07220DC4CC0061DE82 /* CopyFiles */ = { 16 | isa = PBXCopyFilesBuildPhase; 17 | buildActionMask = 2147483647; 18 | dstPath = "include/$(PRODUCT_NAME)"; 19 | dstSubfolderSpec = 16; 20 | files = ( 21 | ); 22 | runOnlyForDeploymentPostprocessing = 0; 23 | }; 24 | /* End PBXCopyFilesBuildPhase section */ 25 | 26 | /* Begin PBXFileReference section */ 27 | 28C79A09220DC4CC0061DE82 /* libRNCSlider.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRNCSlider.a; sourceTree = BUILT_PRODUCTS_DIR; }; 28 | 28C79A1E220DC7760061DE82 /* RNCSlider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNCSlider.h; sourceTree = ""; }; 29 | 28C79A1F220DC7760061DE82 /* RNCSliderManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNCSliderManager.m; sourceTree = ""; }; 30 | 28C79A20220DC7760061DE82 /* RNCSliderManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RNCSliderManager.h; sourceTree = ""; }; 31 | 28C79A21220DC7760061DE82 /* RNCSlider.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RNCSlider.m; sourceTree = ""; }; 32 | /* End PBXFileReference section */ 33 | 34 | /* Begin PBXFrameworksBuildPhase section */ 35 | 28C79A06220DC4CC0061DE82 /* Frameworks */ = { 36 | isa = PBXFrameworksBuildPhase; 37 | buildActionMask = 2147483647; 38 | files = ( 39 | ); 40 | runOnlyForDeploymentPostprocessing = 0; 41 | }; 42 | /* End PBXFrameworksBuildPhase section */ 43 | 44 | /* Begin PBXGroup section */ 45 | 28C79A00220DC4CC0061DE82 = { 46 | isa = PBXGroup; 47 | children = ( 48 | 28C79A1E220DC7760061DE82 /* RNCSlider.h */, 49 | 28C79A21220DC7760061DE82 /* RNCSlider.m */, 50 | 28C79A20220DC7760061DE82 /* RNCSliderManager.h */, 51 | 28C79A1F220DC7760061DE82 /* RNCSliderManager.m */, 52 | 28C79A0A220DC4CC0061DE82 /* Products */, 53 | ); 54 | sourceTree = ""; 55 | }; 56 | 28C79A0A220DC4CC0061DE82 /* Products */ = { 57 | isa = PBXGroup; 58 | children = ( 59 | 28C79A09220DC4CC0061DE82 /* libRNCSlider.a */, 60 | ); 61 | name = Products; 62 | sourceTree = ""; 63 | }; 64 | /* End PBXGroup section */ 65 | 66 | /* Begin PBXNativeTarget section */ 67 | 28C79A08220DC4CC0061DE82 /* RNCSlider */ = { 68 | isa = PBXNativeTarget; 69 | buildConfigurationList = 28C79A12220DC4CC0061DE82 /* Build configuration list for PBXNativeTarget "RNCSlider" */; 70 | buildPhases = ( 71 | 28C79A05220DC4CC0061DE82 /* Sources */, 72 | 28C79A06220DC4CC0061DE82 /* Frameworks */, 73 | 28C79A07220DC4CC0061DE82 /* CopyFiles */, 74 | ); 75 | buildRules = ( 76 | ); 77 | dependencies = ( 78 | ); 79 | name = RNCSlider; 80 | productName = RNCSlider; 81 | productReference = 28C79A09220DC4CC0061DE82 /* libRNCSlider.a */; 82 | productType = "com.apple.product-type.library.static"; 83 | }; 84 | /* End PBXNativeTarget section */ 85 | 86 | /* Begin PBXProject section */ 87 | 28C79A01220DC4CC0061DE82 /* Project object */ = { 88 | isa = PBXProject; 89 | attributes = { 90 | LastUpgradeCheck = 1010; 91 | ORGANIZATIONNAME = "React Native Community"; 92 | TargetAttributes = { 93 | 28C79A08220DC4CC0061DE82 = { 94 | CreatedOnToolsVersion = 10.1; 95 | }; 96 | }; 97 | }; 98 | buildConfigurationList = 28C79A04220DC4CC0061DE82 /* Build configuration list for PBXProject "RNCSlider" */; 99 | compatibilityVersion = "Xcode 9.3"; 100 | developmentRegion = en; 101 | hasScannedForEncodings = 0; 102 | knownRegions = ( 103 | en, 104 | ); 105 | mainGroup = 28C79A00220DC4CC0061DE82; 106 | productRefGroup = 28C79A0A220DC4CC0061DE82 /* Products */; 107 | projectDirPath = ""; 108 | projectRoot = ""; 109 | targets = ( 110 | 28C79A08220DC4CC0061DE82 /* RNCSlider */, 111 | ); 112 | }; 113 | /* End PBXProject section */ 114 | 115 | /* Begin PBXSourcesBuildPhase section */ 116 | 28C79A05220DC4CC0061DE82 /* Sources */ = { 117 | isa = PBXSourcesBuildPhase; 118 | buildActionMask = 2147483647; 119 | files = ( 120 | 28C79A23220DC7760061DE82 /* RNCSlider.m in Sources */, 121 | 28C79A22220DC7760061DE82 /* RNCSliderManager.m in Sources */, 122 | ); 123 | runOnlyForDeploymentPostprocessing = 0; 124 | }; 125 | /* End PBXSourcesBuildPhase section */ 126 | 127 | /* Begin XCBuildConfiguration section */ 128 | 28C79A10220DC4CC0061DE82 /* Debug */ = { 129 | isa = XCBuildConfiguration; 130 | buildSettings = { 131 | ALWAYS_SEARCH_USER_PATHS = NO; 132 | CLANG_ANALYZER_NONNULL = YES; 133 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 134 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 135 | CLANG_CXX_LIBRARY = "libc++"; 136 | CLANG_ENABLE_MODULES = YES; 137 | CLANG_ENABLE_OBJC_ARC = YES; 138 | CLANG_ENABLE_OBJC_WEAK = YES; 139 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 140 | CLANG_WARN_BOOL_CONVERSION = YES; 141 | CLANG_WARN_COMMA = YES; 142 | CLANG_WARN_CONSTANT_CONVERSION = YES; 143 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 144 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 145 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 146 | CLANG_WARN_EMPTY_BODY = YES; 147 | CLANG_WARN_ENUM_CONVERSION = YES; 148 | CLANG_WARN_INFINITE_RECURSION = YES; 149 | CLANG_WARN_INT_CONVERSION = YES; 150 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 151 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 152 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 153 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 154 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 155 | CLANG_WARN_STRICT_PROTOTYPES = YES; 156 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 157 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 158 | CLANG_WARN_UNREACHABLE_CODE = YES; 159 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 160 | COPY_PHASE_STRIP = NO; 161 | ENABLE_STRICT_OBJC_MSGSEND = YES; 162 | ENABLE_TESTABILITY = YES; 163 | GCC_C_LANGUAGE_STANDARD = gnu99; 164 | GCC_DYNAMIC_NO_PIC = NO; 165 | GCC_NO_COMMON_BLOCKS = YES; 166 | GCC_OPTIMIZATION_LEVEL = 0; 167 | GCC_PREPROCESSOR_DEFINITIONS = ( 168 | "DEBUG=1", 169 | "$(inherited)", 170 | ); 171 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 172 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 173 | GCC_WARN_UNDECLARED_SELECTOR = YES; 174 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 175 | GCC_WARN_UNUSED_FUNCTION = YES; 176 | GCC_WARN_UNUSED_VARIABLE = YES; 177 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 178 | MTL_ENABLE_DEBUG_INFO = YES; 179 | MTL_FAST_MATH = YES; 180 | ONLY_ACTIVE_ARCH = YES; 181 | SDKROOT = iphoneos; 182 | }; 183 | name = Debug; 184 | }; 185 | 28C79A11220DC4CC0061DE82 /* Release */ = { 186 | isa = XCBuildConfiguration; 187 | buildSettings = { 188 | ALWAYS_SEARCH_USER_PATHS = NO; 189 | CLANG_ANALYZER_NONNULL = YES; 190 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; 191 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 192 | CLANG_CXX_LIBRARY = "libc++"; 193 | CLANG_ENABLE_MODULES = YES; 194 | CLANG_ENABLE_OBJC_ARC = YES; 195 | CLANG_ENABLE_OBJC_WEAK = YES; 196 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 197 | CLANG_WARN_BOOL_CONVERSION = YES; 198 | CLANG_WARN_COMMA = YES; 199 | CLANG_WARN_CONSTANT_CONVERSION = YES; 200 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 201 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 202 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 203 | CLANG_WARN_EMPTY_BODY = YES; 204 | CLANG_WARN_ENUM_CONVERSION = YES; 205 | CLANG_WARN_INFINITE_RECURSION = YES; 206 | CLANG_WARN_INT_CONVERSION = YES; 207 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 208 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 209 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 210 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 211 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 212 | CLANG_WARN_STRICT_PROTOTYPES = YES; 213 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 214 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; 215 | CLANG_WARN_UNREACHABLE_CODE = YES; 216 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 217 | COPY_PHASE_STRIP = YES; 218 | ENABLE_NS_ASSERTIONS = NO; 219 | ENABLE_STRICT_OBJC_MSGSEND = YES; 220 | GCC_C_LANGUAGE_STANDARD = gnu99; 221 | GCC_NO_COMMON_BLOCKS = YES; 222 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 223 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 224 | GCC_WARN_UNDECLARED_SELECTOR = YES; 225 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 226 | GCC_WARN_UNUSED_FUNCTION = YES; 227 | GCC_WARN_UNUSED_VARIABLE = YES; 228 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 229 | MTL_ENABLE_DEBUG_INFO = NO; 230 | MTL_FAST_MATH = YES; 231 | SDKROOT = iphoneos; 232 | VALIDATE_PRODUCT = YES; 233 | }; 234 | name = Release; 235 | }; 236 | 28C79A13220DC4CC0061DE82 /* Debug */ = { 237 | isa = XCBuildConfiguration; 238 | buildSettings = { 239 | OTHER_LDFLAGS = "-ObjC"; 240 | PRODUCT_NAME = "$(TARGET_NAME)"; 241 | SKIP_INSTALL = YES; 242 | }; 243 | name = Debug; 244 | }; 245 | 28C79A14220DC4CC0061DE82 /* Release */ = { 246 | isa = XCBuildConfiguration; 247 | buildSettings = { 248 | OTHER_LDFLAGS = "-ObjC"; 249 | PRODUCT_NAME = "$(TARGET_NAME)"; 250 | SKIP_INSTALL = YES; 251 | }; 252 | name = Release; 253 | }; 254 | /* End XCBuildConfiguration section */ 255 | 256 | /* Begin XCConfigurationList section */ 257 | 28C79A04220DC4CC0061DE82 /* Build configuration list for PBXProject "RNCSlider" */ = { 258 | isa = XCConfigurationList; 259 | buildConfigurations = ( 260 | 28C79A10220DC4CC0061DE82 /* Debug */, 261 | 28C79A11220DC4CC0061DE82 /* Release */, 262 | ); 263 | defaultConfigurationIsVisible = 0; 264 | defaultConfigurationName = Release; 265 | }; 266 | 28C79A12220DC4CC0061DE82 /* Build configuration list for PBXNativeTarget "RNCSlider" */ = { 267 | isa = XCConfigurationList; 268 | buildConfigurations = ( 269 | 28C79A13220DC4CC0061DE82 /* Debug */, 270 | 28C79A14220DC4CC0061DE82 /* Release */, 271 | ); 272 | defaultConfigurationIsVisible = 0; 273 | defaultConfigurationName = Release; 274 | }; 275 | /* End XCConfigurationList section */ 276 | }; 277 | rootObject = 28C79A01220DC4CC0061DE82 /* Project object */; 278 | } 279 | -------------------------------------------------------------------------------- /src/windows/SliderWindows/SliderView.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (c) Microsoft Corporation. All rights reserved. 2 | // Licensed under the MIT License. 3 | 4 | #include "pch.h" 5 | 6 | #include "JSValueXaml.h" 7 | 8 | #include "SliderView.h" 9 | #include "SliderView.g.cpp" 10 | 11 | #include "winrt/Windows.UI.Xaml.Media.h" 12 | #include "winrt/Windows.UI.Xaml.Media.Imaging.h" 13 | #include "winrt/Windows.UI.Xaml.Input.h" 14 | 15 | namespace winrt { 16 | using namespace Microsoft::ReactNative; 17 | using namespace Windows::Foundation; 18 | using namespace Windows::UI; 19 | using namespace Windows::UI::Xaml::Media; 20 | using namespace Windows::UI::Xaml::Media::Imaging; 21 | } 22 | 23 | namespace winrt::SliderWindows::implementation { 24 | 25 | SliderView::SliderView(winrt::IReactContext const& reactContext) : m_reactContext(reactContext) { 26 | RegisterEvents(); 27 | } 28 | 29 | void SliderView::RegisterEvents() { 30 | //Set this so that Slider passes on Manipulation* events. 31 | this->ManipulationMode(xaml::Input::ManipulationModes::All); 32 | 33 | m_sliderValueChangedRevoker = this->ValueChanged(winrt::auto_revoke, 34 | [ref = get_weak()](auto const& sender, auto const& args) { 35 | if (auto self = ref.get()) { 36 | self->OnValueChangedHandler(sender, args); 37 | } 38 | }); 39 | 40 | m_sliderManipulationStartingRevoker = this->ManipulationStarting(winrt::auto_revoke, 41 | [ref = get_weak()](auto const& sender, auto const& args) { 42 | if (auto self = ref.get()) { 43 | self->OnManipulationStartingHandler(sender, args); 44 | } 45 | }); 46 | 47 | m_sliderManipulationCompletedRevoker = this->ManipulationCompleted(winrt::auto_revoke, 48 | [ref = get_weak()](auto const& sender, auto const& args) { 49 | if (auto self = ref.get()) { 50 | self->OnManipulationCompletedHandler(sender, args); 51 | } 52 | }); 53 | } 54 | 55 | void SliderView::UpdateProperties(winrt::IJSValueReader const& reader) { 56 | m_updating = true; 57 | 58 | bool updatedValue = false; 59 | bool updatedMaxValue = false; 60 | bool updatedMinValue = false; 61 | 62 | auto const& propertyMap = JSValueObject::ReadFrom(reader); 63 | 64 | for (auto const& pair : propertyMap) { 65 | auto const& propertyName = pair.first; 66 | auto const& propertyValue = pair.second; 67 | 68 | if (propertyName == "value") { 69 | if (propertyValue.IsNull()) { 70 | this->ClearValue(xaml::Controls::Primitives::RangeBase::ValueProperty()); 71 | } 72 | else { 73 | updatedValue = true; 74 | m_value = propertyValue.AsDouble(); 75 | } 76 | } 77 | else if (propertyName == "maximumValue") { 78 | if (propertyValue.IsNull()) { 79 | this->ClearValue(xaml::Controls::Primitives::RangeBase::MaximumProperty()); 80 | } 81 | else { 82 | updatedMaxValue = true; 83 | m_maxValue = propertyValue.AsDouble(); 84 | } 85 | } 86 | else if (propertyName == "minimumValue") { 87 | if (propertyValue.IsNull()) { 88 | this->ClearValue(xaml::Controls::Primitives::RangeBase::MinimumProperty()); 89 | } 90 | else { 91 | updatedMinValue = true; 92 | m_minValue = propertyValue.AsDouble(); 93 | } 94 | } 95 | else if (propertyName == "step") { 96 | if (propertyValue.IsNull()) { 97 | this->ClearValue(xaml::Controls::Slider::StepFrequencyProperty()); 98 | } 99 | else { 100 | auto&& step = CalculateStepFrequencyPercentageValue(propertyValue.AsDouble()); 101 | this->StepFrequency(step); 102 | } 103 | } 104 | else if (propertyName == "inverted") { 105 | if (propertyValue.IsNull()) { 106 | this->ClearValue(xaml::Controls::Slider::IsDirectionReversedProperty()); 107 | } 108 | else { 109 | this->IsDirectionReversed(propertyValue.AsBoolean()); 110 | } 111 | } 112 | else if (propertyName == "disabled") { 113 | if (propertyValue.IsNull()) { 114 | this->ClearValue(xaml::Controls::Control::IsEnabledProperty()); 115 | } 116 | else { 117 | this->IsEnabled(!propertyValue.AsBoolean()); 118 | } 119 | } 120 | else if (propertyName == "vertical") { 121 | if (propertyValue.IsNull()) { 122 | this->ClearValue(xaml::Controls::Slider::OrientationProperty()); 123 | } 124 | else { 125 | this->Orientation(propertyValue.AsBoolean() ? 126 | xaml::Controls::Orientation::Vertical : 127 | xaml::Controls::Orientation::Horizontal); 128 | } 129 | } 130 | else if (propertyName == "minimumTrackTintColor") { 131 | if (!propertyValue.IsNull()) { 132 | auto resDict = this->Resources(); 133 | 134 | resDict.Insert(winrt::box_value(L"SliderTrackValueFill"), propertyValue.To()); 135 | resDict.Insert(winrt::box_value(L"SliderTrackValueFillPointerOver"), propertyValue.To()); 136 | resDict.Insert(winrt::box_value(L"SliderTrackValueFillPressed"), propertyValue.To()); 137 | } 138 | } 139 | else if (propertyName == "maximumTrackTintColor") { 140 | if (!propertyValue.IsNull()) { 141 | auto resDict = this->Resources(); 142 | 143 | resDict.Insert(winrt::box_value(L"SliderTrackFill"), propertyValue.To()); 144 | resDict.Insert(winrt::box_value(L"SliderTrackFillPointerOver"), propertyValue.To()); 145 | resDict.Insert(winrt::box_value(L"SliderTrackFillPressed"), propertyValue.To()); 146 | } 147 | } 148 | else if (propertyName == "thumbTintColor") { 149 | if (!propertyValue.IsNull()) { 150 | auto resDict = this->Resources(); 151 | 152 | resDict.Insert(winrt::box_value(L"SliderThumbBackground"), propertyValue.To()); 153 | resDict.Insert(winrt::box_value(L"SliderThumbBackgroundPointerOver"), propertyValue.To()); 154 | resDict.Insert(winrt::box_value(L"SliderThumbBackgroundPressed"), propertyValue.To()); 155 | } 156 | } 157 | else if (propertyName == "thumbImage") { 158 | if (!propertyValue.IsNull()) { 159 | auto imgUriString = propertyValue.AsObject()["uri"].AsString(); 160 | BitmapImage bitmap = BitmapImage(Uri(to_hstring(imgUriString))); 161 | ImageBrush imgB = ImageBrush(); 162 | imgB.ImageSource(bitmap); 163 | 164 | auto resDict = this->Resources(); 165 | resDict.Insert(winrt::box_value(L"SliderThumbBackground"), imgB); 166 | resDict.Insert(winrt::box_value(L"SliderThumbBackgroundPointerOver"), imgB); 167 | resDict.Insert(winrt::box_value(L"SliderThumbBackgroundPressed"), imgB); 168 | } 169 | } 170 | } 171 | 172 | // This is to mitigate platform bugs related to the order of setting min/max values in certain XAML controls. 173 | if (updatedMaxValue) { 174 | this->Maximum(m_maxValue); 175 | } 176 | if (updatedMinValue) { 177 | this->Minimum(m_minValue); 178 | } 179 | if (updatedValue) { 180 | this->Value(m_value); 181 | } 182 | 183 | m_updating = false; 184 | } 185 | 186 | void SliderView::OnValueChangedHandler(winrt::IInspectable const& /*sender*/, 187 | xaml::Controls::Primitives::RangeBaseValueChangedEventArgs const& args){ 188 | 189 | if (!m_updating) { 190 | m_reactContext.DispatchEvent( 191 | *this, 192 | L"topChange", 193 | [&](winrt::Microsoft::ReactNative::IJSValueWriter const& eventDataWriter) noexcept { 194 | eventDataWriter.WriteObjectBegin(); 195 | { 196 | WriteProperty(eventDataWriter, L"value", args.NewValue()); 197 | } 198 | eventDataWriter.WriteObjectEnd(); 199 | }); 200 | } 201 | } 202 | 203 | void SliderView::OnManipulationStartingHandler(winrt::IInspectable const& sender, 204 | xaml::Input::ManipulationStartingRoutedEventArgs const& args) { 205 | if (!m_updating) { 206 | auto self = sender.try_as(); 207 | 208 | m_reactContext.DispatchEvent( 209 | *this, 210 | L"topSlidingStart", 211 | [&](winrt::Microsoft::ReactNative::IJSValueWriter const& eventDataWriter) noexcept { 212 | eventDataWriter.WriteObjectBegin(); 213 | { 214 | WriteProperty(eventDataWriter, L"value", self.Value()); 215 | } 216 | eventDataWriter.WriteObjectEnd(); 217 | }); 218 | } 219 | } 220 | 221 | void SliderView::OnManipulationCompletedHandler(winrt::IInspectable const& sender, 222 | xaml::Input::ManipulationCompletedRoutedEventArgs const& args) { 223 | if (!m_updating) { 224 | auto self = sender.try_as(); 225 | 226 | m_reactContext.DispatchEvent( 227 | *this, 228 | L"topSlidingComplete", 229 | [&](winrt::Microsoft::ReactNative::IJSValueWriter const& eventDataWriter) noexcept { 230 | eventDataWriter.WriteObjectBegin(); 231 | { 232 | WriteProperty(eventDataWriter, L"value", self.Value()); 233 | } 234 | eventDataWriter.WriteObjectEnd(); 235 | }); 236 | } 237 | } 238 | 239 | const double SliderView::CalculateStepFrequencyPercentageValue(const double& stepPropertyValue) const noexcept { 240 | if (stepPropertyValue != 0) { 241 | return stepPropertyValue; 242 | } 243 | else { 244 | return (m_maxValue - m_minValue) / 100.f; 245 | } 246 | } 247 | } 248 | -------------------------------------------------------------------------------- /example/windows/SliderTestWindows/SliderTestWindows.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | true 6 | true 7 | true 8 | {942a8514-0854-4f75-b43b-61e8ffc678cb} 9 | SliderTestWindows 10 | SliderTestWindows 11 | en-US 12 | 16.0 13 | true 14 | Windows Store 15 | 10.0 16 | 10.0.18362.0 17 | 10.0.16299.0 18 | SliderTestWindows_TemporaryKey.pfx 19 | 2B865F049A8EC254802CBE811120971BD5F2CDB5 20 | password 21 | 22 | 23 | 24 | 25 | Debug 26 | ARM 27 | 28 | 29 | Debug 30 | ARM64 31 | 32 | 33 | Debug 34 | Win32 35 | 36 | 37 | Debug 38 | x64 39 | 40 | 41 | Release 42 | ARM 43 | 44 | 45 | Release 46 | ARM64 47 | 48 | 49 | Release 50 | Win32 51 | 52 | 53 | Release 54 | x64 55 | 56 | 57 | 58 | Application 59 | Unicode 60 | 61 | 62 | true 63 | true 64 | 65 | 66 | false 67 | true 68 | false 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | Use 86 | pch.h 87 | $(IntDir)pch.pch 88 | Level4 89 | %(AdditionalOptions) /bigobj 90 | 4453;28204 91 | 92 | 93 | 94 | 95 | _DEBUG;%(PreprocessorDefinitions) 96 | 97 | 98 | 99 | 100 | NDEBUG;%(PreprocessorDefinitions) 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | App.xaml 109 | 110 | 111 | 112 | 113 | Designer 114 | 115 | 116 | 117 | 118 | Designer 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | Create 135 | 136 | 137 | App.xaml 138 | 139 | 140 | 141 | 142 | 143 | App.xaml 144 | 145 | 146 | 147 | 148 | 149 | 150 | false 151 | 152 | 153 | 154 | 155 | {685a83ae-36bc-4e9d-bdc6-417ebf168463} 156 | 157 | 158 | 159 | 160 | $([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), 'node_modules\react-native-windows\package.json'))\node_modules\react-native-windows\ 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | This project references targets in your node_modules\react-native-windows folder. The missing file is {0}. 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. 180 | 181 | 182 | 183 | 184 | 185 | --------------------------------------------------------------------------------