0.0.6 • Published 1 year ago

@optisolbusiness/react-native-survey-question v0.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@optisolbusiness/react-native-survey-question

@optisolbusiness/react-native-survey-question

Installation

npm install --save @optisolbusiness/react-native-survey-question @react-native-community/slider

If using iOS please remember to install cocoapods by running: npx pod-install

Usage

import { SurveyQuestion } from "@optisolbusiness/react-native-survey-question";

// ...

 <SurveyQuestion
        options={[
          {
            question: 'Which stage of career are you at?',
            type: 'singleSelectQuestion',
            user_options: [
              { questionOptions: 'question 2' },
              { questionOptions: 'question 3' },
            ],
          },
          {
            question: 'question one InputText',
            type: 'inputTextQuestion',
            user_options: [
              { textInputQuestionTitle: 'text one', textInputvalue: '',placeholder: '' },
              { textInputQuestionTitle: 'text two', textInputvalue: '',placeholder: ''},
            ],
          },
          {
            question: 'question name Button',
            type: 'multiSelectQuestion',
            user_options: [
              { questionOptions: 'question 2', unSelectedColor: 'transparent',
              selectedColor: 'green', selectedTextColor: 'white',unSelectedTextColor: 'red' },
              { questionOptions: 'question 5',  unSelectedColor: 'transparent',
              selectedColor: 'green', selectedTextColor: 'white',unSelectedTextColor: 'red' },
              { questionOptions: 'question 8', unSelectedColor: 'transparent',
              selectedColor: 'green', selectedTextColor: 'white',unSelectedTextColor: 'red' },
            ],
          },
          {
            question: 'question name slider',
            type: 'progressBarQuestion',
            user_options: [
              {
                title: 'test title -7',
                values: 70,
                min:20,
                max:50,
                minValue: '',
                maxValue: ''
              },
              {
               title: 'test title -9',
                values: 50,
                min:20,
                max:50,
                minValue: '',
                maxValue: ''
              },
            ],
          },
          {
            question: 'question name slider',
            type: 'progressBar_text_Question',
            user_options: [
              {
               title: 'test title -9',
                value: 50,
                min:20,
                max:50,
                minValue: '',
                maxValue: '',
                textInputValue: '',
                placeholder: '',
              },
            ],
          },
        ]}
        onAnswer={(ans) => sample(ans)}
        onAllResp={(allResp) => console.log("allResp--", allResp)}
        styleContiner={styles.surveyBackground}
      />

How to pass type value and it's usage

type: 'singleSelectQuestion'

      options={[
          {
          question: '',
          type: 'singleSelectQuestion',
          user_options: [
              { questionOptions: 'question 1' },
              { questionOptions: 'question 2' },
              { questionOptions: 'question 3' },
            ],
          }
      ]}

type: 'inputTextQuestion'

      options={[
          {
          question: '',
          type: 'inputTextQuestion',
          user_options: [
              { textInputQuestionTitle: 'text one', textInputvalue: '', placeholder: '' },
              { textInputQuestionTitle: 'text two', textInputvalue: '' , placeholder: ''},
              { textInputQuestionTitle: 'text one', textInputvalue: '', placeholder: '' },
            ],
          }
      ]}

type: 'multiSelectQuestion'

      options={[
          {
          question: '',
          type: 'multiSelectQuestion',
          user_options: [
               { questionTitle: 'question 2', unSelectedColor: 'transparent',
                 selectedColor: 'green',selectedTextColor: 'white',unSelectedTextColor: 'red'
              },
            ],
          }
      ]}

type: 'progressBarQuestion'

      options={[
          {
          question: '',
          type: 'progressBarQuestion',
          user_options: [
               {
                title: 'test title -7',
                values: 70,
                min: 20,
                max: 50,
                minValue: '',
                maxValue: ''
              },
            ],
             }
      ]}

type: 'progressBar_text_Question'

         options={[
          {
          question: '',
          type: 'progressBar_text_Question',
          user_options: [
              {
                progressBarTitle: 'test title',
                value: 80,
                textInputValue: '',
                min: 20,
                max: 50,
                minValue: '',
                maxValue: '',
                placeholder: '',
                textInputTitle: ''
              },
            ],
             }
      ]}

Detailed description of props usage mentioned in table below

Props and Methods

PropTypeDescription
progressHeaderMainContainerStyleStyleOptional. Style of Progress Bar Container
progressHeaderSubContianerStyleStyleOptional. Style of Progress Bar
onProgressColorColorMandatory. Current Progress Bar color E.g: onProgressColor={'green'}
nextProgressColorColorMandatory. Next Progress bar color E.g: nextProgressColor={'blue'}
previousProgressColorColorMandatory. Previous Progress bar color E.g: previousProgressColor={'red'}
buttonMainContainerStyleStyleOptional. Previous and Next Button Main Container Style
buttonContainerStyleStyleOptional. Previous and Next Button Styling
buttonTextStyleStyleOptional. Previous and Next Button Text Styling
previousTextStringOptional. Previous text prop, default: Previous
nextTextStringOptional. Next text prop, default: Next
optionsArray of ObjectsMandatory. Need to pass question ,type, user_options
questionStringMandatory. Question heading
typeStringMandatory. 'SingleSelectQuestion' or 'inputTextQuestion' or 'multiSelectQuestion' or 'PrograssBarQuestion' or 'PrograssBar_text_Question'
user_optionsArray of ObjectsMandatory. based on type value user_options will differ,user_options is mandatory for all types
inputTextOuterContainerStyleStyleOptional. Container Styling of text input and title
textInputTitleStyleStyleOptional. Styling of text input title
textInputStyleStyleOptional. TextInput style
progressbarContainerStyleStyleOptional. progressBar Container Style
progressTitleStyleStyleOptional. progressBar Title Style
sliderStyleStyleOptional. slider Style
minimumTrackTintColorStyleOptional. The color used for the track to the left of the button. Overrides the default blue gradient image on iOS.
maximumTrackTintColorStyleOptional. The color used for the track to the right of the button. Overrides the default gray gradient image on iOS.
thumbTintColorStyleOptional. Color of the foreground switch grip.
minMaxStyleContainerStyleOptional. minValue, maxValue Text Container Style
onAnswerFunctionMnadatory. for individual screen response
onAllRespFunctionMandatory. for complete screens response

type: 'singleSelectQuestion' props

PropTypeDescription
questionOptionsStringMandatory. Questions to conduct survey in singleSelectQuestion type
optionStyleStyleOptional. unSelected question styling
selectedOptionStyleStyleOptional. selected question styling
optionTextStyleStyleOptional. unSelected question text style
selectedOptionTextStyleStyleOptional. selected question text style

type: 'inputTextQuestion' props

PropTypeDescription
textInputQuestionTitleStringOptional. Title for text input
textInputvalueStringOptional. value to show for the text input
placeholderStringOptional. placeholder value for text input

type: 'multiSelectQuestion' props

PropTypeDescription
questionTitleStringMandatory. Questions Title
selectedColorColorMandatory. selected question color
unSelectedColorColorMandatory. unSelected question color
selectedTextColorColorMandatory. selected question text color
unSelectedTextColorColorMandatory. unSelected question text color
buttonStylePropsStyleOptional. question outer style
buttonOptionTextStyleStyleOptional. question text style

type: 'progressBarQuestion' props

PropTypeDescription
titleStringOptional. progress Title
valuesStringMandatory. to show progress value
minValuenumberOptional. to show minvalue
maxValuenumberOptional. to show maxvalue
minnumberOptional. Initial minimum value of the slider. Default value is 0.
maxnumberOptional. Initial maximum value of the slider. Default value is 1.

type: 'progressBar_text_Question' props

PropTypeDescription
progressBarTitleStringOptional. progress Title
valueStringMandatory. to show progress value
minValuenumberOptional. to show minvalue
maxValuenumberOptional. to show maxvalue
minnumberOptional. Initial minimum value of the slider. Default value is 0.
maxnumberOptional. Initial maximum value of the slider. Default value is 1.
textInputTitleStringOptional. Title for text input
textInputValueStringOptional. value to show for the text input
placeholderStringOptional. placeholder value for text input

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago