Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
[![travis][travis-badge]][travis-url]
[![codeclimate][codeclimate-badge]][codeclimate-url]

This is fork from react-native-material-textfield it has solved issues of proptypes and native driver warning

Material texfield with consistent behaviour on iOS and Android

![example][example-url]
Expand All @@ -41,7 +43,12 @@ Material texfield with consistent behaviour on iOS and Android
## Installation

```bash
npm install --save react-native-material-textfield
npm install Uzef1997/react-native-material-textfield
```
To use it with typescript

```bash
npm install @types/react-native-material-textfield
```

## Usage
Expand Down
21 changes: 0 additions & 21 deletions src/components/affix/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,6 @@ export default class Affix extends PureComponent {
numberOfLines: 1,
};

static propTypes = {
numberOfLines: PropTypes.number,
style: Animated.Text.propTypes.style,

color: PropTypes.string.isRequired,
fontSize: PropTypes.number.isRequired,

type: PropTypes
.oneOf(['prefix', 'suffix'])
.isRequired,

labelAnimation: PropTypes
.instanceOf(Animated.Value)
.isRequired,

children: PropTypes.oneOfType([
PropTypes.arrayOf(PropTypes.node),
PropTypes.node,
]),
};

render() {
let { labelAnimation, style, children, type, fontSize, color } = this.props;

Expand Down
9 changes: 0 additions & 9 deletions src/components/counter/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@ import { Text } from 'react-native';
import styles from './styles';

export default class Counter extends PureComponent {
static propTypes = {
count: PropTypes.number.isRequired,
limit: PropTypes.number,

baseColor: PropTypes.string.isRequired,
errorColor: PropTypes.string.isRequired,

style: Text.propTypes.style,
};

render() {
let { count, limit, baseColor, errorColor, style } = this.props;
Expand Down
2 changes: 1 addition & 1 deletion src/components/field-outlined/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default class OutlinedTextField extends TextField {
super(props);

this.onTextLayout = this.onTextLayout.bind(this);
this.state.labelWidth = new Animated.Value(0);
this.state.labelWidth = new Animated.Value(0,{useNativeDriver: true});
}

onTextLayout({ nativeEvent: { lines } }) {
Expand Down
83 changes: 42 additions & 41 deletions src/components/field/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,61 +65,61 @@ export default class TextField extends PureComponent {
disabled: false,
};

static propTypes = {
...TextInput.propTypes,
// static propTypes = {
// ...TextInput.propTypes,

animationDuration: PropTypes.number,
// animationDuration: PropTypes.number,

fontSize: PropTypes.number,
labelFontSize: PropTypes.number,
// fontSize: PropTypes.number,
// labelFontSize: PropTypes.number,

contentInset: PropTypes.shape({
top: PropTypes.number,
label: PropTypes.number,
input: PropTypes.number,
left: PropTypes.number,
right: PropTypes.number,
bottom: PropTypes.number,
}),
// contentInset: PropTypes.shape({
// top: PropTypes.number,
// label: PropTypes.number,
// input: PropTypes.number,
// left: PropTypes.number,
// right: PropTypes.number,
// bottom: PropTypes.number,
// }),

labelOffset: Label.propTypes.offset,
// labelOffset: Label.propTypes.offset,

labelTextStyle: Text.propTypes.style,
titleTextStyle: Text.propTypes.style,
affixTextStyle: Text.propTypes.style,
// labelTextStyle: Text.propTypes.style,
// titleTextStyle: Text.propTypes.style,
// affixTextStyle: Text.propTypes.style,

tintColor: PropTypes.string,
textColor: PropTypes.string,
baseColor: PropTypes.string,
// tintColor: PropTypes.string,
// textColor: PropTypes.string,
// baseColor: PropTypes.string,

label: PropTypes.string,
title: PropTypes.string,
// label: PropTypes.string,
// title: PropTypes.string,

characterRestriction: PropTypes.number,
// characterRestriction: PropTypes.number,

error: PropTypes.string,
errorColor: PropTypes.string,
// error: PropTypes.string,
// errorColor: PropTypes.string,

lineWidth: PropTypes.number,
activeLineWidth: PropTypes.number,
disabledLineWidth: PropTypes.number,
// lineWidth: PropTypes.number,
// activeLineWidth: PropTypes.number,
// disabledLineWidth: PropTypes.number,

lineType: Line.propTypes.lineType,
disabledLineType: Line.propTypes.lineType,
// lineType: Line.propTypes.lineType,
// disabledLineType: Line.propTypes.lineType,

disabled: PropTypes.bool,
// disabled: PropTypes.bool,

formatText: PropTypes.func,
// formatText: PropTypes.func,

renderLeftAccessory: PropTypes.func,
renderRightAccessory: PropTypes.func,
// renderLeftAccessory: PropTypes.func,
// renderRightAccessory: PropTypes.func,

prefix: PropTypes.string,
suffix: PropTypes.string,
// prefix: PropTypes.string,
// suffix: PropTypes.string,

containerStyle: (ViewPropTypes || View.propTypes).style,
inputContainerStyle: (ViewPropTypes || View.propTypes).style,
};
// containerStyle: (ViewPropTypes || View.propTypes).style,
// inputContainerStyle: (ViewPropTypes || View.propTypes).style,
// };

static inputContainerStyle = styles.inputContainer;

Expand Down Expand Up @@ -175,8 +175,8 @@ export default class TextField extends PureComponent {
text,
error,

focusAnimation: new Animated.Value(focusState),
labelAnimation: new Animated.Value(labelState),
focusAnimation: new Animated.Value(focusState,{useNativeDriver: false}),
labelAnimation: new Animated.Value(labelState, {useNativeDriver: false}),

receivedFocus: false,

Expand Down Expand Up @@ -223,6 +223,7 @@ export default class TextField extends PureComponent {

let options = {
toValue: this.focusState(),
useNativeDriver: false,
duration,
};

Expand Down
14 changes: 0 additions & 14 deletions src/components/helper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,6 @@ import { Animated } from 'react-native';
import styles from './styles';

export default class Helper extends PureComponent {
static propTypes = {
title: PropTypes.string,
error: PropTypes.string,

disabled: PropTypes.bool,

style: Animated.Text.propTypes.style,

baseColor: PropTypes.string,
errorColor: PropTypes.string,

focusAnimation: PropTypes.instanceOf(Animated.Value),
};

constructor(props) {
super(props);

Expand Down
36 changes: 0 additions & 36 deletions src/components/label/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,6 @@ export default class Label extends PureComponent {
restricted: false,
};

static propTypes = {
numberOfLines: PropTypes.number,

disabled: PropTypes.bool,
restricted: PropTypes.bool,

fontSize: PropTypes.number.isRequired,
activeFontSize: PropTypes.number.isRequired,

baseColor: PropTypes.string.isRequired,
tintColor: PropTypes.string.isRequired,
errorColor: PropTypes.string.isRequired,

focusAnimation: PropTypes
.instanceOf(Animated.Value)
.isRequired,

labelAnimation: PropTypes
.instanceOf(Animated.Value)
.isRequired,

contentInset: PropTypes.shape({
label: PropTypes.number,
}),

offset: PropTypes.shape({
x0: PropTypes.number,
y0: PropTypes.number,
x1: PropTypes.number,
y1: PropTypes.number,
}),

style: Animated.Text.propTypes.style,
label: PropTypes.string,
};

render() {
let {
label,
Expand Down
18 changes: 0 additions & 18 deletions src/components/line/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,6 @@ export default class Line extends PureComponent {
restricted: false,
};

static propTypes = {
lineType: lineTypes,
disabledLineType: lineTypes,

disabled: PropTypes.bool,
restricted: PropTypes.bool,

tintColor: PropTypes.string,
baseColor: PropTypes.string,
errorColor: PropTypes.string,

lineWidth: PropTypes.number,
activeLineWidth: PropTypes.number,
disabledLineWidth: PropTypes.number,

focusAnimation: PropTypes.instanceOf(Animated.Value),
};

static getDerivedStateFromProps(props, state) {
let { lineWidth, activeLineWidth, disabledLineWidth } = props;

Expand Down
29 changes: 2 additions & 27 deletions src/components/outline/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import PropTypes from 'prop-types';
import React, { Fragment, PureComponent } from 'react';
import { View, Animated, I18nManager } from 'react-native';

Expand All @@ -11,30 +10,6 @@ export default class Line extends PureComponent {
restricted: false,
};

static propTypes = {
lineType: PropTypes.oneOf(['solid', 'none']),

disabled: PropTypes.bool,
restricted: PropTypes.bool,

tintColor: PropTypes.string,
baseColor: PropTypes.string,
errorColor: PropTypes.string,

lineWidth: PropTypes.number,
activeLineWidth: PropTypes.number,
disabledLineWidth: PropTypes.number,

focusAnimation: PropTypes.instanceOf(Animated.Value),
labelAnimation: PropTypes.instanceOf(Animated.Value),
labelWidth: PropTypes.instanceOf(Animated.Value),

contentInset: PropTypes.shape({
left: PropTypes.number,
right: PropTypes.number,
}),
};

borderProps() {
let {
disabled,
Expand Down Expand Up @@ -87,10 +62,10 @@ export default class Line extends PureComponent {

let labelOffset = 2 * (contentInset.left - 2 * borderRadius);
let lineOffset = Animated.add(labelWidth, labelOffset);

let topLineContainerStyle = {
transform: [{
scaleX: I18nManager.isRTL? -1 : 1,
scaleX: I18nManager.isRTL ? -1 : 1,
}, {
translateX: Animated.multiply(labelAnimation, lineOffset),
}],
Expand Down