1.0.9 • Published 2 years ago

react-native-stories-view v1.0.9

Weekly downloads
78
License
-
Repository
github
Last release
2 years ago

React Native Stories View ⚡

npm version Platform - Android and IOS

npm.io

A simple and fully customizable React Native components that provides a status/stories feature like Whatsapp, Instagram. For navigation across all the stories you can touch the left or right portion of the screen similar to what we see on Whatsapp or Instagram. The library works seemleslly across both Android as well as IOS platform developed with ❤️ in Typescript & React 🔥.

Feature's include :

  • Progress bar with custom duration & styling options.
  • Story Image view with custom styling options.
  • A fully customizable Header View, you can use default one or pass in your choice of component.
  • A fully customizable Footer View, you can use default one or pass in your choice of component.

Spread Your ❤️:

GitHub followers Twitter Follow

Demo

IOSAndroid

Screenshots

Example OneExample TwoExample ThreeExample FourExample Five
npm.ionpm.ionpm.ionpm.ionpm.io

Installation

If using yarn:

yarn add react-native-stories-view

If using npm:

npm i react-native-stories-view

Usage

For example code, Click here

  • ProgressBar

This individual component can be used to display progressive bar with controlled duration, style & motion. To programatically enable or disable the progress pass boolean value to enableProgress & to change the position of progress use progressIndex prop along with duration prop to control the motion. On every change of propress position onChange function will be invoked for any customization.

<ProgressBar
   images={['','']}
   onChange={() => {}}
   progressIndex={0}
   enableProgress={true}
   duration={20} 
   barStyle={{
      barActiveColor: BAR_ACTIVE_COLOR,
      barInActiveColor: BAR_INACTIVE_COLOR,
      barWidth: 100, 
      barHeight: 4
   }}
/>
  • StoryContainer

This component provides you with entire functionality of Status/Stories feature along with flexible customization.

Basic Usage

This simply display's only the Progress Bar & the Story view images without any header or footer view. The container can be given style by providing containerStyle props.

import { StoryContainer } from 'react-native-stories-view';

<StoryContainer
   visible={true}
   enableProgress={true}
   images={images}
   duration={20}  
   onComplete={() => alert("onComplete")}
   containerStyle={{
       width: '100%',
       height: '100%',
   }}
/>

Header View

You can use the inbuilt header view which can display basic user details by simply providing userProfile props with specified parameters.

// User Information in header
<StoryContainer
   visible={true}
   enableProgress={true}
   images={images}
   duration={20} 
   onComplete={() => alert("onComplete")}
   userProfile={{
      userImage: PROFILE,
      userName: 'Yuvraj Pandey',
      userMessage: 'Work hard & success will follow !!',
      imageArrow: BACK,
      onImageClick: () => {
         console.log('lskndclksnc');
         Alert.alert('User profile image tapped');
      },
   }}
/>

However if you wish to add your own custom component, you can pass your own component in headerComponent prop and this will replace the header described above.

<StoryContainer
   visible={true}
   enableProgress={true}
   images={images}
   onComplete={() => alert("onComplete")}
   duration={20} 
   headerComponent={<View />}
/>

In case neither of the prop i.e userProfile or headerComponent is passed then header view will be not be displayed.

Footer View

The in built footer view provides you with a reply option where in you can accept user input for the status user just viewed. isShowReply boolean prop can be used to programaically show or hide the footer reply view. The onReplyTextChange & onReplyButtonClick function provides callback for the action performed by the user along with the progressIndex of the particular story currently viewed.

// Reply option in Footer
<StoryContainer
   visible={true}
   enableProgress={true}
   images={images}
   duration={20} 
   onComplete={() => alert("onComplete")}
   replyView={{
      isShowReply: true,
      onReplyTextChange: (textReply, progressIndex) => {
          console.log(`Text : ${textReply} , position : ${progressIndex}`);
      },
      onReplyButtonClick: (buttonType, progressIndex) => {
         switch (buttonType) {
            case 'send':
               console.log(`Send button tapped for position : ${progressIndex}`);
               break;

             case 'smiley':
               console.log(`Smiley button tapped for position : ${progressIndex}`);
               break;
          }
       },
   }}
/>

If you have your own custom component to use in Footer, simply pass your component in footerComponent prop as below which will replace the inbuilt Footer with your own custom style.

// Custom Footer component option
<StoryContainer
   visible={true}
   enableProgress={true}
   images={images}
   duration={20} 
   onComplete={() => alert("onComplete")}
   footerComponent={<View />}
/>

However if neither of the prop i.e replyView or footerComponent is passed then footer view will be not be displayed.

Documentation :

ProgressBar

PropNamePropTypePurposeRequired
imagesArray<String>Story images array to render count of barMandatory
progressIndexnumberStarts progress for a particular index itemMandatory
enableProgressBooleanStart/Stop the progress bar motionOptional
durationNumberControl's the speed of progress barOptional
barStyleObjectProgress Bar styleOptional
barActiveColorStringActive progress colorOptional
barInActiveColorStringIn Active progress colorOptional
barWidthnumberDefault 100, Always > 10 but < 100Optional
barHeightnumberDefault 7, Always > 4 but < 10Optional
onChangeFunctionFunction executes after change in progressIndexOptional

Basic

PropNamePropTypePurposeRequired
visibleBooleanToggle visibility of Story ContainerMandatory
enableProgressBooleanEnable/disable the top progress bar visibilityOptional
imagesArray<String>Story ImagesMandatory
durationNumberControl's the speed of progress barOptional
containerStyleObjectContainer styleOptional
onCompleteFunctionFunction executes after all status is completedOptional

Header

PropNamePropTypePurposeRequired
userProfileObjectDefault user detail viewOptional
userImageStringImage URLOptional
userNameStringDisplay's user nameOptional
userMessageStringDisplay's user informationOptional
imageArrowStringImage UrlOptional
onImageClickFunctionFunction that executes imageArrow click eventOptional
headerComponentComponentCustom componentOptional

Footer

PropNamePropTypePurposeRequired
replyViewObjectDefault reply view with Input textOptional
isShowReplyObjectToggle's the display of footer viewMandatory
onReplyTextChangeStringCallback for user entered text with posotionOptional
onReplyButtonClickStringCallback for emoji & send click with posotionOptional
footerComponentComponentCustom componentOptional

About Me

Yuvraj Pandey

I am a passionate Engineer which likes to push himself on various fronts of technologies.

For more exciting updates follow me,