1.1.5 • Published 1 year ago

rn-components_dtc v1.1.5

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

React-Native-Component_DTC

This lib support some of component basic for project. (build for DTC's projects)

Installation

Step 1: Before use this lib, you need config native "react-native-vector-icons" following this link: https://github.com/oblador/react-native-vector-icons

Step 2: To install lib this project run

  npm i rn-components_dtc

Step 3:

cd ios & pod install

If you are having trouble with iOS, try to reinstall the dependencies by running:

    1. cd ios
    2. bundle install
    3. bundle exec pod install

Usage/Examples

const App = () => {
  useEffect(() => {
    console.log(RNModuleTemplateModule)
  })
  const isDarkMode = useColorScheme() === 'dark'
  const backgroundStyle = {
    backgroundColor: isDarkMode ? Colors.darker : Colors.lighter,
  }

  const [isVisible, setisVisible] = useState<boolean>(false)
  const [checked, setChecked] = useState<boolean>(false)

  const Test = () => {
    return <Text>test right custom children</Text>
  }

  const data = [
    {
      key: 1,
      text: 'Option A',
    },
    {
      key: 2,
      text: 'Option B',
    },
    {
      key: 3,
      text: 'Option C',
    },
  ]

  const onRadioButtonPress = (itemIdx: any) => {
    console.log('Clicked', itemIdx)
  }

  return (
    <SafeAreaView style={backgroundStyle}>
      <StatusBar
        barStyle={isDarkMode ? 'light-content' : 'dark-content'}
        backgroundColor={backgroundStyle.backgroundColor}
      />
      <ScrollView
        contentInsetAdjustmentBehavior='automatic'
        style={backgroundStyle}
      >
        <Header />
        <View
          style={{
            backgroundColor: isDarkMode ? Colors.black : Colors.white,
          }}
        >
          <View
            style={{
              flex: 1,
              marginTop: 30,
              marginHorizontal: 16,
            }}
          >
            <Button
              text='test'
              onPressBtn={() => {}}
              btnStyle={{ marginVertical: 10, padding: 10 }}
            />
            <TextInputComponent
              containerViewInputStyle={{ marginBottom: 10 }}
              textInputStyle={{ borderWidth: 2 }}
              errorText='loi roi kia lam lai di'
            />
            <ImageCpn
              typeVectorIcon='AntDesign'
              iconName='plus'
              sizeIcon={50}
              colorIcon='red'
              imgStyle={{ marginBottom: 10, borderWidth: 1, borderRadius: 6 }}
              onPressItem={() => {
                console.log('pressed item')
              }}
            />
            <View
              style={{ borderWidth: 2, borderColor: 'gray', borderRadius: 6 }}
            >
              <CollapseView
                title={'Tùy chọn tìm kiếm'}
                titleStyle={{ color: 'blue' }}
                icon={
                  <Icons.AntDesign
                    name='infocirlceo'
                    size={20}
                    color={'black'}
                  />
                }
                customViewChildStyle={{
                  borderTopWidth: 1,
                  borderColor: 'gray',
                }}
                customContainerStyle={{
                  borderTopWidth: 1,
                }}
              >
                <Text>test</Text>
                <Text>test1</Text>
              </CollapseView>
            </View>
            <ImageCpn typeVectorIcon='AntDesign' iconName='minus' />
            <CollapseViewV2 />
            <RadioComponent
              titleLeft={'Test radio button'}
              customStyleContainer={{ marginTop: 10 }}
              value={null}
              onChangeSwitch={(bool) => {
                console.log('changed status')
              }}
            />
          </View>
          <Button
            text='Open modal'
            onPressBtn={() => {
              setisVisible(!isVisible)
            }}
            btnStyle={{ margin: 10, padding: 10 }}
          />
          <Checkbox
            leftText='left'
            checked={checked}
            onChecked={setChecked}
            childrenRight={<Test />}
          />
          <MultiRadioButton
            isSwapTextToLeft={false}
            values={data}
            onPress={onRadioButtonPress}
          />
        
        </View>
        <ModalComponent
          isVisible={isVisible}
          isShowButtonAccpet
          hasCancelButton
          titlePopup={'Test modal'}
          onPressBtnAccept={() => setisVisible(false)}
          customStyleBtnAccept={{ backgroundColor: 'pink' }}
        />
      </ScrollView>
    </SafeAreaView>
  )
}

export default App

Components

I. Button

PropsDescription
textText in button
activeOpacityOpacity when user click button (from 0 to 1)
disabledDisable button
childrenInstead of Text <React.ReactNode>
textStyleText Style <StyleProp>
btnStyleStyle of button <StyleProp>
onPressBtnon Press button
numberOfLinesnumber of line of Text in button
adjustsFontSizeToFitadjust font size
allowFontScalingauto scale font

II. TextInput

PropsDescription
valuevalue input text
placeholderplace holder text ( default is '...Nhập giá trị' )
placeholderStyleStyle for place holder <StyleProp>
onChangeTextOn change value of Text <(value: string) => void>
onFocusWhen user focus on input <(e: NativeSyntheticEvent) => void>
onBlurCallback that is called when the text input is blurred <(e: NativeSyntheticEvent) => void>
onEndEdittingWhen user end edit text input <(e: NativeSyntheticEvent) => void>
childrenLeftWhen want to custom left children React Node of input text <React.ReactNode>
childrenLeftStyleContainer Style of children left <StyleProp>
childrenRightWhen want to custom right children React Node of input text <React.ReactNode>
childrenRightStyleContainer Style of children right <StyleProp>
textInputStyleContainer Style of textinput <StyleProp>
containerViewInputStyleContainer Style of all children <StyleProp>
errorTextShow error text at bottom of text input
errorTextStyleError Text Style <StyleProp>
editableText input can edit ( default is true)

III. ImageCpn

PropsDescription
imageUrlStatic url of image
imageUrl of image with format require('...') type
imgStyleStyle for image
iconNameName of vector icon, match with typeVectorIcon
typeVectorIconType of vector icons ( AntDesign, Feather, Entypo, EvilIcons, Ionicons, FontAwesome,... )
colorIconColor of Icon
sizeIconSize of icon
resizeModeResize mode of image ( contain, center, cover, stretch, repeat )
onPressItemOn press image or icon

IV. Modal Component

PropsDescription
isVisibleThe visible prop determines whether your modal is visible.
setModalVisibleFunction like onRequestClose modal
onPressBtnAcceptOn press accept button to do some thing
imageImage like avatar of modal
titlePopupTitle of modal
subTitlePopupSubtitle of modal
titleBtnAcceptTitle of button accept
titleBtnCancelTitle of button cancel
hasCheckBoxBoolean check box in modal
isCheckedStatus of checkbox
setCheckedCheckboxFunction change status checkbox
titleWithCheckBoxTitle of checkbox with horizontal
hasCancelButtonBoolean check cancel button
customStyleBtnAcceptStyle container of button accept
customStyleBtnCancelStyle container of button cancel
isDisableBtnAcceptDisable button accept
colorCheckboxColor of check box, default is blue
sizeCheckboxSize of check box, default is 16
isShowButtonAccpetBoolean check has button accept or not, default is true

V. Radio Component

PropsDescription
valueValue of radio button ( can be boolean value or any value following each projects ).
titleLeftTitle of Radio button component
onChangeSwitchFunction change status of Radio button
customStyleContainerCustom Style container of radio button
customStyleTextLeftCustom text style
trackColorFalseColor when radio button is off
trackColorTrueColor when radio button is on
thumbColorColor of thumb

VI. Collapse View

PropsDescription
disabledDisable collapse view, default is false
titleTitle of collapse view
titleStyleStyle for title
childrenCustom Children ( Contents ) when view expanded
iconIcon at head ( left ) of title
colorsIconArray color type 'red', 'blue'. When collapse is red, expand is blue
sizeIconSize of icon
customViewChildStyleCustom container style of children
hasCountBoolean check count ( count is on the right of title)
countCount
isShowRightContentBoolean check right content or no. (on the right of title with flex - end )
txtFollowingCountText following on the count ( describe for count like Times, Searchs, ... )
isShowButtonBoolean check button with dependency must has isShowRightContent. ( like minus icon or plus icon when user collapse or expand view )
txtBtnText button if right content is Text, dependency is isShowRightContent
customBtnRightStyleCustom Style for right content
onPressBtnAction of button right content
customContainerStyleCustom container style for collapse view
openDefaultBoolean check default is collapse or expand
isSwapChildSwap children will be show on top or button of collapse
isSpecialChildBoolean check custom children special has or no
titleSpecialTitle of special child
subTitleSpecialSubtitle of special child
valueSpecialValue Special
hasHeaderBoolean check has header special or not ( when use expand view )
titleHeaderSpecialTitle for header special
styleTitleHeaderSpecialStyle for title header special
colorIconCloseColor of icon close ( when use expand view )
colorActiveCollapseColor when view was expand, Exp: default color is white, when view expand, color change to different color
colorTextActiveCollapseColor of text when collapse or expand ( like colorActiveCollapse )

Note: Devs's DTC following design on Figma "Test firm search APP".

VII. Collapse View V2 (Collapse view text )

PropsDescription
lineDefaultLine show default after use collapse view
textDataData type Text
textMoreText show more
textCollapseText collapse
iconsArray of icon replace for textMore and textCollapse. Exp: <Icons.AntDesign name='caretdown' color={'black'} size={14} />, <Icons.AntDesign name='caretup' color={'black'} size={14} />,
1.1.5

1 year ago

1.1.4

1 year ago

1.1.3

1 year ago

1.1.2

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago