Git Product home page Git Product logo

simformsolutionspvtltd / react-native-spinner-button Goto Github PK

View Code? Open in Web Editor NEW
124.0 7.0 14.0 25.22 MB

React Native button component with multiple animated spinners

License: MIT License

JavaScript 3.06% Java 10.71% Objective-C 3.44% Ruby 3.50% Shell 0.27% TypeScript 77.89% Objective-C++ 1.12%
react-native react-native-button react-native-buttons spinner react-native-spinner react-native-spinner-button react-native-ui-components react-native-ui-kitten react-native-loading loading-animations

react-native-spinner-button's Introduction

Tree-Selection

react-native-spinner-button npm version Android iOS MIT

React Native Spinner Button component library provides dynamic spinner buttons and ripple effects, enriching the user experience with smooth animations and intuitive feedback

Library is compatible with both Android and iOS platforms, offering a versatile solution to elevate your app's user interface with ease.

🎬 Preview

Example of react-native-spinner-button

Quick Access

Installation | Usage and Examples | Properties | Example Code | License

Getting Started

Here's how to get started with react-native-spinner-button in your React Native project:

Installation

1. Install the package

npm install react-native-spinner-button react-native-gradients react-native-svg

Using Yarn:

yarn add react-native-spinner-button react-native-gradients react-native-svg
2. Install cocoapods in the ios project
cd ios && pod install

Usage

import React, {useState, useCallback} from 'react';
import {StyleSheet, Text, View} from 'react-native';
import SpinnerButton from 'react-native-spinner-button';

const App: React.FC = () => {
  const [isLoading, setLoading] = useState<boolean>(false);

  const handleButtonPress = useCallback<() => void>(() => {
    setLoading(true);
    setTimeout(() => {
      setLoading(false);
    }, 3000);
  }, []);

  return (
    <View style={styles.screen}>
      {/* Your button component */}
      <SpinnerButton
        buttonStyle={styles.buttonStyle}
        isLoading={isLoading}
        onPress={() => {
          handleButtonPress();
        }}
        indicatorCount={10}
      >
        <Text style={styles.buttonText}>Default Or Ball SpinnerButton</Text>
      </SpinnerButton>
    </View>
  );
};

export default App;

const styles = StyleSheet.create({
  screen: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
  },
  buttonStyle: {
    borderRadius: 10,
    margin: 10,
    backgroundColor: '#893346',
  },
  buttonText: {
    fontSize: 20,
    textAlign: 'center',
    color: 'white',
  },
});

Example of Ripple Effect Button

import React from 'react';
import {StyleSheet, Text, View} from 'react-native';
import SpinnerButton from 'react-native-spinner-button';

const App: React.FC = () => {
  const buttonPress: () => void = () => {
    console.log('Button Clicked');
  };

  return (
    <View style={styles.screen}>
      <SpinnerButton
        animationType="ripple-effect"
        onPress={buttonPress}
        buttonStyle={styles.btnStyle}
        animatedDuration={400}>
        <Text style={styles.textStyle}>RippleButton</Text>
      </SpinnerButton>
    </View>
  );
};

const styles = StyleSheet.create({
  screen: {
    flex: 1,
    justifyContent: 'center',
  },
  btnStyle: {
    margin: 10,
    backgroundColor: '#893346',
  },
  textStyle: {
    fontSize: 20,
    textAlign: 'center',
    color: 'white',
  },
});

export default App;

🎬 Preview

Spinner Button Ripple Button
alt Default alt Modal

Properties

Props for the spinner button

Props Default Type Description
onPress - function The function to execute upon tapping the button
animationType null or undefined string Type of animation for the button and spinner, For more details about properties, refer react-native-animatable and also support "ripple-effect"
buttonStyle {height: 50} array or object Button styling
borderStyle - array or object It's a stylesheet object supporting all basic border properties like width, radius, color, and style (solid, dotted, and dashed), etc
spinnerColor white string The color of the spinner
spinnerType BallIndicator string Type of the spinner: BallIndicator, BarIndicator, DotIndicator, MaterialIndicator, PacmanIndicator, PulseIndicator, SkypeIndicator, UIActivityIndicator, WaveIndicator.
isLoading false boolean The flag to render a button or a spinner. false will render a button, and true will render a spinner
indicatorCount 8 number The count property of react-native-indicators
size 16 number The size of the dot in DotIndicator
spinnerOptions - object An object of waveMode for WaveIndicator. For more details about these properties, refer react-native-indicators
gradientType - string Gradients allow you to display more than one color with a smooth transition between the colors (think Instagram logo). Currently, we support two types of gradients: linear and radial
gradientColors - array Colors can be passed in different formats such as name, RGBA, hex, etc. The colors should be ordered in the way we want them to be displayed. For example, colors={[ "purple", "white" ]}, the gradient will transition from purple to white
gradientColoroffset - array An array of strings that defines where each color will stop in the gradient. These values are passed as a percentage of the entire gradient from 0% to 100% and must correspond to the colors passed in length and position. For example, with colors={[“red”, “yellow”, “green”]}, then we’ll have locations={['0%', '50%', '80%']}, with the first color (red) covering '0%' – '50%', the second (yellow) going from '50%' – '80%', and the third (green) from '80%' – '100%'
gradientColorAngle - number The gradient line's angle of direction. A value of 0deg is equivalent to the top; increasing values rotate clockwise from there. The angle range is from 0 to 360 degrees More detail to read
gradientRadialRadius - number This property is used for radial type gradients to set the radius of the radial gradient
gradientButtonHeight - number The size of the gradient component
radialRadiusx - string or number The x-coordinate of the center of the radial gradient
radialRadiusy - string or number The y-coordinate of the center of the radial gradient
radialRadiusRX - string or number The horizontal radius of the radial gradient defining the ellipse
radialRadiusRY - string or number The vertical radius of the radial gradient defining the ellipse
animatedDuration 300 number This property is used to define the duration of the animation, indicating how long it will take to execute the animation
customSpinnerComponent - node This prop allows you to add your own custom spinner component
animateWidth - number This prop is used to set the component width when the progress/loading starts. If you do not set this prop, it will identify the width and height which are minimum and then use that value
animateHeight - number This prop is used to set the component height when the progress/loading starts. If you do not set this prop, it will identify the width and height which are minimum and then use that value
animateRadius - number This prop is used to set the component radius when the progress/loading starts. If you do not set this prop, it will create a circle shape by default
isConnected true boolean The flag is used to identify the network connection, and based on the flag, the user iteration is set. false will render the button in disabled mode, and true will render the button in normal mode
disabled false boolean The flag to identify button enable/disable. true will render the button in disabled mode, and false will render the button in normal mode
disableStyle - array or object It's a stylesheet object. This style applies when identifying the button as disabled or if network connection is not available
gradientName - string These properties are used whenever you want to use a gradient but do not pass the gradientColors, gradientColorOffset, and gradientColorAngle properties
disableGradientColors - array Colors can be passed in different formats such as names, RGBA, hex, etc. The colors should be ordered in the way we want them to be displayed. For example, with colors={[ "purple", "white" ]}, the gradient will transition from purple to white
rippleColor rgba(255, 255, 255, .25) string Color of the ripple animation effect

Example

A full working example project is here Example

yarn
yarn example ios   // For ios
yarn example android   // For Android

Find this library useful? ❤️

Support it by joining stargazers for this repository.⭐

Bugs / Feature requests / Feedbacks

For bugs, feature requests, and discussion please use GitHub Issues, GitHub New Feature, GitHub Feedback

🤝 How to Contribute

We'd love to have you improve this library or fix a problem 💪 Check out our Contributing Guide for ideas on contributing.

Awesome Mobile Libraries

License

react-native-spinner-button's People

Contributors

besbash avatar gavinthomas1192 avatar jigar-s-simform avatar krunal-k-simformsolutions avatar krunal-kevadiya avatar maulikjoshi-simform avatar mobile-simformsolutions avatar mukesh-simform avatar nilesh-simform avatar rupal-simform avatar simform-solutions avatar yashsodha-simformsolutions avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-native-spinner-button's Issues

alignSelf Spinner

please set alignSelf:'center' in SpinnerComponent for all cases
switch (spinnerType) {
case 'BallIndicator':
return (
<View style={{ width: width, alignItems: 'center', justifyContent: 'center' }}> /// here for all //case
/// ..

);
case 'BarIndicator':
.....

for be center in show loading spinner

Update NPM package.

Hey I'd really like to give your team credit for this and not just fork it, then use it.
Can you update the npm package?

Thanks for you work!

Console.logs

Hey, love this package!
Was quick and worked out of box.

Can you remove these console . logs?

I can also do a PR but not for a couple days..
Spinner.js 44-45
Thanks!

I went ahead and did a PR
#8

componentWillReceiveProps has been renamed warning

I am using this button in my React Native application, but when I click the button I get the warning that componentWillReceiveProps has been renamed. Here is the full warning:

WARN  Warning: componentWillReceiveProps has been renamed, and is not recommended for use. See https://fb.me/react-async-component-lifecycle-hooks for details.

* Move data fetching code or side effects to componentDidUpdate.
* If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state
* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run `npx react-codemod rename-unsafe-lifecycles` in your project source folder.

Please update the following components: Indicator

Tried to register two views with the same name RNSVGRect, js engine: hermes

ERROR Error: Requiring module "node_modules\react-native-spinner-button\index.js", which threw an exception: Invariant Violation:
Tried to register two views with the same name RNSVGRect, js engine: hermes.
I Keept getting that error. here are dependancies.
"dependencies": {
"@react-navigation/bottom-tabs": "^6.5.11",
"@react-navigation/drawer": "^6.6.6",
"@react-navigation/native": "^6.1.9",
"@react-navigation/stack": "^6.3.20",
"nativewind": "^2.0.11",
"react": "18.1.0",
"react-native": "0.70.14",
"react-native-dimension": "^1.0.6",
"react-native-elements": "^3.4.3",
"react-native-feather": "^1.1.2",
"react-native-floating-label-input": "^1.4.3",
"react-native-gesture-handler": "^2.14.0",
"react-native-paper": "^5.11.4",
"react-native-reanimated": "^3.6.1",
"react-native-safe-area-context": "^4.7.4",
"react-native-screens": "^3.27.0",
"react-native-spinner-button": "^1.4.0",
"react-native-svg": "^14.1.0",
"react-native-vector-icons": "^10.0.2"
}
.

Unexpected token (10:4)

import SpinnerButton from 'react-native-spinner-button';

class Login extends Component {
  render() {
    return (
      // ... other stuff
      <SpinnerButton isLoading={ false  } >
        Login
      </SpinnerButton>
    );
  }
}
Failed to compile.

./node_modules/react-native-spinner-button/components/SpinnerButton.js
SyntaxError: ...\node_modules\react-native-spinner-button\components\SpinnerButton.js: Unexpected token (10:4)

   8 |   const { animationType, buttonStyle, onPress, isLoading, children } = props;
   9 |   return (
> 10 |     <Animatable.View animation={animationType || 'fadeIn'}>
     |     ^
  11 |       <TouchableOpacity
  12 |         style={[styles.defaultButtonStyle, buttonStyle]}
  13 |         onPress={onPress}
```

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.