MCPcopy Index your code
hub / github.com/leecade/react-native-swiper

github.com/leecade/react-native-swiper @v1.6.0-nightly.5 sqlite

repository ↗ · DeepWiki ↗ · release v1.6.0-nightly.5 ↗
44 symbols 89 edges 20 files 2 documented · 5%
README

react-native-swiper

The best Swiper component for React Native.

JavaScript Style Guide npm version npm version PR Stats Issue Stats Join the chat

react-native-swiper

Roadmap

see: ROADMAP.md

Changelogs

  • [1.6.0-nightly]
  • Dependency
    • Remove ViewPagerAndroid, use ScrollView #1009
  • TypeScript
    • correct the wrong types #1000
    • Add missing scrollBy TypeScript definition #931
  • New Feature
    • add scrollTo #831
    • Added prop to disable the PrevButton #749
    • Optionally render page #1004
  • Bug Fix

    • ES6 and CommonJS compatibility #717
    • Solves the issue of state messing up when parent component calls setState #939
    • replay when autoplay is setted to true #1002
  • [1.5.6]

  • Fix #16, #36, #371, #410, #411, #422, #468 Fix landscape orientation auto resize! (thanks @ahmed3mar, @timmywil)

  • Add containerStyle prop to customize the view container.

  • [1.5.5]

  • Update: using PropTypes from prop-types and Change View.propTypes to ViewPropTypes

  • [1.5.4]

  • Added easily accessible pagination point manipulation: use dotColor / activeDotColor and dotStyle / activeDotStyle (thanks @denizs)

  • Added scrollEnabled prop to documentation (thanks @ibandominguez)

  • [1.5.3]

  • Add loadMinimalLoader prop to customize <ActivityIndicator /> (thanks @Exilz)

  • Disable autoplay timer when prop changes to false (thanks @dizlexik)
  • Special thanks to @hypatiah for fixed some grammatical errors in README

  • [1.5.2]

  • Add yarn lock
  • Fix jitter when quickly swiping back and forth between pages (iOS) (thanks @nemophrost)
  • The first webview always reloaded when injecting the rest of the children (thanks @eosterberg)

see more: CHANGELOG.md

Show Cases

Try these cases by yourself very easy, Just open examples/ios/swiper.xcodeproj in Xcode, then press Cmd + R; you may edit examples/index.ios.js for switch cases.

examples/components/Basic

examples/components/Swiper

examples/components/SwiperNumber

examples/components/Phone

examples/components/LoadMinimal

Getting Started

Installation

v1.5.14

$ npm i react-native-swiper --save

v1.6.0-nightly

npm i --save react-native-swiper@nightly

Basic Usage

  • Install react-native first
$ npm i react-native-cli -g
  • Initialization of a react-native project
$ react-native init myproject
  • Then, edit myproject/index.ios.js, like this:
import React, { Component } from 'react'
import { AppRegistry, StyleSheet, Text, View } from 'react-native'

import Swiper from 'react-native-swiper'

const styles = StyleSheet.create({
  wrapper: {},
  slide1: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#9DD6EB'
  },
  slide2: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#97CAE5'
  },
  slide3: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#92BBD9'
  },
  text: {
    color: '#fff',
    fontSize: 30,
    fontWeight: 'bold'
  }
})

export default class SwiperComponent extends Component {
  render() {
    return (
      <Swiper style={styles.wrapper} showsButtons={true}>
        <View style={styles.slide1}>
          <Text style={styles.text}>Hello Swiper</Text>
        </View>
        <View style={styles.slide2}>
          <Text style={styles.text}>Beautiful</Text>
        </View>
        <View style={styles.slide3}>
          <Text style={styles.text}>And simple</Text>
        </View>
      </Swiper>
    )
  }
}

AppRegistry.registerComponent('myproject', () => SwiperComponent)

Properties

Basic

Prop Default Type Description
horizontal true bool If true, the scroll view's children are arranged horizontally in a row instead of vertically in a column.
loop true bool Set to false to disable continuous loop mode.
index 0 number Index number of initial slide.
showsButtons false bool Set to true make control buttons visible.
autoplay false bool Set to true enable auto play mode.
onIndexChanged (index) => null func Called with the new index when the user swiped

Custom basic style & content

Prop Default Type Description
width - number If no specify default enable fullscreen mode by flex: 1.
height - number If no specify default fullscreen mode by flex: 1.
style {...} style See default style in source.
containerStyle {...} style See default container style in source.
loadMinimal false bool Only load current index slide , loadMinimalSize slides before and after.
loadMinimalSize 1 number see loadMinimal
loadMinimalLoader <ActivityIndicator /> element Custom loader to display when slides aren't loaded

Pagination

Prop Default Type Description
showsPagination true bool Set to true make pagination visible.
paginationStyle {...} style Custom styles will merge with the default styles.
renderPagination - function Complete control how to render pagination with three params (index, total, context) ref to this.state.index / this.state.total / this, For example: show numbers instead of dots.
dot <View style={{backgroundColor:'rgba(0,0,0,.2)', width: 8, height: 8,borderRadius: 4, marginLeft: 3, marginRight: 3, marginTop: 3, marginBottom: 3,}} /> element Allow custom the dot element.
activeDot <View style={{backgroundColor: '#007aff', width: 8, height: 8, borderRadius: 4, marginLeft: 3, marginRight: 3, marginTop: 3, marginBottom: 3,}} /> element Allow custom the active-dot element.
dotStyle - object Allow custom the active-dot element.
dotColor - string Allow custom the active-dot element.
activeDotColor - string Allow custom the active-dot element.
activeDotStyle - object Allow custom the active-dot element.

Autoplay

Prop Default Type Description
autoplay true bool Set to true enable auto play mode.
autoplayTimeout 2.5 number Delay between auto play transitions (in second).
autoplayDirection true bool Cycle

Extension points exported contracts — how you extend this code

SwiperStates (Interface)
(no doc)
index.d.ts
SlideState (Interface)
(no doc)
examples/components/LoadMinimal/index.tsx
SwiperInternals (Interface)
(no doc)
index.d.ts
SlideActions (Interface)
(no doc)
examples/components/LoadMinimal/index.tsx
SwiperProps (Interface)
(no doc)
index.d.ts

Core symbols most depended-on inside this repo

getReactNativeHost
called by 1
examples/android/app/src/main/java/com/examples/MainApplication.java
initializeFlipper
called by 1
examples/android/app/src/main/java/com/examples/MainApplication.java
UNSAFE_componentWillReceiveProps
called by 0
src/index.js
componentDidMount
called by 0
src/index.js
componentWillUnmount
called by 0
src/index.js
UNSAFE_componentWillUpdate
called by 0
src/index.js
componentDidUpdate
called by 0
src/index.js
initState
called by 0
src/index.js

Shape

Method 14
Function 13
Class 12
Interface 5

Languages

TypeScript68%
Java32%

Modules by API surface

src/index.js9 symbols
examples/android/app/src/main/java/com/examples/MainApplication.java7 symbols
index.d.ts5 symbols
examples/components/Dynamic/index.js5 symbols
examples/android/app/src/debug/java/com/examples/ReactNativeFlipper.java5 symbols
examples/components/PhotoView/index.js4 symbols
examples/components/LoadMinimal/index.tsx4 symbols
examples/android/app/src/main/java/com/examples/MainActivity.java2 symbols
examples/components/SwiperNumber/index.js1 symbols
examples/components/Swiper/index.js1 symbols
examples/components/Phone/index.js1 symbols

Dependencies from manifests, versioned

@babel/core7.6.0 · 1×
@babel/runtime7.6.0 · 1×
@types/react16.9.2 · 1×
@types/react-native0.60.15 · 1×
babel-eslint8.0.1 · 1×
babel-jest24.9.0 · 1×
eslint6.4.0 · 1×
jest24.9.0 · 1×
metro-react-native-babel-preset0.56.0 · 1×
prop-types15.5.10 · 1×
react16.8.6 · 1×

For agents

$ claude mcp add react-native-swiper \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact