Skip to content

Commit

Permalink
Merge pull request #543 from shoutem/release/4.0.13
Browse files Browse the repository at this point in the history
Release/4.0.13
  • Loading branch information
Definitely-Not-Vlad authored Nov 23, 2020
2 parents 81b09cd + b4bc697 commit 12524c3
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 21 deletions.
42 changes: 24 additions & 18 deletions components/TextInput.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, { PureComponent } from 'react';
import autoBindReact from 'auto-bind/react';
import _ from 'lodash';
import PropTypes from 'prop-types';
import { TextInput as RNTextInput } from 'react-native';

Expand All @@ -10,16 +9,6 @@ import { connectStyle } from '@shoutem/theme';
import { Caption } from './Text';
import { View } from './View';

// Style properties defined in theme which would case a warning if passed to a components style prop
const omittedStyleProperties = [
'errorBorder',
'placeholderTextColor',
'selectionColor',
'underlineColorAndroid',
'withBorder',
'withoutBorder',
];

class TextInput extends PureComponent {
constructor(props) {
super(props);
Expand All @@ -40,23 +29,40 @@ class TextInput extends PureComponent {
}

render() {
const { errorMessage, highlightOnFocus, style } = this.props;
const {
errorMessage,
highlightOnFocus,
style,
...otherProps
} = this.props;
const { isFocused } = this.state;

const {
errorBorderColor,
placeholderTextColor,
selectionColor,
underlineColorAndroid,
withBorder,
withoutBorder,
...otherStyle
} = style;

const hasBorder = (isFocused && highlightOnFocus) || !!errorMessage;

return (
<View>
<RNTextInput
{..._.omit(this.props, 'style')}
{...otherProps}
onBlur={this.handleBlur}
onFocus={this.handleFocus}
placeholderTextColor={style.placeholderTextColor}
selectionColor={style.selectionColor}
underlineColorAndroid={style.underlineColorAndroid}
style={[
_.omit(style, omittedStyleProperties),
(isFocused && highlightOnFocus) ? style.withBorder : style.withoutBorder,
!!errorMessage && style.errorBorder,
]}
style={{
...otherStyle,
...(hasBorder ? style.withBorder : style.withoutBorder),
...(!!errorMessage ? style.errorBorderColor : {}),
}}
/>
{!!errorMessage &&
<Caption styleName="form-error sm-gutter-top">
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@shoutem/ui",
"version": "4.0.12",
"version": "4.0.13",
"description": "Styleable set of components for React Native applications",
"dependencies": {
"@shoutem/animation": "~0.12.4",
Expand Down
3 changes: 1 addition & 2 deletions theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -1967,8 +1967,7 @@ export default (variables = defaultThemeVariables) => ({
fontWeight: resolveFontWeight(variables.text.fontWeight),
fontStyle: resolveFontStyle(variables.text.fontStyle),

errorBorder: {
borderWidth: 1,
errorBorderColor: {
borderColor: variables.errorText.color,
},
withBorder: {
Expand Down

0 comments on commit 12524c3

Please sign in to comment.