Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-wheel

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-wheel

android wheel view for react-native

  • 1.0.5
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

react-native-wheel

the android wheel view for react-native component

Installation and How to use

Step 1 - NPM Install
npm install --save react-native-wheel
Step 2 - Update Gradle Settings
// file: android/settings.gradle
...

include ':reactwheelview', ':app' 
project(':reactwheelview').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-wheel')
 // if there are more library
 // include ':app' , ':libraryone' , ':librarytwo' , 'more...'
 // project(':libraryonename').projectDir = new File(rootProject.projectDir, '../node_modules/libraryonemodule')
 // project(':librarytwoname').projectDir = new File(rootProject.projectDir, '../node_modules/librarytwomodule')
 // more..
Step 3 - Update app Gradle Build
// file: android/app/build.gradle
...

dependencies {
    ...
    compile project(':reactwheelview')
}
Step 4 - Register React Package
...
import com.heng.wheel.WheelPackage;

public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler {

    private ReactInstanceManager mReactInstanceManager;
    private ReactRootView mReactRootView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        mReactRootView = new ReactRootView(this);
        mReactInstanceManager = ReactInstanceManager.builder()
                .setApplication(getApplication())
                .setBundleAssetName("index.android.bundle")
                .setJSMainModuleName("index.android")
                .addPackage(new MainReactPackage())
                .addPackage(new WheelPackage()) // register wheel package
                .setUseDeveloperSupport(BuildConfig.DEBUG)
                .setInitialLifecycleState(LifecycleState.RESUMED)
                .build();
        mReactRootView.startReactApplication(mReactInstanceManager, "AwesomeProject", null);
        setContentView(mReactRootView);
    }
...

Step 5 - Require and use in Javascript
// file: index.android.js
var React = require('react-native');
var WheelView = require('react-native-wheel');

var { AppRegistry,StyleSheet,Text,View,ToastAndroid } = React;

var wheelData = ['one','two','three','four','five','six','seven','eight','nine','ten'];

var AwesomeProject = React.createClass({

    onItemChange(index){
      ToastAndroid.show('select item : ' + wheelData[index],ToastAndroid.SHORT);
    },
    render: function() {
        return (
            <View style={styles.container}>
               <WheelView
                  style={styles.wheelview}
                  onItemChange={this.onItemChange}
                  values={wheelData}
                  isLoop={true}
                  selectedIndex={0}
                  textSize={17}
                  />
            </View>
        );
    }
});


var styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  wheelview: {
    width: 120,
    height: 300
  },
});

AppRegistry.registerComponent('AwesomeProject', () => AwesomeProject);

Notes

  • if has error , please check build.gradle config
  • you can modify this library (react-native-wheel/build.gradle)

android {
    compileSdkVersion 23  //@
    buildToolsVersion "23.0.1"  //@

    defaultConfig {
        minSdkVersion 16 
        targetSdkVersion 23  //@
    }
}

dependencies {
    compile 'com.facebook.react:react-native:0.15.+'  //@
}

// modify the above @ value not higher than you project value

##Reference https://github.com/weidongjian/androidWheelView

Run Renderings

Keywords

FAQs

Package last updated on 09 Dec 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc