3.0.1 • Published 3 months ago

rn-swipe-button v3.0.1

Weekly downloads
1,347
License
MIT
Repository
github
Last release
3 months ago

React Native Swipe Button Component

star this repo fork this repo NPM Version npm total downloads Npm Downloads Socke Score Contribuutions Welcome

Description

  • Highly customizable "swipe to submit" category button.
  • Generally used in exchange of regular buttons to avoid accidental taps.
  • This component works for Android, iOS and Web application.
  • Supports RTL out of the box.
  • Provides accessiblity support.
  • Component has more than 85% test coverge.
  • 100% TypeScript
  • MIT License

Installation

npm install rn-swipe-button --save

# OR

yarn add rn-swipe-button

react-native compatibility

rn-swipe-buttonreact-nativereact
<= v1.3.8>= 0.60.5>= 16.8.6
>= v2.0.0>= 0.70.0>= 18.1.0

Usage

import SwipeButton from 'rn-swipe-button'; 

<SwipeButton />
import React, { useState } from 'react';
import { View, Text } from 'react-native';

import SwipeButton from 'rn-swipe-button';


function Example() {
  let forceResetLastButton: any = null;
  let forceCompleteCallback: any = null;
  const [finishSwipeAnimDuration, setFinishSwipeAnimDuration] = useState(400)
  
  const forceCompleteButtonCallback = useCallback(() => {
    setFinishSwipeAnimDuration(0)
    forceCompleteCallback()
  }, [])

  const forceResetButtonCallback = useCallback(() => {
    forceResetLastButton()
    setInterval(() => setFinishSwipeAnimDuration(400) , 1000)
  }, [])
  
  return (
    <View>
      <SwipeButton
        disableResetOnTap
        forceReset={ (reset: any) => {
          forceResetLastButton = reset
        }}
        finishRemainingSwipeAnimationDuration={finishSwipeAnimDuration}
        forceCompleteSwipe={ (forceComplete: any) => {
          forceCompleteCallback = forceComplete
        }}
        railBackgroundColor="#9fc7e8"
        railStyles={{
          backgroundColor: '#147cbb',
          borderColor: '#880000FF',
        }}
        thumbIconBackgroundColor="#FFFFFF"
        thumbIconImageSource={require('@/assets/images/react-logo.png')}
        title="Slide to unlock"
      />
      <View style={{ marginBottom: 5, flexDirection: 'row', justifyContent: 'center' }}>
        <Text onPress={forceCompleteButtonCallback}>Force Complete</Text>
        <Text onPress={forceResetButtonCallback}>Force Reset</Text>
      </View>
    </View>
  )
};

Note

Contributing

I request more developers from the open-source community to contributing to improve this project. You can find the work by visiting the project associated with this repository. You can find issues related to defects, new feature requests and dev only related tasks like writing unit tests.

2.0.3

5 months ago

2.0.2

5 months ago

2.1.0

4 months ago

2.0.1

5 months ago

2.0.0

7 months ago

3.0.1

3 months ago

3.0.0

4 months ago

1.3.8

3 years ago

1.3.7

3 years ago

1.3.6

4 years ago

1.3.5

4 years ago

1.3.4

4 years ago

1.3.3

4 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.9

5 years ago

1.2.8

5 years ago

1.2.7

5 years ago

1.2.6

5 years ago

1.2.5

5 years ago

1.2.4

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago