Socket
Socket
Sign inDemoInstall

react-native-expo-swipe-button

Package Overview
Dependencies
797
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    react-native-expo-swipe-button

a ready-to-use swipe button highly customizable


Version published
Weekly downloads
142
increased by94.52%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

react-native-expo-swipe-button

NPM Status

ezgif com-gif-maker(1)

A swipe button ready-to-use and highly customizable

Installations

npm install react-native-expo-swipe-button --save
yarn install react-native-expo-swipe-button

Usage

import { SwipeButton } from 'react-native-expo-swipe-button';

function Home(): JSX.Element {
  return (
    <View
      style={{
        flex: 1,
        justifyContent: 'center',
        backgroundColor: 'white',
        flexDirection: 'column',
      }}
    >
      <SwipeButton
        Icon={
          <MaterialIcons name="keyboard-arrow-right" size={50} color="white" />
        }
        onComplete={() => Alert.alert('Completed')}
        title="Swipe to complete"
        borderRadius={180}
        containerStyle={{ backgroundColor: 'gray' }}
        underlayTitle="Release to complete"
        underlayTitleStyle={{ color: 'white' }}
      />
      <SwipeButton
        Icon={
          <MaterialIcons name="keyboard-arrow-right" size={50} color="white" />
        }
        onComplete={() => {}}
        title="Gradient swipe"
        borderRadius={180}
        containerGradientProps={{
          colors: ['red', 'cyan'],
          start: [0, 0.5],
          end: [1, 0.5],
        }}
        underlayTitle="Release to complete"
        underlayStyle={{
          borderRadius: 180,
        }}
        underlayContainerGradientProps={{
          colors: ['green', 'yellow'],
          start: [0, 0.5],
          end: [1, 0.5],
        }}
      />
      <SwipeButton
        Icon={
          <MaterialIcons name="keyboard-arrow-right" size={50} color="white" />
        }
        onComplete={() => {}}
        title="Custom format swipe"
        borderRadius={25}
        containerStyle={{
          backgroundColor: 'transparent',
          borderWidth: 0,
          borderColor: 'red',
        }}
        underlayStyle={{
          borderRadius: 0,
          borderWidth: 5,
          borderColor: 'red',
          backgroundColor: 'transparent',
        }}
        underlayTitle="Release to complete"
        underlayTitleStyle={{ color: 'white' }}
        completeThresholdPercentage={50}
        goBackToStart
        titleElement={
          <LinearGradient
            colors={['red', 'yellow']}
            style={[styles.titleContainer, { height: 60, borderRadius: 25 }]}
            start={[0, 0.5]}
            end={[1, 0.5]}
          >
            <Text
              numberOfLines={2}
              allowFontScaling={false}
              style={[styles.title]}
            >
              Full custom swipe
            </Text>
          </LinearGradient>
        }
        underlayTitleElement={
          <LinearGradient
            colors={['pink', 'yellow']}
            style={[styles.titleContainer, { height: 60, borderRadius: 25 }]}
            start={[0, 0.5]}
            end={[1, 0.5]}
          >
            <Text
              numberOfLines={2}
              allowFontScaling={false}
              style={[styles.title]}
            >
              Release to complete
            </Text>
          </LinearGradient>
        }
      />
    </View>
  );
}

Properties

PropDescriptionTypeDefaultIs Required
disabledIf disabled is set to true it will not be possible to interact with the button.booleanfalseno
completeThresholdPercentageDetermine when onComplete should be invoked.number70%no
goBackToStartIf true, the circle will go back to the start position after swipe is completed.booleanfalseno
widthThe width of the component.number90%no
heightThe height of the component.number70no
circleSizedefine the size of the circle buttonnumber70no
underlayStyleThe styling of the underlay containerStyleProp<ViewStyle>{position: 'absolute',backgroundColor: '#152228',borderTopStartRadius: DEFAULT_BORDER_RADIUS,borderBottomStartRadius: DEFAULT_BORDER_RADIUS,borderBottomEndRadius: DEFAULT_BORDER_RADIUS, borderTopEndRadius: DEFAULT_BORDER_RADIUS }no
containerStyleStyling of the outer containerStyleProp<ViewStyle>{backgroundColor: 'white',alignSelf: 'center',justifyContent: 'center', marginVertical: 10 }no
iconContainerStyleThe styling of the buttonStyleProp<ViewStyle>{ position: 'absolute', backgroundColor: 'black', alignItems: 'center', justifyContent: 'center' }no
borderRadiusThe border radius of the container and the Iconnumberheight / 2no
containerGradientPropsgradient props for the container. Using this will actually use a linear gradient as view`{ colors?: string[]; } & Omit<LinearGradientProps, 'colors''style'>`none
underlayContainerGradientPropsgradient props for the underlayContainer. Using this will actually use a linear gradient as view`{ colors?: string[]; } & Omit<LinearGradientProps, 'colors''style'>`none
IconElement that should be displayed inside the buttonJSX.Elementnoneyes
circleBackgroundColorBackground color for the circlestringblackno
borderRadiusset border radius for the circlenumbernoneno
titleThe text that will be displayed in the containerstringnoneyes
titleExtraTextPropsAdditional props for the title textTextPropsnoneno
titleStyleAdditional styling for the title textStyleProp<TextStyle>{ color: 'black', fontSize: 16, maxWidth: '50%', textAlign: 'center' }no
titleContainerExtraViewPropsAdditional props for the title containerViewPropsnoneno
titleContainerStyleAdditional styling for the title containerStyleProp<ViewStyle>{ justifyContent: 'center', alignItems: 'center' }no
titleElementAn JSX element you can define to replace the title default component. Using this will omit the others title propsJSX.Elementnoneno
underlayTitleThe text that will be displayed in the underlay containerstring''no
underlayTitleExtraTextPropsAdditional props for the underlay title textTextPropsnoneno
underlayTitleStyleAdditional styling for the underlay title textStyleProp<TextStyle>{ color: 'black', fontSize: 16, maxWidth: '50%', textAlign: 'center' }no
underlayTitleContainerExtraViewPropsAdditional props for the underlay title containerViewPropsnoneno
underlayTitleContainerStyleAdditional styling for the underlay title containerStyleProp<ViewStyle>{ justifyContent: 'center' alignItems: 'center' }no
underlayTitleElementAn JSX element you can define to replace the underlay title default component. Using this will omit the others title propsJSX.Elementnoneno
onCompleteCallback that will be invoked when complete threshold has been reached() => voidnoneyes
onSwipeProgresscallback for swiping in progress(progress: number) => voidnoneno
onSwipeStartCallback that will be invoked when the user starts swiping() => voidnoneno
onSwipeEndCallback that will be invoked when the user ends swiping() => voidnoneno

A complete minimal example can be found Here.

Known issues

Contributing

See the contributing guide to learn how to contribute to the repository.

License

MIT

Keywords

FAQs

Last updated on 05 Oct 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc