Giter VIP home page Giter VIP logo

react-native-insta-story's Introduction

react-native-insta-story

Install

$ npm install react-native-insta-story --save or $ yarn add react-native-insta-story --save

Import

import InstaStory from "react-native-insta-story";

Props

Name Description Type Default Value
data Array of IUserStory. You can check from interfaces. object
unPressedBorderColor Unpressed border color of profile circle color red
pressedBorderColor Pressed border color of profile circle color grey
onClose Todo when close function null
onStart Todo when start function null
duration Per story duration seconds number 10
swipeText Text of swipe component string Swipe Up
customSwipeUpComponent For use custom component for swipe area component
customCloseComponent For use custom component for cloe button component
avatarSize Size of avatar circle number 60

Usage

const data = [
  {
    user_id: 1,
    user_image:
      "https://pbs.twimg.com/profile_images/1222140802475773952/61OmyINj.jpg",
    user_name: "Ahmet Çağlar Durmuş",
    stories: [
      {
        story_id: 1,
        story_image:
          "https://image.freepik.com/free-vector/universe-mobile-wallpaper-with-planets_79603-600.jpg",
        onPress: () => console.log("story 1 swiped"),
      },
      {
        story_id: 2,
        story_image:
          "https://image.freepik.com/free-vector/mobile-wallpaper-with-fluid-shapes_79603-601.jpg",
      },
    ],
  },
  {
    user_id: 2,
    user_image:
      "https://images.unsplash.com/photo-1511367461989-f85a21fda167?ixid=MnwxMjA3fDB8MHxzZWFyY2h8Mnx8cHJvZmlsZXxlbnwwfHwwfHw%3D&ixlib=rb-1.2.1&w=1000&q=80",
    user_name: "Test User",
    stories: [
      {
        story_id: 1,
        story_image:
          "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcTjORKvjcbMRGYPR3QIs3MofoWkD4wHzRd_eg&usqp=CAU",
        onPress: () => console.log("story 1 swiped"),
      },
      {
        story_id: 2,
        story_image:
          "https://files.oyebesmartest.com/uploads/preview/vivo-u20-mobile-wallpaper-full-hd-(1)qm6qyz9v60.jpg",
        onPress: () => console.log("story 2 swiped"),
      },
    ],
  },
];

<InstaStory
  data={data}
  duration={10}
  onStart={(item) => console.log(item)}
  onClose={(item) => console.log("close: ", item)}
  customSwipeUpComponent={
    <View>
      <Text>Swipe</Text>
    </View>
  }
  style={{ marginTop: 30 }}
/>;

Usage With API

 const [posts, setPosts] = useState("");

  useEffect(() => {
    axios.get(APIURL)
    .then((response)=> {
      setPosts(response.data);
    })

  }, [])


  <InstaStory
          data={posts}
          duration={3}
          onStart={item => mixpanel.track('Story Start')} //Tracking event Mixpanel
          onClose={item => mixpanel.track('Story Close')}
          customSwipeUpComponent={
            <View>
              <Text>Swipe</Text>
            </View>
          }
          style={{marginVertical: 10}}
        />

react-native-insta-story's People

Contributors

huseyintamer avatar

Watchers

James Cloos avatar

Forkers

nrzky

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.