1.3.10 • Published 9 months ago

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

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months 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, Flashlist 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 have installed Flashlist, it will be automatically used for avatars list.

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, { useRef } from 'react';
import { View } from 'react-native';
import InstagramStories, { InstagramStoriesPublicMethods } from '@birdwingo/react-native-instagram-stories';

const YourComponent = () => {

  // to use public methods:
  const ref = useRef( null ); // if using typescript - useRef<InstagramStoriesPublicMethods>( null )
  
  const stories = [{
    id: 'user1',
    name: 'User 1',
    imgUrl: 'user1-profile-image-url',
    stories: [
      { id: 'story1', source: { uri: 'story1-image-url' } },
      { id: 'story2', source: { uri: 'story1-video-url' }, mediaType: 'video' },
      // ...
    ]}, // ...
  ];

  // usage of public method
  const setStories = () => ref.current?.setStories( stories );
  
  return (
    <View>
      <InstagramStories
        ref={ref}
        stories={stories}
        // ...
      />
     <Pressable onPress={setStories}>{...}</Pressable>
    </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', FlashListPropsAdditional 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.
nameTextStyleTextStyle{ width: avatarSize + 10 }Additional styles for name text elements.
nameTextPropsTextPropsProps to be passed to the name Text component.
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)
storyAnimationDurationnumber800Duration of story animation (animation when swiping to the left/right)
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
hideElementsOnLongPressbooleanfalseA boolean indicating whether to hide all elements when story is paused by long press
hideOverlayOnLongPressbooleanThe value of hideElementOnLongPressControls whether the image overlay hides when hideElementOnLongPress is set to true. If true, the overlay will hide along with other elements on long press. If false, only the other elements (e.g., header, progress bar) will hide, and the overlay will remain visible.
loopingStories'none''onlyLast''all''none'A string indicating whether to continue stories after last story was shown. If set to 'none' modal will be closed after all stories were played, if set to 'onlyLast' stories will loop on last user only after all stories were played. If set to 'all' stories will play from beginning after all stories were played.
statusBarTranslucentbooleanfalseA property passed to React native Modal component
footerComponentReactNodeA custom component, such as a floating element, that can be added to the modal.
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
goToSpecificStory( userId: string, index: number ) => voidChange current playing story to defined index if index not exist then start playing first story

Types

InstagramStoryProps

ParameterTypeRequired
idstringtrue
avatarSourceImageProps'source'false
renderAvatar() => ReactNodefalse
renderStoryHeader() => ReactNodefalse
onStoryHeaderPress() => voidfalse
namestringfalse
storiesStoryItemProps[]true

Please note that id parameter must be unique for every user

StoryItemProps

ParameterTypeRequired
idstringtrue
sourceImageProps'source'true
mediaType'video' | 'image' (default: 'image')false
animationDurationnumberfalse
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.3.10

9 months ago

1.3.9

9 months ago

1.3.7

9 months ago

1.3.6

9 months ago

1.3.8

9 months ago

1.2.8

1 year ago

1.3.5

11 months ago

1.3.4

12 months ago

1.3.3

12 months ago

1.3.2

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.9

1 year ago

1.2.12

1 year ago

1.2.10

1 year ago

1.2.11

1 year ago

1.2.7

1 year ago

1.2.6

1 year ago

1.2.5

1 year ago

1.2.4

1 year ago

1.2.3

1 year ago

1.2.2

1 year ago

1.2.1

1 year ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.9

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago