0.1.1 • Published 4 years ago

react-native-shbib-ui v0.1.1

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

Table of Contents

1. Getting Started:

Installation

Install react-native-shbib-ui:

npm install react-native-shbib-ui --save

or

yarn add react-native-shbib-ui

2. Usage:

App.js

import {Button} from 'react-native-shbib-ui';

<Button />;

3. Components supported:

Avatar

Demo

App.js

import React from 'react';
import {Avatar} from 'react-native-shbib-ui';
import {View} from 'react-native';
export default class AvatarExample extends React.Component {
  render() {
    return (
      <View style={styles.root}>
        <Avatar
          containerStyle={styles.avatarContainer}
          title="AS"
          titleSize={50}
        />
        <Avatar
          containerStyle={styles.avatarContainer}
          title="AS"
          titleColor="orange"
          source={require('./src/Assets/Images/avatar1.jpg')}
        />
        <Avatar
          containerStyle={styles.avatarContainer}
          source={require('./src/Assets/Images/avatar2.jpg')}
          avatarSize={150}
        />
      </View>
    );
  }
}
const styles = {
  root: {
    flex: 1,
    justifyContent: 'center',
  },
  avatarContainer: {
    marginTop: 10,
  },
};

Props

Prop nameDescriptionTypeDefault value
containerStyleContainer style for componentobject-
avatarStyleDivider colorobject-
titleStyleTitle styleobject-
sourceImage sourceimageSource-
titleAvatar titlestring-
avatarSizeBadge valuenumber-
titleSizeBadge sizenumber-
titleColorValue font sizestring-

Tab

Demo

App.js

import React from 'react';
import {Tab} from 'react-native-shbib-ui';
import {View, TouchableOpacity, Text} from 'react-native';
export default class TabExample extends React.Component {
  render() {
    return (
      <Tab
        scrollEnabled={false}
        bounces={false}
        horizontal
        containterStyle={styles.tabContainer}
        renderTabActive={(item, setActiveTab) => (
          <TouchableOpacity onPress={setActiveTab}>
            <View style={styles.tabActive}>
              <Text style={styles.textActive}>{item.title}</Text>
            </View>
          </TouchableOpacity>
        )}
        renderTabNotActive={(item, setActiveTab) => (
          <TouchableOpacity onPress={setActiveTab}>
            <View style={styles.tabNotActive}>
              <Text style={styles.textNotActive}>{item.title}</Text>
            </View>
          </TouchableOpacity>
        )}
        items={[
          {
            title: 'Tab1',
            content: (
              <View style={styles.text}>
                <Text style={styles.textHint}>First Tab</Text>
              </View>
            ),
          },
          {
            title: 'Tab2',
            content: (
              <View style={styles.text}>
                <Text style={styles.textHint}>Second Tab</Text>
              </View>
            ),
          },
          {
            title: 'Tab3',
            content: (
              <View style={styles.text}>
                <Text style={styles.textHint}>Third Tab</Text>
              </View>
            ),
          },
        ]}
      />
    );
  }
}

const styles = {
  tabContainer: {
    marginTop: 50,
  },
  tabActive: {
    alignItems: 'center',
    justifyContent: 'center',
    borderBottomWidth: 4,
    borderBottomColor: 'blue',
    paddingHorizontal: width * 0.1,
    paddingVertical: 20,
  },
  tabNotActive: {
    alignItems: 'center',
    justifyContent: 'center',
    borderBottomWidth: 4,
    borderBottomColor: 'transparent',
    paddingHorizontal: width * 0.1,
    paddingVertical: 20,
  },
  textActive: {
    fontSize: 18,
    color: 'black',
    textAlign: 'center',
    fontWeight: '800',
  },
  textNotActive: {
    fontSize: 18,
    color: 'black',
    textAlign: 'center',
    fontWeight: '800',
    color: 'grey',
  },
  text: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
  textHint: {
    fontSize: 25,
  },
};

Props

Prop nameDescriptionTypeDefault value
containerStyleContainer style for componentobject-
itemsTabs renderarray-
renderTabActiveComponent render active tabfunction-
renderTabNotActiveComponent render not active tabfunction-
horizontalRenders items horizontallyboolean-
scrollEnabledboolean-
bouncesboolean-

Swiper

Demo

App.js

import React from 'react';
import {View, Image} from 'react-native';
import {Swiper} from 'react-native-shbib-ui';
export default class SwiperExample extends React.Component {
  render() {
    var data = [
      {src: require('Image1.jpg')},
      {src: require('Image2.jpg')},
      {src: require('Image3.jpg')},
    ];
    return (
      <Swiper
        containerStyle={{flex: 1}}
        onScroll={() => {}}
        activeDotColor={'#1976D2'}
        inActiveDotColor={'grey'}
        data={data}
        initIndex={0}
        renderItem={({item, index}) => (
          <View style={{backgroundColor: item.color, flex: 1}}>
            <Image source={item.src} />
          </View>
        )}
      />
    );
  }
}

Props

Prop nameDescriptionTypeDefault value
containerStyleContainer style for componentobject-
dataChunk of data(object)array-
renderItemCallback which takes a chunk of data and returns a component.function-
onScrollCallback that is called when the Item is swipedfunction-
activeDotColorActive dot colorstring-
inActiveDotColorInActive dot colorstring-
initIndexSet default active itemnumber-

Stepper

Demo

App.js

import React from 'react';
import {View, Text} from 'react-native';
import {Button, Stepper} from 'react-native-shbib-ui';

export default StepperExample = () => {
  FirstScreen = ({next, back}) => (
    <View style={styles.screenContent}>
      <Text style={styles.text}>First Screen</Text>
      <View style={styles.buttonContent}>
        <Button title={'Prev Step'} onPress={back} />
        <Button title={'Next Step'} onPress={next} />
      </View>
    </View>
  );
  SecondScreen = ({next, back}) => (
    <View style={styles.screenContent}>
      <Text style={styles.text}>Second Screen</Text>
      <View style={styles.buttonContent}>
        <Button title={'Prev Step'} onPress={back} />
        <Button title={'Next Step'} onPress={next} />
      </View>
    </View>
  );
  ThirdScreen = ({next, back}) => (
    <View style={styles.screenContent}>
      <Text style={styles.text}>Third Screen</Text>
      <View style={styles.buttonContent}>
        <Button title={'Prev Step'} onPress={back} />
        <Button title={'Next Step'} onPress={next} />
      </View>
    </View>
  );
  return (
    <View style={styles.root}>
      <Stepper steps={[FirstScreen, SecondScreen, ThirdScreen]} />
    </View>
  );
};
const styles = {
  root: {
    flex: 1,
    justifyContent: 'center',
  },
  screenContent: {
    alignSelf: 'center',
    alignItems: 'center',
  },
  text: {
    fontSize: 30,
  },
  buttonContent: {
    marginTop: 100,
    flexDirection: 'row',
  },
};

Props

Prop nameDescriptionTypeDefault value
containerStyleContainer style for componentobject-
stepsContainer style for componentarray of function-

Card

Demo

App.js

import React from 'react';
import {View, Text} from 'react-native';
import {Card} from 'react-native-shbib-ui';

export default CardExample = () => {
  const text =
    'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.';
  return (
    <View style={styles.root}>
      <Card containerStyle={styles.cardContainer} style={styles.card1Styles}>
        <Text>{text}</Text>
      </Card>
      <Card containerStyle={styles.cardContainer} style={styles.card2Styles}>
        <Text>{text}</Text>
      </Card>
    </View>
  );
};

const styles = {
  root: {
    flex: 1,
    justifyContent: 'center',
  },
  cardContainer: {
    alignSelf: 'center',
  },
  card1Styles: {
    width: 300,
    height: 100,
    justifyContent: 'center',
    alignItems: 'center',
  },
  card2Styles: {
    marginTop: 20,
    width: 300,
    height: 100,
    justifyContent: 'center',
    alignItems: 'center',
    borderRadius: 20,
  },
};

Props

Prop nameDescriptionTypeDefault value
containerStyleContainer style for componentobject-

MediaGrid

Demo

App.js

import React from 'react';
import {MediaGrid, Card} from 'react-native-shbib-ui';
import {View} from 'react-native';
export default class MediaGridExample extends React.Component {
  render() {
    var data = [require('Image1.jpg')];
    var data1 = [require('Image1.jpg'), require('Image2.jpg')];
    var data2 = [
      require('Image1.jpg'),
      require('Image2.jpg'),
      require('Image3.jpg'),
    ];
    var data3 = [
      require('Image1.jpg'),
      require('Image2.jpg'),
      require('Image3.jpg'),
      require('Image4.jpg'),
      require('Image5.jpg'),
    ];
    return (
      <View style={styles.root}>
        <Card style={styles.cardStyle}>
          <MediaGrid media={data} />
        </Card>
        <Card style={styles.cardStyle}>
          <MediaGrid media={data1} />
        </Card>
        <Card style={styles.cardStyle}>
          <MediaGrid media={data2} />
        </Card>
        <Card style={styles.cardStyle}>
          <MediaGrid media={data3} />
        </Card>
      </View>
    );
  }
}
const styles = {
  root: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
  cardStyle: {
    padding: 10,
    marginTop: 10,
  },
};

Props

Prop nameDescriptionTypeDefault value
containerStyleContainer style for componentobject-
dataChunk of Image sourceimageSource-

Header

Demo

App.js

import React from 'react';
import {Text} from 'react-native';
import {Header} from 'react-native-shbib-ui';
export default class HeaderExample extends React.Component {
  render() {
    return (
      <Header
        color="#f5f5f5"
        size={70}
        rightComponent={() => <Text>right</Text>}
        centerComponent={() => <Text>center</Text>}
        leftComponent={() => <Text>left</Text>}
      />
    );
  }
}

Props

Prop nameDescriptionTypeDefault value
containerStyleContainer style for componentobject-
styleStyle for headerobject-
colorSet background color for headerstring-
sizeSet size for headernumber-
customHeaderCustom design of headerfunction-
leftComponentComponents render to the left in Headerfunction-
centerComponentComponents render to the center in Headerfunction-
rightComponentComponents render to the right in Headerfunction-

Button

Demo

App.js

import React from 'react';
import {View} from 'react-native';
import {Button} from 'react-native-shbib-ui';
export default class ButtonExample extends React.Component {
  render() {
    return (
      <View style={styles.root}>
        <Button
          buttonSize={100}
          buttonColor={'#FFA726'}
          rounded
          title={'Rounded'}
        />
        <Button buttonSize={150} buttonColor={'#66BB6A'} title={'Click me'} />
        <Button buttonSize={175} buttonColor={'#26C6DA'} loading />
        <Button
          buttonSize={200}
          disabled
          titleSize={30}
          titleColor={'black'}
          title={'Disabled'}
        />
      </View>
    );
  }
}
const styles = {
  root: {
    flex: 1,
    justifyContent: 'space-around',
  },
};

Props

Prop nameDescriptionTypeDefault value
containerStyleStyling for Component containerobject-
disabledStyleAdd additional styling for disabled buttonobject-
buttonStyleAdd additional styling for buttonobject-
titleStyleAdd additional styling for titlenumber-
loadingStyleAdd additional styling for loading componentobject-
titleTitle for buttonstringButton
onPressHandler to be called when the user pressfunctionfalse
loadingDisplay a loading spinnerboolean-
loadingColorSpinner colorstring'white'
loadingSizeSpinner sizeiOS:string, Android:numberiOS:'small', Android:20
roundedRounded Buttonbooleanfalse
disabledDisables click option for buttonbooleanfalse
buttonColorButton colorstring-
buttonSizeButton sizenumber
titleColorTitle colorstring-
titleSizeTitle sizenumber-
activeOpacityActive opacity for buttonnumber1

Badge

Demo

App.js

import React from 'react';
import {View} from 'react-native';
import {Badge} from 'react-native-shbib-ui';
export default class BadgeExample extends React.Component {
  render() {
    return (
      <View style={styles.root}>
        <Badge
          valueSize={20}
          valueColor={'white'}
          badgeSize={30}
          badgeColor={'orange'}
        />
        <Badge
          containerStyle={styles.avatarContainer}
          value={'1'}
          valueSize={20}
          valueColor={'white'}
          badgeSize={30}
          badgeColor={'red'}
        />
        <Badge
          containerStyle={styles.avatarContainer}
          value={'10'}
          valueSize={20}
          valueColor={'white'}
          badgeSize={35}
          badgeColor={'green'}
        />
        <Badge
          containerStyle={styles.avatarContainer}
          value={'100'}
          valueSize={20}
          valueColor={'white'}
          badgeSize={40}
          badgeColor={'blue'}
        />
        <Badge
          containerStyle={styles.avatarContainer}
          value={'1000'}
          valueSize={20}
          valueColor={'white'}
          badgeColor={'grey'}
        />
      </View>
    );
  }
}
const styles = {
  root: {
    flex: 1,
    justifyContent: 'center',
  },
  avatarContainer: {
    marginTop: 10,
  },
};

Props

Prop nameDescriptionTypeDefault value
containerStyleContainer style for componentobject-
badgeStyleDivider colorobject-
valueStyleDivider border widthobject-
valueBadge valuestring-
badgeSizeBadge sizenumber-
valueSizeValue font sizenumber20
badgeColorBadge colorstring-
valueColorValue colorstring'white'

Spinner

Demo

App.js

import React from 'react';
import {View} from 'react-native';
import {Spinner} from 'react-native-shbib-ui';
export default class SpinnerExample extends React.Component {
  render() {
    return (
      <View style={styles.root}>
        <Spinner color={'#FFA726'} size={'small'} />
        <Spinner color={'#66BB6A'} size={'large'} />
        <Spinner color={'#26C6DA'} size={'large'} />
        <Spinner color={'black'} />
      </View>
    );
  }
}
const styles = {
  root: {
    flex: 1,
    justifyContent: 'space-around',
  },
};

Props

Prop nameDescriptionTypeDefault value
containerStyleContainer style for componentobject-
colorSet spinner colorstring-
sizeSet size for spinnernumber-

Divider

Demo

App.js

import React from 'react';
import {View} from 'react-native';
import {Divider} from 'react-native-shbib-ui';
export default class DividerExample extends React.Component {
  render() {
    return (
      <View style={styles.root}>
        <Divider
          containerStyle={{}}
          color={'red'}
          borderWidth={1}
          width={100}
        />
        <Divider
          containerStyle={{}}
          color={'green'}
          borderWidth={2}
          width={200}
        />
        <Divider
          containerStyle={{}}
          color={'blue'}
          borderWidth={3}
          width={300}
        />
        <Divider
          containerStyle={{}}
          color={'grey'}
          borderWidth={4}
          width={400}
        />
        <Divider containerStyle={{}} color={'black'} borderWidth={5} />
      </View>
    );
  }
}
const styles = {
  root: {
    flex: 1,
    justifyContent: 'space-around',
  },
};

Props

Prop nameDescriptionTypeDefault value
containerStyleContainer style for componentobject-
colorDivider colorstring-
borderWidthDivider border widthnumber1
widthDivider widthnumber-

CheckBox

Demo

App.js

import React from 'react';
import {View} from 'react-native';
import {CheckBox} from 'react-native-shbib-ui';
export default class CheckBoxExample extends React.Component {
  render() {
    return (
      <View style={styles.root}>
        <CheckBox label={'Check Box1'} labelSize={20} iconSize={25} />
        <CheckBox
          checked={true}
          label={'Check Box2'}
          labelColor={'red'}
          labelSize={20}
          iconColor={'red'}
          iconSize={25}
        />
        <CheckBox
          iconColor={'orange'}
          labelColor={'orange'}
          label={'Check Box3'}
          labelSize={20}
          iconSize={25}
        />
      </View>
    );
  }
}
const styles = {
  root: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
};

Props

Prop nameDescriptionTypeDefault value
containerStyleContainer style for componentobject-
checkedState value of an item from set of choicesboolean-
onPressHandler to be called when the user selects / unselects the checkboxfunction-
iconSizeIcon sizenumber-
iconColorIcon colorstring-
labelCheckbox labelstring-
labelSizeLabel sizenumber-
labelColorLabel colorstring-

RadioButton

Demo

App.js

import React from 'react';
import {View} from 'react-native';
import {RadioButton} from 'react-native-shbib-ui';
export default class RadioButtonExample extends React.Component {
  render() {
    return (
      <View style={styles.root}>
        <RadioButton label={'Radio button1'} labelSize={20} iconSize={25} />
        <RadioButton
          checked={true}
          label={'Radio button2'}
          labelColor={'red'}
          labelSize={20}
          iconColor={'red'}
          iconSize={25}
        />
        <RadioButton
          iconColor={'orange'}
          labelColor={'orange'}
          label={'Radio button3'}
          labelSize={20}
          iconSize={25}
        />
      </View>
    );
  }
}
const styles = {
  root: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
};

Props

Prop nameDescriptionTypeDefault value
containerStyleContainer style for componentobject-
checkedState value of an item from set of choicesboolean-
onPressHandler to be called when the user selects / unselects the radio buttonfunction-
iconSizeIcon sizenumber-
iconColorIcon colorstring-
labelRadio button labelstring-
labelSizeLabel sizenumber-
labelColorLabel colorstring-

Progress

Demo

App.js

import React from 'react';
import {Progress} from './src/react-native-shbib-ui';
import {View} from 'react-native';
export default class ProgressExample extends React.Component {
  render() {
    return (
      <View style={styles.root}>
        <Progress.Bar
          value={30}
          primaryColor="#FFAB40"
          secondaryColor="#FFD180"
          width={150}
          height={20}
        />
        <Progress.Bar
          value={60}
          primaryColor="#FF3D00"
          secondaryColor="#FF9E80"
          width={200}
          height={25}
        />
        <Progress.Bar
          value={40}
          primaryColor="#00E676"
          secondaryColor="#B9F6CA"
          width={250}
          height={30}
        />
        <Progress.Bar
          value={80}
          primaryColor="#1976D2"
          secondaryColor="#BBDEFB"
          width={300}
          height={35}
        />
      </View>
    );
  }
}
const styles = {
  root: {
    flex: 1,
    justifyContent: 'space-around',
    alignItems: 'center',
  },
};

Props

Prop nameDescriptionTypeDefault value
containerStyleContainer style for componentobject-
styleProgress styleobject-
valueProgress fillnumber-
primaryColorFill colorstring-
secondaryColorBackground colorstring-
widthProgress widthnumber-
heightProgress heightnumber-