Giter VIP home page Giter VIP logo

react-native-multiple-choice's Introduction

react-native-multiple-choice

A cross-platform (iOS / Android) single and multiple-choice React Native component.

Install

npm i react-native-multiple-choice --save

Usage

Here is an overview of the component usage.

<MultipleChoice
    options={[
    'Lorem ipsum dolor sit',
    'Lorem ipsum',
    'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.',
    'Lorem ipsum dolor sit amet, consetetur',
    'Lorem ipsum dolor'
    ]}
    selectedOptions={['Lorem ipsum']}
    maxSelectedOptions={2}
    onSelection={(option)=>alert(option + ' was selected!')}
/>

Props

  • style - {} custom style of the list
  • optionStyle - {} custom style of the option element
  • options - [] required array of options
  • selectedOptions - [] optional array of initially selected options
  • maxSelectedOptions - int optional maximum number of selectable options
  • onSelection - function(option){} option selection callback
  • renderIndicator - function(option) should return a selected/deselected indicator node, default: check mark image
  • renderSeparator - function(option) should return a separator node that is displayed between the options, default: gray line
  • renderText - function(option) should return a text node, default: text node
  • renderRow - function(option) should return a option view
  • disabled - bool if set to true component is disabled and can't be interacted with

Screenshot

example

react-native-multiple-choice's People

Contributors

d-a-n avatar yannickoo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

react-native-multiple-choice's Issues

Change renderIndicator

How can I change the renderIndicator ?
Maybe is something super easy but I can't make it work.

List invisible untill scrolling

Image of invisible
Attached screenshot with inspector.
The tab view is react-native-tab-view by satya164:
https://github.com/react-native-community/react-native-tab-view

When starting to scroll, the list appears as usual.
RN 0.29.2.

Tried changing ScrollView to View, same behavior.

code:

            <View>
                <ScrollView>
                    <MultipleChoice
                        ref="Subjects"
                        options={this.state.subjects}
                        selectedOptions={this.state.checked}
                        onSelection={(option)=>console.log(option + ' was selected!')}
                    />
                </ScrollView>
            </View>

Update: tried also to add contentInset and automaticallyAdjustContentInsets to ListView, didn't seem to work.

Android version is having scrolling issue if fixed height is provided for multiple choice

Hi,

I have a screen in which i have other components and also react-native-multiple-choice i have given fixed height as i don't want it to increase the screen height all wrapped in scrollview. The screen works perfectly on ios and i am able to scroll whole screen as well as the react-native-multiple-choice but same code doesn't work on android.

Following is the code please check and let me know if i am doing anything wrong or missing anything:

<ScrollView
      showsVerticalScrollIndicator={false}
      ref="scroll" >
        <TouchableWithoutFeedback onPress={dismissKeyboard}>
          <View>
            <View style={[ComponentStyles.componentMargins, ComponentStyles.topMargin]}>
              <Text style={[ComponentStyles.headerText]}>Please tell us about your music teaching experience. {'\n'}How many years have you been teaching for ?</Text>
              <View>
                <View style={[ComponentStyles.marginSmallTopBottom,{flexDirection:'row', alignItems:'center', justifyContent:'space-between',}]}>
    		<Text style={[ComponentStyles.headerText]}>
    		Years
    		</Text>
    		<View>
    		{expYearsComponent}
    		</View>
    		</View>
              </View>
            </View>
            <Separator/>
            <View style={[ComponentStyles.componentMargins, ComponentStyles.topMargin]}>
              <Text style={[ComponentStyles.headerText]}>Have you worked at any educational Institute?</Text>
              <View style={[ComponentStyles.topMargin, ComponentStyles.bottomMargin,{flexDirection:'row'}]}>
                <View style={[{flexDirection: 'row', alignItems: 'center',}]}>
                  <MKRadioButton
                    checked={this.state.workedAtInstitute}
                    rippleDuration={100}
                    group={this.taughtAtInstituteRadioGroup}
                    onCheckedChange={this.onRadioCheckedChange.bind(this) }/>
                  <Text style={[ComponentStyles.contentText]}>Yes</Text>
                </View>
                <View style={[ComponentStyles.marginSmallRightLeft,{flexDirection: 'row', alignItems: 'center',}]}>
                  <MKRadioButton
                  checked = {!this.state.workedAtInstitute}
                  rippleDuration={100}
                  group={this.taughtAtInstituteRadioGroup}/>
                  <Text style={[ComponentStyles.contentText]}>No</Text>
                </View>
              </View>
            </View>
            <Separator/>
            <View style={[ComponentStyles.componentMargins,ComponentStyles.topMargin, ComponentStyles.bottomMargin]}>
              <Text style={[ComponentStyles.headerText]}>In what languages can you teach ?</Text>              
                <MultipleChoice
                  style={[{flex:1, height:300}]}
                  options={languagesList}
                  selectedOptions={this.state.languages}
                  maxSelectedOptions={0}
                  onSelection={this.onLanguageSelection.bind(this) }
                  />             
            </View>
            <Separator/>

            <View style={[
              ComponentStyles.componentMargin,
              ComponentStyles.marginLargeTopBottom,
              {flexDirection: 'row', justifyContent: 'center',}]}>
              <View style={[{marginRight:8}]}>
                {cancelButton}
              </View>
              <View>
                {saveButton}
              </View>
            </View>
            <Spinner overlayColor="rgba(255,255,255, 0.45)" color="#ED1C24" visible={this.props.spinnerVisibilityObject.spinnerVisible && this.props.spinnerVisibilityObject.spinnerType === SpinnerTypes.SAVE_TEACHER_PREFERENCES}/>
          </View>
        </TouchableWithoutFeedback>

      </ScrollView>

set state on selection

Hi Guys, when i setState on selection it works properly but the check images don't show anymore. can someone assist me with this please?
onSelection={ (option) => this.setState(option)}

use two multiple-choice in one page

when use two multiple-choice in one page, one is setted to maxSelectedOptions=1 and other is setted to maxSelectedOptions =5 ,then the two multiple-choice both have maxSelectedOptions =5 actions , is there some setting issues?

Not supported in 0.61.5 react native version as List view is deprecated.

Invariant Violation: ListView has been removed from React Native. See https://fb.me/nolistview for more information or use deprecated-react-native-listview.

This error is located at:
in MultipleChoice (at FeatureDevelopmentDetails.js:780)
in RCTView (at FeatureDevelopmentDetails.js:777)
in RCTView (at FeatureDevelopmentDetails.js:642)
in RCTView (at FeatureDevelopmentDetails.js:638)
in RCTScrollContentView (at ScrollView.js:1038)
in RCTScrollView (at ScrollView.js:1178)
in ScrollView (at FeatureDevelopmentDetails.js:636)
in RCTView (at FeatureDevelopmentDetails.js:613)
in FeatureDevelopmentDetails (created by SceneView)
in SceneView (at StackViewLayout.js:795)
in RCTView (at createAnimatedComponent.js:151)
in AnimatedComponent (at StackViewCard.js:69)
in RCTView (at createAnimatedComponent.js:151)
in AnimatedComponent (at screens.native.js:59)
in Screen (at StackViewCard.js:57)
in Card (at createPointerEventsContainer.js:27)
in Container (at StackViewLayout.js:860)
in RCTView (at screens.native.js:83)
in ScreenContainer (at StackViewLayout.js:311)
in RCTView (at createAnimatedComponent.js:151)
in AnimatedComponent (at StackViewLayout.js:307)
in PanGestureHandler (at StackViewLayout.js:300)
in StackViewLayout (at withOrientation.js:30)
in withOrientation (at StackView.js:79)
in RCTView (at Transitioner.js:215)
in Transitioner (at StackView.js:22)
in StackView (created by Navigator)
in Navigator (at createKeyboardAwareNavigator.js:12)
in KeyboardAwareNavigator (at createAppContainer.js:388)
in NavigationContainer (at ReactComponents/index.ios.js:30)
in MyApp (at renderApplication.js:40)
in RCTView (at AppContainer.js:101)
in RCTView (at AppContainer.js:119)
in AppContainer (at renderApplication.js:39)

Object.defineProperty$argument_2.get
react-native-implementation.js:359:8
MultipleChoice#constructor
index.js:43:19
renderRoot
[native code]:0
runRootCallback
[native code]:0
unstable_runWithPriority
scheduler.development.js:643:23
Component.prototype.setState
react.development.js:325:31
componentDidMount
FeatureDevelopmentDetails.js:245:21
tryCatch
runtime.js:45:44
invoke
runtime.js:271:30
tryCatch
runtime.js:45:44
invoke
runtime.js:135:28
Promise.resolve.then$argument_0
runtime.js:145:19
tryCallOne
core.js:37:14
setImmediate$argument_0
core.js:123:25
_callTimer
JSTimers.js:146:14
_callImmediatesPass
JSTimers.js:194:17
callImmediates
JSTimers.js:458:30
callImmediates
[native code]:0
flushedQueue
[native code]:0
invokeCallbackAndReturnFlushedQueue
[native code]:0
Can you please upgrade this package by using Flatlist please?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.