0.7.0 • Published 9 months ago

react-native-story-component v0.7.0

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

react-native-story-component

npm version CircleCI Commitizen friendly license

A decent story component for React-Native

Preview

Table of Contents

Getting started

npm i react-native-story-component

Props

NameDescriptionTypeDefault Value
dataArray of stories.UserStory[]
unPressedBorderColorUnpressed border color of profile circlecolorred
pressedBorderColorPressed border color of profile circlecolorgrey
onCloseTodo when close(item: UserStory) => voidnull
onStartTodo when start(item: UserStory) => voidnull
durationPer story duration in secondsnumber10
swipeTextText of swipe componentstringSwipe Up
customSwipeUpButtonCustom component for swipe area() => ReactNode
customCloseButtonCustom component for close button() => ReactNode
customStoryListCustom component for story list(props: CustomStoryList) => React.ReactNode
customStoryViewCustom component for story view(props: CustomStoryView) => React.ReactNode
customProfileBannerCustom component for profile banner(props: CustomProfileBanner) => React.ReactNode
customStoryImageCustom component for story image(props: CustomStoryImage) => React.ReactNode
avatarSizeSize of avatar circlenumber60
showAvatarTextShow or hide avatar textbooltrue
showProfileBannerShow or hide profile bannerbooltrue
textStyleAvatar text styleTextStyle
prefetchImagesPrefetch story imagesbooltrue
onImagesPrefetchedCallback function for prefetching process(allImagesPrefetched: bool) => void

Usage

import Stories from 'react-native-story-component';

const App = () => {
  return (
    <Stories
      data={[
        {
          id: 1,
          avatar: 'https://randomuser.me/api/portraits/men/1.jpg',
          name: 'Marvin Lane',
          stories: [
            {
              id: 1,
              image: 'https://images.unsplash.com/photo-1510215744419-742d9dce947f?crop=entropy&cs=tinysrgb&fm=jpg&ixlib=rb-1.2.1&q=60&raw_url=true&ixid=MnwxMjA3fDB8MHxzZWFyY2h8NHx8MTA4MHgxOTIwfGVufDB8fDB8fA%3D%3D&auto=format&fit=crop&w=1200',,
              swipeText: 'Custom swipe text for this story',
              onPress: () => console.log('story 1 swiped'),
            },
            {
              id: 2,
              image: 'https://images.unsplash.com/photo-1493509094819-bd2d26fac21b?crop=entropy&cs=tinysrgb&fm=jpg&ixlib=rb-1.2.1&q=60&raw_url=true&ixid=MnwxMjA3fDB8MHxzZWFyY2h8M3x8MTA4MHgxOTIwfGVufDB8fDB8fA%3D%3D&auto=format&fit=crop&w=1200',
            },
          ],
        },
        {
          id: 2,
          avatar: 'https://randomuser.me/api/portraits/men/2.jpg',
          name: 'Manuel Weaver',
          stories: [
            {
              id: 1,
              image: 'https://images.unsplash.com/photo-1524821261922-e353d72c20e5?crop=entropy&cs=tinysrgb&fm=jpg&ixlib=rb-1.2.1&q=60&raw_url=true&ixid=MnwxMjA3fDB8MHxzZWFyY2h8Mnx8MTA4MHgxOTIwfGVufDB8fDB8fA%3D%3D&auto=format&fit=crop&w=1200',
              swipeText: 'Custom swipe text for this story',
              onPress: () => console.log('story 1 swiped'),
            },
            {
              id: 2,
              image: 'https://images.unsplash.com/photo-1590846083693-f23fdede3a7e?crop=entropy&cs=tinysrgb&fm=jpg&ixlib=rb-1.2.1&q=60&raw_url=true&ixid=MnwxMjA3fDB8MHxzZWFyY2h8MXx8MTA4MHgxOTIwfGVufDB8fDB8fA%3D%3D&auto=format&fit=crop&w=1200',
              swipeText: 'Custom swipe text for this story',
              onPress: () => console.log('story 2 swiped'),
            },
          ],
        },
      ]}
      duration={10}
      onStart={(openedStory) => {
        console.log(openedStory);
      }}
      onClose={(closedStory) => {
        console.log(closedStory);
      }}
      customSwipeUpButton={() => (
        <View>
          <Text>Swipe</Text>
        </View>
      )}
    />
  );
};

Example App

# clone the project
git clone https://github.com/ridvanaltun/react-native-story-component.git

# go into the project
cd react-native-story-component

# make project ready
npm run bootstrap

# go into the example
cd example

# run for android
npm run android

# or

# run for ios
npm run ios

Credit

I copied and rewrite the codebase from https://github.com/caglardurmus/react-native-insta-story in this project. I created this project because I was needed a better one.

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT

0.7.0

9 months ago

0.6.0

9 months ago

0.5.0

2 years ago

0.4.2

2 years ago

0.4.1

2 years ago

0.4.0

2 years ago

0.3.3

2 years ago

0.3.2

2 years ago

0.3.1

2 years ago

0.3.0

2 years ago

0.2.1

2 years ago

0.2.0

2 years ago

0.1.0

2 years ago