├── .babelrc ├── .gitignore ├── LICENSE ├── README.md ├── lib └── index.js ├── package.json └── src └── index.js /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["react-native"] 3 | } 4 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Applikey Solutions 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Made by [Applikey Solutions](https://applikeysolutions.com) 2 | 3 | ![rocket](https://user-images.githubusercontent.com/10288457/29079755-b0809b58-7c66-11e7-8a68-004ccb227e5f.gif) 4 | 5 | # react-native-animated-check-mark 6 | 7 | # Table of Contents 8 | 1. [Purpose](#purpose) 9 | 2. [Supported Platforms](#supported-platforms) 10 | 3. [Installation](#installation) 11 | 4. [Basic Usage](#basic-usage) 12 | 5. [Properties](#properties) 13 | 6. [Demo](#demo) 14 | 7. [Release Notes](#release-notes) 15 | 8. [Contact Us](#contact-us) 16 | 9. [License](#license) 17 | 18 | # Purpose 19 | A small react component for animated cross-mark transformation. 20 | 21 | # Supported Platforms 22 | 23 | * iOS 24 | * Android 25 | 26 | # Installation 27 | 28 | ```bash 29 | $ npm i react-native-animated-check-mark --save 30 | ``` 31 | 32 | # Basic Usage 33 | 34 | - Install `react-native` first 35 | 36 | ```bash 37 | $ npm i react-native -g 38 | ``` 39 | 40 | - Initialization of a react-native project 41 | 42 | ```bash 43 | $ react-native init myproject 44 | ``` 45 | 46 | - Then, edit `myproject/index.ios.js`, like this: 47 | 48 | ```jsx 49 | import React, { Component } from 'react'; 50 | import { 51 | AppRegistry, 52 | StyleSheet, 53 | View, 54 | } from 'react-native'; 55 | 56 | import CrossMarker from 'react-native-animated-check-mark'; 57 | 58 | export default class myproject extends Component { 59 | render() { 60 | return ( 61 | 62 | 63 | 64 | console.log('To Cross')} 70 | onCrossPress={() => console.log('To Mark')} 71 | /> 72 | 73 | 74 | 75 | ); 76 | } 77 | } 78 | 79 | const styles = StyleSheet.create({ 80 | container: { 81 | flex: 1, 82 | justifyContent: 'center', 83 | alignItems: 'center', 84 | backgroundColor: '#F5FCFF', 85 | }, 86 | }); 87 | 88 | AppRegistry.registerComponent('myproject', () => myproject); 89 | ``` 90 | 91 | # Demo 92 | 93 | ![dropdown](https://user-images.githubusercontent.com/10288457/29079761-b4d590e6-7c66-11e7-8357-0ac6a642d523.gif) 94 | 95 | # Properties 96 | 97 | | Prop | Default | Type | Description | 98 | | :------------ |:---------------:| :---------------:| :-----| 99 | | color | #000 | `string` | Set the color of lines | 100 | | delay | 500 | `number` | Set the duration of transform (milliseconds) | 101 | | height | 30 | `number` | Set the line height | 102 | | width | 4 | `number` | Set the line width | 103 | | onCrossPress | - | `function` | fires, when component in cross mode is tapped | 104 | | onMarkPress | - | `function` | fires, when component in mark mode is tapped | 105 | 106 | # Release Notes 107 | 108 | Version 0.0.2 109 | 110 | - Release version. 111 | 112 | # Contact Us 113 | 114 | You can always contact us via github@applikey.biz We are open for any inquiries regarding our libraries and controls, new open-source projects and other ways of contributing to the community. If you have used our component in your project we would be extremely happy if you write us your feedback and let us know about it! 115 | 116 | # License 117 | 118 | The MIT License (MIT) 119 | 120 | Copyright © 2017 Applikey Solutions 121 | 122 | Permission is hereby granted free of charge to any person obtaining a copy of this software and associated documentation files (the "Software") to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 123 | 124 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 125 | 126 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 127 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 128 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 129 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 130 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 131 | THE SOFTWARE. 132 | -------------------------------------------------------------------------------- /lib/index.js: -------------------------------------------------------------------------------- 1 | Object.defineProperty(exports,"__esModule",{value:true});var _jsxFileName='src/index.js';var _createClass=function(){function defineProperties(target,props){for(var i=0;i { 39 | const { onMarkPress } = this.props; 40 | 41 | if (typeof onMarkPress === 'function') onMarkPress(); 42 | this.startAnimation(1); 43 | } 44 | 45 | toMark = () => { 46 | const { onCrossPress } = this.props; 47 | 48 | if (typeof onCrossPress === 'function') onCrossPress(); 49 | this.startAnimation(0); 50 | } 51 | 52 | changeMode = () => { 53 | this.cross ? this.toMark() : this.toCross(); 54 | this.cross = !this.cross; 55 | } 56 | 57 | renderLine = (angle, offset) => { 58 | const { color, height, width } = this.props; 59 | 60 | return 74 | } 75 | 76 | render () { 77 | const { height, width } = this.props, 78 | origin = { 79 | x: height, 80 | y: height / 2, 81 | } 82 | 83 | const leftLinePos = this.animatedValue.interpolate({ 84 | inputRange: [0, 1], 85 | outputRange: [origin.x - height / 3, origin.x] 86 | }); 87 | 88 | const rightLinePos = this.animatedValue.interpolate({ 89 | inputRange: [0, 1], 90 | outputRange: [origin.x + height / 3, origin.x] 91 | }); 92 | 93 | return 94 | 95 | {this.renderLine('-45 deg', leftLinePos)} 96 | {this.renderLine('45 deg', rightLinePos)} 97 | 98 | 99 | } 100 | } 101 | 102 | CrossMarker.propTypes = { 103 | color: PropTypes.string, 104 | delay: PropTypes.number, 105 | height: PropTypes.number, 106 | width: PropTypes.number, 107 | onCrossPress: PropTypes.func, 108 | onMarkPress: PropTypes.func, 109 | onCrossTransformed: PropTypes.func, 110 | onMarkTransformed: PropTypes.func, 111 | } 112 | 113 | CrossMarker.defaultProps = { 114 | color: '#000', 115 | delay: 500, 116 | height: 30, 117 | width: 4, 118 | onCrossPress: () => {}, 119 | onMarkPress: () => {}, 120 | } 121 | --------------------------------------------------------------------------------