npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@blackbox-vision/react-native-live-stories

v0.19.0

Published

An Instagram video stories component

Downloads

36

Readme

React Native Live Stories npm version License: MIT

:rocket: An Instagram Stories like component.

Table of contents

Use Case

You need a component for rendering Instagram like stories.

Compatibility

Since this library does internal use of hooks you need React >= 16.8.0.

Installation

You can install this library via NPM or YARN.

NPM

npm i @blackbox-vision/react-native-live-stories

YARN

yarn add @blackbox-vision/react-native-live-stories

Peer dependencies

We rely on the following packages:

You can install all of them by running the next command:

npm i react-native-elements react-native-video react-native-snap-carousel react-native-vector-icons react-native-linear-gradient react-native-fast-image react-native-video-cache

Additional Steps

React Native Fast Image

If in your android builds you've proguard enabled, you will need to add the following config in proguard-rules.pro:

-keep public class com.dylanvann.fastimage.* {*;}
-keep public class com.dylanvann.fastimage.** {*;}
-keep public class * implements com.bumptech.glide.module.GlideModule
-keep public class * extends com.bumptech.glide.module.AppGlideModule
-keep public enum com.bumptech.glide.load.ImageHeaderParser$** {
  **[] $VALUES;
  public *;
}

React Native Video Cache

For built-in caching we use react-native-video-cache library, which needs a little adjustment in the android manifest in order to work.

You need to add the property android:usesCleartextTraffic="true" in your application in AndroidManifest.xml.

Example Usage

After reading and performing the previous steps, you should be able to import the library and use it like in this example:

// insta-stories.js

import { Text } from 'react-native';
import React, { useState } from 'react';
import { StoryPreview } from '@blackbox-vision/react-native-live-stories';

const stories = [
  {
    id: 1,
    viewed: false,
    preview:
      'https://instagram.faep7-1.fna.fbcdn.net/v/t51.2885-19/s320x320/62500940_1363897577094116_5145198214462308352_n.jpg?_nc_ht=instagram.faep7-1.fna.fbcdn.net&_nc_ohc=BkIQomknhK0AX_1xEiM&oh=2269fb6e76910915456b7bb6ff24a282&oe=5FBFFDA9',
    video: 'https://www.w3schools.com/html/mov_bbb.mp4',
  },
  {
    id: 2,
    viewed: false,
    preview:
      'https://instagram.faep7-1.fna.fbcdn.net/v/t51.2885-19/s320x320/62500940_1363897577094116_5145198214462308352_n.jpg?_nc_ht=instagram.faep7-1.fna.fbcdn.net&_nc_ohc=BkIQomknhK0AX_1xEiM&oh=2269fb6e76910915456b7bb6ff24a282&oe=5FBFFDA9',
    video: 'https://vjs.zencdn.net/v/oceans.mp4',
  },
  {
    id: 3,
    viewed: false,
    preview:
      'https://instagram.faep7-1.fna.fbcdn.net/v/t51.2885-19/s320x320/62500940_1363897577094116_5145198214462308352_n.jpg?_nc_ht=instagram.faep7-1.fna.fbcdn.net&_nc_ohc=BkIQomknhK0AX_1xEiM&oh=2269fb6e76910915456b7bb6ff24a282&oe=5FBFFDA9',
    video: 'https://vjs.zencdn.net/v/oceans.mp4',
  },
];

const InstaStories = (props) => {
  const onStoryDetailItemNext = (story, idx) => {
    console.info('Moving to next story', story, ' at index ', idx);
  };

  const onStoryDetailBackPress = (story, idx) => {
    console.info('Going back from story', story, ' at index ', idx);
  };

  const onStoryPreviewItemPress = (story, idx) => {
    console.info('Clicking story preview for story', story, ' at index ', idx);
  };

  const getStoryPreviewItemProps = (story, idx) => ({
    shouldAnimate: !story.viewed,
  });

  return (
    <StoryPreview
      stories={stories}
      onStoryDetailItemNext={onStoryDetailItemNext}
      onStoryDetailBackPress={onStoryDetailBackPress}
      onStoryPreviewItemPress={onStoryPreviewItemPress}
      getStoryPreviewItemProps={getStoryPreviewItemProps}
    />
  );
};

Component API

The StoryPreview component has the following props:

| Properties | Types | Default Value | Description | | ------------------------ | ----------- | ------------- | ---------------------------------------------------- | | style | ViewStyle | none | Styles for FlatList mini stories container | | stories | array | [] | An array of stories to be rendered | | StoryDetailItemHeader | component | none | Component for Header in Story Detail Item | | StoryDetailItemFooter | component | none | Component for Footer in Story Detail Item | | onStoryDetailItemNext | function | none | Callback fired when drag to next item | | onStoryDetailBackPress | function | none | Callback fired when on back button press | | onStoryPreviewItemPress | function | none | Callback fired when performed click on preview | | getStoryPreviewItemProps | function | none | Callback to get story preview item props dynamically |

Customization

We provide some sort of customization by passing some components that can override the defaults from the library.

For now, we only give the ability to customize the followings components:

  • Story Header
  • Story Footer

Header

You can pass to the StoryPreview the component prop StoryDetailItemHeader that will replace the Header shipped by default.

Example Header:

import React from 'react';
import { Text } from 'react-native';

export const StoryHeader = ({
  mute,
  muted,
  story,
  goBack,
  duration,
  progress,
}) => <Text>I am the header</Text>;

StoryHeader.displayName = 'StoryHeader';

Footer

You can pass to the StoryPreview the component prop StoryDetailItemFooter that will replace the Footer shipped by default.

Example Footer:

import React from 'react';
import { Text } from 'react-native';

export const StoryFooter = ({
  mute,
  muted,
  story,
  goBack,
  duration,
  progress,
}) => <Text>I am the footer</Text>;

StoryFooter.displayName = 'StoryFooter';

TODOs

With this library we're intended to have you covered when trying to implement stories into a React Native app.

As part of our efforts we've a very stable code by now, but we need to improve much things in order to reach a stable release.

Here is a list of things we need to do:

  • [ ] Re-define story attributes to support passing more information.
  • [ ] Improve grow animation to behave like Insta one.
  • [ ] Add support for loading effect in Previews like Insta.
  • [ ] Add support for rendering multiple same user stories.
  • [ ] Add support for rendering initial preview with a CTA.
  • [ ] Ship with a default Header and Footer in the story that looks like Instagram ones.

Issues

Please, open an issue following one of the issues templates. We will do our best to fix them.

Contributing

If you want to contribute to this project see contributing for more information.

License

Distributed under the MIT license. See LICENSE for more information.