Skip to content

Commit dcd99ba

Browse files
author
sqlProvider
committed
[RNAnimatableButton] initial
0 parents  commit dcd99ba

File tree

13 files changed

+1221
-0
lines changed

13 files changed

+1221
-0
lines changed

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules/
2+
.expo/
3+
npm-debug.*
4+
build
5+
dist

.vscode/launch.json

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
// Use IntelliSense to learn about possible attributes.
3+
// Hover to view descriptions of existing attributes.
4+
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5+
"version": "0.2.0",
6+
"configurations": [
7+
{
8+
"name": "Debug Android",
9+
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
10+
"type": "reactnative",
11+
"request": "launch",
12+
"platform": "android",
13+
"sourceMaps": true,
14+
"outDir": "${workspaceRoot}/.vscode/.react"
15+
},
16+
{
17+
"name": "Debug iOS",
18+
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
19+
"type": "reactnative",
20+
"request": "launch",
21+
"platform": "ios",
22+
"sourceMaps": true,
23+
"outDir": "${workspaceRoot}/.vscode/.react"
24+
},
25+
{
26+
"name": "Attach to packager",
27+
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
28+
"type": "reactnative",
29+
"request": "attach",
30+
"sourceMaps": true,
31+
"outDir": "${workspaceRoot}/.vscode/.react"
32+
},
33+
{
34+
"name": "Debug in Exponent",
35+
"program": "${workspaceRoot}/.vscode/launchReactNative.js",
36+
"type": "reactnative",
37+
"request": "launch",
38+
"platform": "exponent",
39+
"sourceMaps": true,
40+
"outDir": "${workspaceRoot}/.vscode/.react"
41+
}
42+
]
43+
}

.vscode/settings.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"react-native": {
3+
"packager": {
4+
"port": 19001
5+
}
6+
}
7+
}

README.md

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
## react-native-animatable-button
2+
[![npm version](https://badge.fury.io/js/react-native-animatable-button.svg)](https://badge.fury.io/js/react-native-animatable-button)
3+
## Installation
4+
```
5+
npm install react-native-animatable-button --save
6+
```
7+
8+
## Overview
9+
10+
- [x] States
11+
- [x] Opacity animation
12+
- [x] Tap animations
13+
- [x] Fully customizable
14+
15+
## Props
16+
17+
### Button Props
18+
19+
| Props | Type | Description | Required | Default |
20+
|:---------------------|:----------------------------|:-----------------------------------|:-------------|:----------------------------|
21+
| accessibilityLabel | string | custom access label | not required | reactNativeAnimetableButton
22+
| buttonContainerStyle | Object<ViewSyle> | must be provided Object not STYLE | not required | see below
23+
| selectedState | string | selected id of provided states | not required | default
24+
| states | [key: string]: IButtonState | state object | not required | default state
25+
| disabled | boolean | enable/disable button | not required | false
26+
| touchFeedbaack | boolean | enable/disable tap opacity animate | not required | true
27+
| touchFeedbaackDelay | boolean | set delayPressIn prop of TOpacity | not required | 0
28+
29+
### Button Animation Props
30+
31+
| Props | Type | Description | Required | Default |
32+
|:---------------------------|:----------------------------|:-----------------------------------|:-------------|:----------------------------------|
33+
| animationDelay | number | delay of animations | not required | 0
34+
| animationDuration | number | animation duration time | not required | 400
35+
| animationEasing | EasingFunction | easing options | not required | Easing.bezier(0.4, 0.2, 0.4, 1.3)
36+
| onPressAnimationEnable | boolean | tap animation config | not required | true
37+
| onPressAnimationScaleValue | number | number of scale to | not required | 1.05
38+
| onPressAnimationType | button - inside | scale all button or inside | not required | button
39+
| startAnimationDelay | number | delay of start animation | not required | 0
40+
| startAnimationDuration | number | animation duration time for start | not required | 400
41+
| startAnimationEnable | boolean | enable/disable start animation | not required | true
42+
| backgroundAnimation | animated - slide | set background option | not required | animated
43+
44+
45+
### Button State Props
46+
47+
| Props | Type | Description | Required | Default |
48+
|:------------------------------|:----------------------------|:-----------------------------------|:-------------|:----------------------------------|
49+
| buttonInsideContainerStyle | Object<ViewSyle> | must be provided Object not STYLE | not required | see below
50+
| icon | ImageURISource - any | icon uri or source | not required | -
51+
| iconStyle | ImageStyle | icon style | not required | see below
52+
| iconPosition | left - right | position of icon | not required | left
53+
| text | string | button text | not required | -
54+
| textStyle | TextStyle | text style | not required | see below
55+
| spinner | boolean | enable/disable spinner | not required | false
56+
| spinnerProps | ActivityIndicatorProperties | spinner Props | not required | -
57+
| syncIconAndTextAnimation | boolean | enable/disable animation diff | not required | false
58+
| asyncIconAndTextAnimationDiff | number [0 - 100] | percent of diff | not required | 50
59+
60+
61+
62+
#### buttonContainerStyle
63+
```javascript
64+
{
65+
backgroundColor: 'rgba(0,0,0,0)',
66+
borderRadius: 5,
67+
borderWidth: 1,
68+
height: ButtonSize.height,
69+
overflow: 'hidden'
70+
}
71+
```
72+
73+
#### buttonInsideContainerStyle
74+
```javascript
75+
{
76+
alignItems: 'center',
77+
backgroundColor: 'rgba(0,0,0,0)',
78+
flexDirection: 'row',
79+
height: ButtonSize.height,
80+
justifyContent: 'center',
81+
overflow: 'hidden',
82+
paddingHorizontal: 10
83+
}
84+
```
85+
86+
#### textStyle
87+
```javascript
88+
{
89+
paddingHorizontal: 5
90+
}
91+
```
92+
93+
#### iconStyle
94+
```javascript
95+
{
96+
flex: 1,
97+
resizeMode: 'contain'
98+
}
99+
```
100+
101+
## Note
102+
Master props and state props are combined when provided.
103+
104+
## Usage example
105+
```javascript
106+
constructor() {
107+
super();
108+
109+
this.state = {
110+
activeState: 'idle2'
111+
}
112+
}
113+
114+
render () {
115+
<Button
116+
touchFeedback={false}
117+
onPress={this.onPress.bind(this)}
118+
selectedState={this.state.activeState}
119+
buttonContainerStyle={{
120+
height: 40
121+
}}
122+
buttonInsideContainerStyle={{
123+
backgroundColor: 'rgba(100,100,100,0.5)'
124+
}}
125+
onPress={() => {
126+
console.log('master pressed');
127+
if (this.state.activeState === 'idle2') this.setState({ activeState: 'idle' });
128+
}}
129+
states={{
130+
laodList: {
131+
text:"Load List",
132+
buttonInsideContainerStyle:{
133+
backgroundColor: 'rgba(255,0,0,0.5)'
134+
},
135+
onPress: () => {
136+
console.log('loadList pressed');
137+
this.setState({ activeState: 'loading' })
138+
139+
return false;
140+
}
141+
},
142+
// when tap laodList logs => loadList pressed; master pressed
143+
144+
loading: {
145+
text:"loading",
146+
buttonInsideContainerStyle:{
147+
backgroundColor: 'rgba(0,255,0,0.5)'
148+
},
149+
spinner: true,
150+
onPress: () => { console.log('loading pressed'); return true; }
151+
},
152+
// when tap loading logs => loading pressed;
153+
154+
idle: {
155+
text:"idle",
156+
onPress: () => {
157+
console.log('idle pressed');
158+
this.setState({ activeState: 'loadList' })
159+
}
160+
},
161+
// when tap idle logs => idle pressed; master pressed
162+
163+
idle2: {
164+
text:"idle2",
165+
}
166+
// when tap idle2 logs => master pressed
167+
}}
168+
/>
169+
}
170+
```
171+
172+
### Description
173+
if you are return `false` or `undefined` in sub onPress functions when call master onPress function.
174+

build.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
rm -rf dist/ &&
3+
rm -rf build/ &&
4+
echo "rm -rf dist/ build/" &&
5+
tsc &&
6+
echo "tsc" &&
7+
cp -R ./build ./dist &&
8+
echo "cp -R ./build ./dist" &&
9+
cp ./package.json ./dist/ &&
10+
echo "cp ./package.json ./dist/" &&
11+
cp ./README.md ./dist/ &&
12+
echo "cp ./README.md ./dist/" &&
13+
cp ./src/index.d.ts ./dist/ &&
14+
echo "cp ./src/index.d.ts ./dist/" &&
15+
cp ./src/IButton.d.ts ./dist/

package.json

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{
2+
"name": "react-native-animatable-button",
3+
"version": "1.0.0",
4+
"private": true,
5+
"main": "index.js",
6+
"typings": "index.d.ts",
7+
"scripts": {},
8+
"dependencies": {
9+
"tinycolor2": "^1.4.1"
10+
},
11+
"devDependencies": {
12+
"@types/react": "16.0.2",
13+
"@types/react-native": "0.49.5",
14+
"@types/tinycolor2": "^1.4.0",
15+
"tslint": "^5.8.0",
16+
"typescript": "^2.6.1"
17+
},
18+
"repository": {
19+
"type": "git",
20+
"url": "git+https://github.com/sqlProvider/react-native-animatable-button.git"
21+
},
22+
"keywords": [
23+
"react",
24+
"react-native",
25+
"button",
26+
"animated",
27+
"animatable-button",
28+
"react-native-animatable-button"
29+
],
30+
"author": {
31+
"name": "Semih KEŞKEK",
32+
"email": "keskeksmh@gmail.com",
33+
"url": "http://github.com/sqlProvider"
34+
},
35+
"license": "ISC",
36+
"bugs": {
37+
"url": "https://github.com/sqlProvider/react-native-animatable-button/issues"
38+
},
39+
"homepage": "https://github.com/sqlProvider/react-native-animatable-button#readme"
40+
}

0 commit comments

Comments
 (0)