1.1.0 • Published 6 years ago

rn-inka-element v1.1.0

Weekly downloads
11
License
MIT
Repository
-
Last release
6 years ago

rn-inka-element

A React Native library with some bottom sheet (using modal)

npm versionnpm

Getting started

$ npm install rn-inka-element --save

Require

You need install moment for ModalDateTime

$ npm install moment --save

You need install react-native-vector-icons for ModalNumberPad

$ npm install react-native-vector-icons --save

Mostly automatic installation

$ react-native link rn-inka-element

Usage

ModalNumberPad

import { ModalNumberPad } from 'rn-inka-element';

// Use ModalNumberPad
<ModalNumberPad
  onRequestClose={() => modal_number_visible = false}
  onConfirm={value => {
    console.log(value);
    modal_number_visible = false;
  }}
  onCancel={() => modal_number_visible = false}
  lang={{
    title_thin: 'Choose ',
    title_bold: '"Product Price"',
    button_ok: 'OK',
    button_cancel: 'Cancel',
  }}
  valueInit={1104}
  visible={modal_number_visible} />

Props:

PropSupportDescription
onValueChangeiOS/AndroidCallback function to receive new value of number pad. You need change your store value here to update value to number pad
valueInitiOS/AndroidDefault value will display on pad
onConfirmiOS/AndroidCallback function when user press OK, note that if you def this props, a default button OK will render, callback param will be the number you need

ModalDateTime

import { ModalDateTime } from 'rn-inka-element';

// Use ModalDateTime
<ModalDateTime
  onRequestClose={() => modal_datetime_visible = false}
  visible={modal_datetime_visible}
  dateInit='2019-12-23 12:30'
  onCancel={() => modal_datetime_visible = false}
  onConfirm={(date) => {
    // date type is moment
    console.log(date.format())
    modal_datetime_visible = false;
  }}
  />

Props:

PropSupportDescription
dateInitiOS/AndroidDefault value will display on pad
onConfirmiOS/AndroidCallback function when user press OK, note that if you def this props, a default button OK will render, callback param will be the moment you choosed

ModalBottomSheet

Other Modal is base on this component

import { ModalBottomSheet } from 'rn-inka-element';

// Use ModalDateTime
<ModalBottomSheet
  onRequestClose={() => modal_option_visible = false}
  onCancel={() => modal_option_visible = false}
  onConfirm={() => modal_option_visible = false}
  lang={{
    title_thin: 'Choose ',
    title_bold: '"Product Price"',
    button_ok: 'OK',
    button_cancel: 'Cancel',
  }}
  enableScroll={false}
  renderContent={() => (
    <View style={styles.modal_container}>
      // Render your content here
    </View>
  )}
  visible={modal_option_visible} />

Props:

PropSupportDescription
onConfirmiOS/AndroidOn OK button press, note that if you def this props, a default button OK will render
onCanceliOS/AndroidOn Cancel button press, note that if you def this props, a default button Cancel will render
onSwipeDowniOSWork on iOS only, handle event when use swipe modal down. This event use over scroll of scroll view
onSwipeUpiOSWork on iOS only, handle event when use swipe modal up. This event use over scroll of scroll view
visibleiOS/AndroidImportant prop to control modal visible
onRequestCloseiOS/AndroidThis function use help this modal can close when click cancel, ok, outside
renderHeaderiOS/AndroidOverride render header of BottomSheet
enableScrolliOS/AndroidEnable scroll content if higher than screen
renderContentiOS/AndroidRender content of modal, in case enableScroll and scrollType is not 'ScrollView' renderContent will be disable
enableInputiOS/AndroidShow input below modal header, usually use to search data on List
onChangeTextiOS/AndroidCallback when input text change, use for search & filter function
scrollTypeiOS/AndroidType of content scrollview (when enableScroll = true), maybe FlatList, SectionList or ScrollView
scrollPropsiOS/AndroidCustom props of ScrollView/FlatList..., you may use this to set data for List and all its props (include header, items)
langiOS/AndroidUse this prop for multiple language

ModalBottomSheet with FlatList and Search input

You can use FlatList inside Modal very easy, or add an input on top of modal for seach function

import { ModalBottomSheet } from 'rn-inka-element';

<ModalBottomSheet
  onRequestClose={() => modal_option_visible = false}
  onCancel={() => modal_option_visible = false}
  onConfirm={() => modal_option_visible = false}
  lang={{
    title_thin: 'Choose ',
    title_bold: '"Product Price"',
    button_ok: 'OK',
    button_cancel: 'Cancel',
  }}
  enableScroll={true}
  scrollType='FlatList'
  enableInput={true}
  onChangeText={text => console.log(text)}
  scrollProps={{
    data: options,
    keyExtractor: (item, index) => index.toString(),
    renderItem: (rowData, index) => {
      const option = rowData.item;

      return (
        // render item of list
        )
    }
  }}
  visible={modal_option_visible} />
1.1.0

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago