Skip to content

Commit c0e98c0

Browse files
committed
first commit
1 parent de2ddef commit c0e98c0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

69 files changed

+10171
-1
lines changed

.gitignore

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
2+
# OSX
3+
#
4+
.DS_Store
5+
6+
# node.js
7+
#
8+
node_modules
9+
npm-debug.log
10+
yarn-error.log
11+

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
example

README.md

Lines changed: 63 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,64 @@
11
# react-native-animated-text-input
2-
React Native text input component with a floating label - using react-native-reanimated
2+
React Native text input component with a floating label - using react-native-reanimated.
3+
4+
## Peer Dependancies
5+
6+
```
7+
react-native-reanimated
8+
```
9+
10+
# Demo
11+
12+
![Alt text](/demo.gif?raw=true "AnimatedTextInput")
13+
14+
# Installation
15+
```
16+
yarn add react-native-animated-text-input
17+
```
18+
or
19+
```
20+
npm install --save react-native-animated-text-input
21+
```
22+
23+
# Usage
24+
```js
25+
import Input from 'react-native-animated-text-input';
26+
27+
<Input
28+
label={"User name"}
29+
value={userName}
30+
onChangeText={(t) => setUserName(t)}
31+
activeColor={'green'}
32+
activeLabelColor={'green'}
33+
containerStyle={{ marginVertical: 20 }}
34+
onBlur={() => !userName ? setUsernameError('User name is mandotory') : null}
35+
error={usernameError}
36+
/>
37+
```
38+
# Prop-types
39+
40+
| Prop name |Type |
41+
| ------------- | ------------- |
42+
| error | string - error text to display if any error available |
43+
| errorColor | color - color to decorate text input border and error text |
44+
| errorTextStyle | Text style - styles to override error text styles |
45+
| textInputStyle | Input style - style obj to oveerride text input styles |
46+
| containerStyle | View style - style to override textinput container (EG: padding , margins) |
47+
| labelTextStyle | Text style - styles to override label(placeholder) text style |
48+
| isKeyboardInput | boolean - default true, if false this will not open keboard, instead give a callback via onPress if this is false |
49+
| onPress | function - function to execute onPress in `isKeyboardInput = true` |
50+
| labelTextColor | color - default label(placeholder) color if labelTextStyle is not set |
51+
| activeLabelColor | color - default label(placeholder) color if labelTextStyle is not set and label is floaing on top(text input is active) |
52+
| activeColor | color - border color when the text input is active |
53+
| {...props} | TextInput props - All react native text input props |
54+
55+
# Example
56+
57+
checkout example/test directory and findout a react-native app.
58+
```
59+
yarn android
60+
```
61+
or
62+
```
63+
yarn ios
64+
```

animationUtils.js

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import {
2+
Easing,
3+
timing as retiming,
4+
Clock,
5+
Value,
6+
set,
7+
startClock,
8+
clockRunning,
9+
stopClock,
10+
cond,
11+
block,
12+
not,
13+
} from 'react-native-reanimated';
14+
15+
16+
export const timing = (params) => {
17+
const { clock, easing, duration, from, to } = {
18+
clock: new Clock(),
19+
easing: Easing.linear,
20+
duration: 250,
21+
from: 0,
22+
to: 1,
23+
...params
24+
};
25+
26+
const state = {
27+
finished: new Value(0),
28+
position: new Value(0),
29+
time: new Value(0),
30+
frameTime: new Value(0)
31+
};
32+
33+
const config = {
34+
toValue: new Value(0),
35+
duration,
36+
easing
37+
};
38+
39+
return block([
40+
onInit(clock, [set(config.toValue, to), set(state.frameTime, 0)]),
41+
animate({
42+
clock,
43+
fn: retiming,
44+
state,
45+
config,
46+
from
47+
})
48+
]);
49+
};
50+
51+
export const animate = ({
52+
fn,
53+
clock,
54+
state,
55+
config,
56+
from
57+
}) =>
58+
block([
59+
onInit(clock, [
60+
set(state.finished, 0),
61+
set(state.time, 0),
62+
set(state.position, from),
63+
startClock(clock)
64+
]),
65+
fn(clock, state, config),
66+
cond(state.finished, stopClock(clock)),
67+
state.position
68+
]);
69+
70+
export const onInit = (clock, sequence) => cond(not(clockRunning(clock)), sequence);

demo.gif

1.63 MB
Loading

example/test/.buckconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
[android]
3+
target = Google Inc.:Google APIs:23
4+
5+
[maven_repositories]
6+
central = https://repo1.maven.org/maven2

example/test/.eslintrc.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module.exports = {
2+
root: true,
3+
extends: '@react-native-community',
4+
};

example/test/.flowconfig

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
[ignore]
2+
; We fork some components by platform
3+
.*/*[.]android.js
4+
5+
; Ignore "BUCK" generated dirs
6+
<PROJECT_ROOT>/\.buckd/
7+
8+
; Ignore polyfills
9+
node_modules/react-native/Libraries/polyfills/.*
10+
11+
; These should not be required directly
12+
; require from fbjs/lib instead: require('fbjs/lib/warning')
13+
node_modules/warning/.*
14+
15+
; Flow doesn't support platforms
16+
.*/Libraries/Utilities/LoadingView.js
17+
18+
[untyped]
19+
.*/node_modules/@react-native-community/cli/.*/.*
20+
21+
[include]
22+
23+
[libs]
24+
node_modules/react-native/Libraries/react-native/react-native-interface.js
25+
node_modules/react-native/flow/
26+
27+
[options]
28+
emoji=true
29+
30+
esproposal.optional_chaining=enable
31+
esproposal.nullish_coalescing=enable
32+
33+
module.file_ext=.js
34+
module.file_ext=.json
35+
module.file_ext=.ios.js
36+
37+
munge_underscores=true
38+
39+
module.name_mapper='^react-native$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/react-native/react-native-implementation'
40+
module.name_mapper='^react-native/\(.*\)$' -> '<PROJECT_ROOT>/node_modules/react-native/\1'
41+
module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> '<PROJECT_ROOT>/node_modules/react-native/Libraries/Image/RelativeImageStub'
42+
43+
suppress_type=$FlowIssue
44+
suppress_type=$FlowFixMe
45+
suppress_type=$FlowFixMeProps
46+
suppress_type=$FlowFixMeState
47+
48+
suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)
49+
suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(<VERSION>\\)? *\\(site=[a-z,_]*react_native\\(_ios\\)?_\\(oss\\|fb\\)[a-z,_]*\\)?)\\)?:? #[0-9]+
50+
suppress_comment=\\(.\\|\n\\)*\\$FlowExpectedError
51+
52+
[lints]
53+
sketchy-null-number=warn
54+
sketchy-null-mixed=warn
55+
sketchy-number=warn
56+
untyped-type-import=warn
57+
nonstrict-import=warn
58+
deprecated-type=warn
59+
unsafe-getters-setters=warn
60+
inexact-spread=warn
61+
unnecessary-invariant=warn
62+
signature-verification-failure=warn
63+
deprecated-utility=error
64+
65+
[strict]
66+
deprecated-type
67+
nonstrict-import
68+
sketchy-null
69+
unclear-type
70+
unsafe-getters-setters
71+
untyped-import
72+
untyped-type-import
73+
74+
[version]
75+
^0.105.0

example/test/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.pbxproj -text

example/test/.gitignore

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# OSX
2+
#
3+
.DS_Store
4+
5+
# Xcode
6+
#
7+
build/
8+
*.pbxuser
9+
!default.pbxuser
10+
*.mode1v3
11+
!default.mode1v3
12+
*.mode2v3
13+
!default.mode2v3
14+
*.perspectivev3
15+
!default.perspectivev3
16+
xcuserdata
17+
*.xccheckout
18+
*.moved-aside
19+
DerivedData
20+
*.hmap
21+
*.ipa
22+
*.xcuserstate
23+
24+
# Android/IntelliJ
25+
#
26+
build/
27+
.idea
28+
.gradle
29+
local.properties
30+
*.iml
31+
32+
# node.js
33+
#
34+
node_modules/
35+
npm-debug.log
36+
yarn-error.log
37+
38+
# BUCK
39+
buck-out/
40+
\.buckd/
41+
*.keystore
42+
!debug.keystore
43+
44+
# fastlane
45+
#
46+
# It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
47+
# screenshots whenever they are needed.
48+
# For more information about the recommended setup visit:
49+
# https://docs.fastlane.tools/best-practices/source-control/
50+
51+
*/fastlane/report.xml
52+
*/fastlane/Preview.html
53+
*/fastlane/screenshots
54+
55+
# Bundle artifact
56+
*.jsbundle
57+
58+
# CocoaPods
59+
/ios/Pods/

example/test/.prettierrc.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
module.exports = {
2+
bracketSpacing: false,
3+
jsxBracketSameLine: true,
4+
singleQuote: true,
5+
trailingComma: 'all',
6+
};

example/test/.watchmanconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{}

example/test/App.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
* Sample React Native App
3+
* https://github.com/facebook/react-native
4+
*
5+
* @format
6+
* @flow
7+
*/
8+
9+
import React, { useState } from 'react';
10+
import {
11+
SafeAreaView,
12+
StyleSheet,
13+
ScrollView,
14+
StatusBar,
15+
} from 'react-native';
16+
17+
import Input from 'react-native-animated-text-input';
18+
19+
const App: () => React$Node = () => {
20+
const [userName, setUserName] = useState('')
21+
const [password, setPassword] = useState('')
22+
const [usernameError, setUsernameError] = useState('')
23+
return (
24+
<>
25+
<StatusBar barStyle="dark-content" />
26+
<SafeAreaView>
27+
<ScrollView
28+
contentInsetAdjustmentBehavior="automatic"
29+
contentContainerStyle={styles.scrollView}>
30+
31+
<Input
32+
label={"User name"}
33+
value={userName}
34+
onChangeText={(t) => setUserName(t)}
35+
activeColor={'green'}
36+
activeLabelColor={'green'}
37+
containerStyle={{ marginVertical: 20 }}
38+
onBlur={() => !userName ? setUsernameError('User name is mandotory') : null}
39+
error={usernameError}
40+
/>
41+
<Input
42+
label={"Password"}
43+
value={password}
44+
onChangeText={(t) => setPassword(t)}
45+
containerStyle={{ marginVertical: 20 }}
46+
/>
47+
</ScrollView>
48+
</SafeAreaView>
49+
</>
50+
);
51+
};
52+
53+
const styles = StyleSheet.create({
54+
scrollView: {
55+
padding: 30
56+
},
57+
});
58+
59+
export default App;

example/test/__tests__/App-test.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**
2+
* @format
3+
*/
4+
5+
import 'react-native';
6+
import React from 'react';
7+
import App from '../App';
8+
9+
// Note: test renderer must be required after react-native.
10+
import renderer from 'react-test-renderer';
11+
12+
it('renders correctly', () => {
13+
renderer.create(<App />);
14+
});

0 commit comments

Comments
 (0)