All Projects → intellidev1991 → React Native Image Slider Box

intellidev1991 / React Native Image Slider Box

Licence: mit
A simple and fully customizable React Native component that implements an Image Slider UI.

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Native Image Slider Box

react-native-value-picker
Cross-Platform iOS(ish) style picker for react native.
Stars: ✭ 18 (-84.07%)
Mutual labels:  react-components, react-native-component
React Native Performance Monitor
React Native Performance Monitor - Realtime graphing of React Native render performance
Stars: ✭ 174 (+53.98%)
Mutual labels:  react-components, react-native-component
Opentok React
React components for OpenTok.js
Stars: ✭ 93 (-17.7%)
Mutual labels:  react-components
Mui Treasury
A collection of ready-to-use components based on Material-UI
Stars: ✭ 1,821 (+1511.5%)
Mutual labels:  react-components
React Feather
React component for Feather icons
Stars: ✭ 1,379 (+1120.35%)
Mutual labels:  react-components
Dataformsjs
🌟 DataFormsJS 🌟 A minimal JavaScript Framework and standalone React and Web Components for rapid development of high quality websites and single page applications.
Stars: ✭ 95 (-15.93%)
Mutual labels:  react-components
React Darkreader
🌓 A React Hook for adding a dark / night mode to your site.
Stars: ✭ 104 (-7.96%)
Mutual labels:  react-components
Ui
React Styled Components with bootstrap grid system
Stars: ✭ 89 (-21.24%)
Mutual labels:  react-components
Block Content To React
React component for transforming Sanity block content to React components
Stars: ✭ 111 (-1.77%)
Mutual labels:  react-components
React Native Otp Inputs
OTP inputs for React-Native
Stars: ✭ 101 (-10.62%)
Mutual labels:  react-native-component
Jafar
🌟!(Just another form application renderer)
Stars: ✭ 107 (-5.31%)
Mutual labels:  react-components
Re Jok
A React UI Component library built with styled-components
Stars: ✭ 102 (-9.73%)
Mutual labels:  react-components
Md Components
Material Design React Components
Stars: ✭ 97 (-14.16%)
Mutual labels:  react-components
React Cropper
Cropperjs as React component
Stars: ✭ 1,600 (+1315.93%)
Mutual labels:  react-components
React Cassette Player
Simple ReactJS HTML5 audio player component built with SVG icons from The Noun Project.
Stars: ✭ 93 (-17.7%)
Mutual labels:  react-components
React Native Slot Machine
Text slot machine for react-native
Stars: ✭ 109 (-3.54%)
Mutual labels:  react-native-component
React Pinpoint
An open source utility library for measuring React component render times.
Stars: ✭ 93 (-17.7%)
Mutual labels:  react-components
Uniforms
A React library for building forms from any schema.
Stars: ✭ 1,368 (+1110.62%)
Mutual labels:  react-components
React Native Barcode Scanner Google
Barcode scanner for react native, which implements barcode detection from Google's Vision API.
Stars: ✭ 105 (-7.08%)
Mutual labels:  react-native-component
Bloc.js
A predictable state management library that helps implement the BLoC design pattern in JavaScript
Stars: ✭ 111 (-1.77%)
Mutual labels:  react-components

react-native-image-slider-box

npm npm

Announce: New version published.


SliderBox

SliderBox

Install

  1. First, install our library | use below npm script

    npm i react-native-image-slider-box

    yarn add react-native-image-slider-box

  2. (Optional) : if you want to use third-party image library such as FastImage

    npm i react-native-fast-image

    yarn add react-native-fast-image

Well-done.

Usage :

list of available props for customization SliderBox:

Props Value Type Description
ImageComponent Image component, default as Image default value is React-native Image, if you use third-party library like FastImage use this property
images Array of image path(or url) as string Set array of images path- these paths can contain http url link or local images path using require('./pathOfImage')
onCurrentImagePressed handler function callback callback for get pressed image index (index start from 0)
currentImageEmitter handler function callback callback for get current image index (index start from 0)
disableOnPress boolean if present, then onCurrentImagePressed will be disabled
sliderBoxHeight int value default value = 200, you can change height of image slider box
parentWidth int default = screen.width ; in advance mode, if parent is smaller, you can change it. best practice is use onLayout handler in parent component or screen.
dotColor color string code change color of paging dot
inactiveDotColor color string code change color of inactive paging dot
dotStyle style object default style is : {width: 10,height: 10,borderRadius: 5,marginHorizontal: 0,padding: 0,margin: 0,} change style of paging dots if you want
paginationBoxVerticalPadding int value default = 10 ; change the height of paging dots from bottom of Slider-Box
autoplay bool value default = false
circleLoop boolean - attribute if set, when user swiped to last image circularly return to the first image again.
paginationBoxStyle object,default values use lib style customize pagination box
dotStyle object,default use lib style customize dot styles
resizeMethod string default is resize
resizeMode string default is cover
ImageComponentStyle object {} style object for ImageComponent
imageLoadingColor string default is #E91E63 , image loading indicator color
ImageLoader React component, default as ActivityIndicator default value is React-native ActivityIndicator.
   |

| firstItem | number | default is 0 , index of image to display when slider box loads |

1- add below import in your code :

import { SliderBox } from "react-native-image-slider-box";

2- Define your image array source, for below examples i create array in state.

export default class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      images: [
        "https://source.unsplash.com/1024x768/?nature",
        "https://source.unsplash.com/1024x768/?water",
        "https://source.unsplash.com/1024x768/?girl",
        "https://source.unsplash.com/1024x768/?tree", // Network image
        require('./assets/images/girl.jpg'),          // Local image
      ]
    };
  }
  // other component code ...
}

3- Use SliderBox such as these below examples :

Example 1 : SliderBox without and handler or customization

<SliderBox images={this.state.images} />

Example 2 : SliderBox with image press handler and currentImageEmitter

SliderBox

<SliderBox
  images={this.state.images}
  onCurrentImagePressed={index => console.warn(`image ${index} pressed`)}
  currentImageEmitter={index => console.warn(`current pos is: ${index}`)}
/>

Example 3 : SliderBox with image press handler and change slider height (default is 200)

SliderBox

<SliderBox
  images={this.state.images}
  sliderBoxHeight={400}
  onCurrentImagePressed={index => console.warn(`image ${index} pressed`)}
/>

Example 4 : SliderBox with custom width from parent. use onLayout function by calling it from root View of component.

onLayout = e => {
  this.setState({
    width: e.nativeEvent.layout.width
  });
};
render() {
    return (
        <View style={styles.container} onLayout={this.onLayout}>
            <SliderBox
                images={this.state.images}
                sliderBoxHeight={200}
                onCurrentImagePressed={index =>
                    console.warn(`image ${index} pressed`)
                }
                parentWidth={this.state.width}
            />
        </View>
    );
  }

Example 5 : SliderBox with custom dots color

SliderBox

<SliderBox
  images={this.state.images}
  sliderBoxHeight={200}
  onCurrentImagePressed={index => console.warn(`image ${index} pressed`)}
  dotColor="#FFEE58"
  inactiveDotColor="#90A4AE"
/>

Example 6 : SliderBox with custom dot style

SliderBox

<SliderBox
  images={this.state.images}
  sliderBoxHeight={200}
  onCurrentImagePressed={index => console.warn(`image ${index} pressed`)}
  dotColor="#FFEE58"
  inactiveDotColor="#90A4AE"
  dotStyle={{
    width: 15,
    height: 15,
    borderRadius: 15,
    marginHorizontal: 10,
    padding: 0,
    margin: 0
  }}
/>

Example 7 : SliderBox with change paging box padding (Vertical height from bottom of SliderBox) + add autoplay and circleLoop attribute for jump to the first image after swipe the last one.

SliderBox

<SliderBox
  images={this.state.images}
  sliderBoxHeight={200}
  onCurrentImagePressed={index => console.warn(`image ${index} pressed`)}
  dotColor="#FFEE58"
  inactiveDotColor="#90A4AE"
  paginationBoxVerticalPadding={20}
  autoplay
  circleLoop
/>

Example 8 : use Custom Image Component, customize pagination, image modes and dotStyles:

SliderBox

<SliderBox
  ImageComponent={FastImage}
  images={this.state.images}
  sliderBoxHeight={200}
  onCurrentImagePressed={index => console.warn(`image ${index} pressed`)}
  dotColor="#FFEE58"
  inactiveDotColor="#90A4AE"
  paginationBoxVerticalPadding={20}
  autoplay
  circleLoop
  resizeMethod={'resize'}
  resizeMode={'cover'}
  paginationBoxStyle={{
    position: "absolute",
    bottom: 0,
    padding: 0,
    alignItems: "center",
    alignSelf: "center",
    justifyContent: "center",
    paddingVertical: 10
  }}
  dotStyle={{
    width: 10,
    height: 10,
    borderRadius: 5,
    marginHorizontal: 0,
    padding: 0,
    margin: 0,
    backgroundColor: "rgba(128, 128, 128, 0.92)"
  }}
  ImageComponentStyle={{borderRadius: 15, width: '97%', marginTop: 5}}
  imageLoadingColor="#2196F3"
/>

Full-Component(Screen) Example:

import React, { Component } from "react";
import { StyleSheet, Text, View } from "react-native";

import { SliderBox } from "react-native-image-slider-box";

export default class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      images: [
        "https://source.unsplash.com/1024x768/?nature",
        "https://source.unsplash.com/1024x768/?water",
        "https://source.unsplash.com/1024x768/?girl",
        "https://source.unsplash.com/1024x768/?tree",
        require('./assets/images/girl.jpg'),
      ]
    };
  }

  render() {
    return (
      <View style={styles.container}>
        <SliderBox
          images={this.state.images}
          onCurrentImagePressed={index =>
            console.warn(`image ${index} pressed`)
          }
        />
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1
  }
});

Contribute

Note: Please Use example folder to run sample. The sample used components/SliderBox.js file to run. Please after editing this file copy changes to root dist/ folder too. The npm used dist/ folder. Thanks guys.

License MIT

Please subscribe and contribute with me to develop this lib


Notice:

This library use react-native-snap-carousel and make easier way to create image slider box with full customization ability.

See original Library https://github.com/archriss/react-native-snap-carousel

we dont edit or modify original library, we just use it with some additional style. (BSD 3 License)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].