Skip to content

Commit

Permalink
Merge pull request #92 from rsml/optimize-styles
Browse files Browse the repository at this point in the history
Fix #91: Optimize styles by using StyleSheet.create() for styles that…
  • Loading branch information
anhtuank7c committed Feb 22, 2021
2 parents 61dce36 + 75677d6 commit 6454c0f
Showing 1 changed file with 24 additions and 11 deletions.
35 changes: 24 additions & 11 deletions index.js
Expand Up @@ -10,11 +10,25 @@ import {
Keyboard,
Image,
View,
ViewPropTypes
ViewPropTypes,
StyleSheet
} from 'react-native';

const AnimatedTextInput = Animated.createAnimatedComponent(TextInput);

const optimizedStyles = StyleSheet.create({
iconSearchDefault: {
tintColor: 'grey'
},
iconDeleteDefault: {
tintColor: 'grey'
},
cancelButtonText: {
fontSize: 14,
color: '#fff'
}
})

class Search extends PureComponent {
constructor(props) {
super(props);
Expand Down Expand Up @@ -417,6 +431,12 @@ const getStyles = (inputHeight, isRtl) => {
inputHeight = 30
}

const {
iconSearchDefault,
iconDeleteDefault,
cancelButtonText
} = optimizedStyles;

return {
container: {
backgroundColor: 'grey',
Expand Down Expand Up @@ -445,30 +465,23 @@ const getStyles = (inputHeight, isRtl) => {
height: 14,
width: 14
},
iconSearchDefault: {
tintColor: 'grey'
},
iconSearchDefault,
iconDelete: {
position: 'absolute',
[isRtl ? 'left' : 'right']: 70,
top: middleHeight - 7,
height: 14,
width: 14
},
iconDeleteDefault: {
tintColor: 'grey'
},
iconDeleteDefault,
cancelButton: {
justifyContent: 'center',
alignItems: isRtl ? 'flex-end' : 'flex-start',
backgroundColor: 'transparent',
width: 60,
height: 50
},
cancelButtonText: {
fontSize: 14,
color: '#fff'
}
cancelButtonText
};
}

Expand Down

0 comments on commit 6454c0f

Please sign in to comment.