1.2.7 ā€¢ Published 8 days ago

@birdwingo/react-native-instagram-stories v1.2.7

Weekly downloads
-
License
MIT
Repository
github
Last release
8 days ago

@birdwingo/react-native-instagram-stories

npm downloads npm version github release npm release

Features šŸŒŸ

šŸ“ø Capture Moments: Easily integrate Instagram-like stories in your React Native app to let users share their favorite moments.

āœØ Inspired by Instagram: Crafted with inspiration from the real Instagram stories feature, capturing its essence and style.

šŸ“± Mobile-Friendly: Designed with mobile users in mind, providing a smooth and responsive experience on all devices.

šŸ’¾ Using Async Storage: Utilize Async Storage to save the progress of users and load them whenever they want.

šŸ› ļø Developer Friendly: Well-documented and easy to set up, making the developer's life a breeze.

šŸš€ High Performance: Optimized for speed, ensuring a lag-free experience for users.

šŸ’” Rich Features: Support for video, images, and text, plus more ā€“ all in one powerful package!

šŸŽ‰ Community Support: Join a growing community of developers and users, eager to help and share their experiences.

About

react-native-instagram-stories component is a versatile React Native component designed to display a horizontal scrollable list of user stories, similar to the stories feature found in the Instagram app. It provides a visually appealing way to showcase stories with various customizable options. It is used in the Birdwingo mobile app for Birdwingo Academy which allows users to learn the basics of investing in stocks and ETFs.

Installation

npm install react-native-svg
npm install react-native-reanimated
npm install react-native-gesture-handler
npm install @birdwingo/react-native-instagram-stories

Integration with Storage and Video

The component offers an option to save and track the progress of seen stories using saveProgress. If you use saveProgress, please make sure you have @react-native-async-storage/async-storage installed.

If you use video in your stories, please make sure you have react-native-video installed.

Usage

To use the InstagramStories component, you need to import it in your React Native application and include it in your JSX code. Here's an example of how to use it:

import React from 'react';
import { View } from 'react-native';
import InstagramStories from '@birdwingo/react-native-instagram-stories';

const YourComponent = () => {
  
  const stories = [{
    id: 'user1',
    name: 'User 1',
    imgUrl: 'user1-profile-image-url',
    stories: [
      { id: 'story1', sourceUrl: 'story1-image-url' },
      { id: 'story2', sourceUrl: 'story1-video-url', mediaType: 'video' },
      // ...
    ]}, // ...
  ];
  
  return (
    <View>
      <InstagramStories
        stories={stories}
        // ...
      />
    </View>
  );
};

export default YourComponent;

Props

NameTypeDefault valueDescription
storiesInstagramStoryProps[]requiredAn array of stories.
saveProgressbooleanfalseA boolean indicating whether to save and track the progress of seen stories.
avatarBorderColorsstring[]DEFAULT_COLORSAn array of string colors representing the border colors of story avatars.
avatarSeenBorderColorsstring[] '#2A2A2C' An array of string colors representing the border colors of seen story avatars.
avatarSizenumber60The size of the story avatars.
storyAvatarSizenumber25The size of the avatars shown in the header of each story.
avatarListContainerStyleScrollViewProps'contentContainerStyle'Additional styles for the avatar scroll list container.
avatarListContainerPropsScrollViewPropsProps to be passed to the avatar list ScrollView component.
containerStyleViewStyleAdditional styles for the story container.
textStyleTextStyleAdditional styles for text elements.
animationDurationnumber10000The duration of the story animations in ms.
videoAnimationMaxDurationnumberThe max duration of the video story animations in ms. If is this property not provided, the whole video will be played.
backgroundColorstring'#000000'The background color of story container.
showNamebooleanfalseWhether you want to show user name under avatar in avatar list.
nameTextStyleTextStyleAdditional styles for name text elements.
videoPropsreact-native-videoAdditional props for video component. For more information, follow react-native-video.
closeIconColorstring'#00000099'The color of story close icon.
progressColorstring'#00000099'Background color of progress bar item in inactive state
progressActiveColorstring'#FFFFFF'Background color of progress bar item in active state
modalAnimationDurationnumber800Duration of modal animation in ms (showing/closing instagram stories)
mediaContainerStyleViewStyleAdditional styles for media (video or image) container
imageStylesImageStyle{ width: WIDTH, aspectRatio: 0.5626 }Additional styles image component
imagePropsImagePropsAdditional props applied to image component
isVisiblebooleanfalseA boolean indicating whether to show modal on load (modal will be show with first story item)
headerStyleViewStyleAdditional styles for the story header
headerContainerStyleViewStyleAdditional styles for the story header container
progressContainerStyleViewStyleAdditional styles for the story progress container
hideAvatarListbooleanfalseA boolean indicating whether to hide avatar scroll list
imageOverlayViewReactNodeImage overlay compontent
onShow( id: string ) => voidCallback when a story is shown.
onHide( id: string ) => voidCallback when a story is hidden.
onSwipeUp( userId?: string, storyId?: string ) => voidCallback when user swipes up.
onStoryStart( userId?: string, storyId?: string ) => voidCallback when story started
onStoryEnd( userId?: string, storyId?: string ) => voidCallback when story ended

Public Methods

NameTypeDescription
spliceStories( stories: InstagramStoryProps[], index?: number ) => voidInsert new stories at a specific index. If you don't provide index property, stories will be pushed to the end of array.
spliceUserStories( stories: InstagramStoryProps[], user: string, index?: number ) => voidInsert new stories for a specific user at a specific index. If you don't provide index property, stories will be pushed to the end of array
setStories( stories: InstagramStoryProps[] ) => voidReplace the current stories with a new set of stories.
clearProgressStorage() => voidClear the progress storage for seen stories.
hide() => voidHide stories if currently visible
show( id?: string ) => voidShow stories modal with provided story id. If id is not provided, will be shown first story
pause() => voidPause story
resume() => voidResume story
goToPreviousStory() => voidGoes to previous story item
goToNextStory() => voidGoes to next story item
getCurrentStory() => {userId?: string, storyId?: string}Returns current userId and storyId

Types

InstagramStoryProps

ParameterTypeRequired
idstringtrue
imgUrlstringfalse
renderAvatar() => ReactNodefalse
renderStoryHeader() => ReactNodefalse
namestringfalse
storiesStoryItemProps[]true

Please note that id parameter must be unique for every user

StoryItemProps

ParameterTypeRequired
idstringtrue
sourceUrlstringtrue
mediaType'video' | 'image' (default: 'image')false
renderContent() => ReactNodefalse
renderFooter() => ReactNodefalse

Please note that id parameter must be unique for every story

Default Gradient Colors

Default colors for avatar gradient are the same as on Instagram - [ '#F7B801', '#F18701', '#F35B04', '#F5301E', '#C81D4E', '#8F1D4E' ]

Sponsor

react-native-instagram-stories is sponsored by Birdwingo.\ Download Birdwingo mobile app to see react-native-instagram-stories in action!

1.2.7

8 days ago

1.2.6

2 months ago

1.2.5

2 months ago

1.2.4

3 months ago

1.2.3

3 months ago

1.2.2

3 months ago

1.2.1

3 months ago

1.1.1

4 months ago

1.1.0

4 months ago

1.0.13

5 months ago

1.0.12

6 months ago

1.0.11

6 months ago

1.0.9

6 months ago

1.0.7

6 months ago

1.0.6

6 months ago

1.0.5

6 months ago

1.0.4

8 months ago

1.0.3

9 months ago

1.0.2

9 months ago

1.0.1

9 months ago