enhanced tags

This commit is contained in:
u-e 2019-02-12 16:41:38 +03:00
parent 25ffaec71e
commit 2a44133bc4
3 changed files with 41 additions and 7 deletions

View File

@ -1,19 +1,39 @@
import EStyleSheet from 'react-native-extended-stylesheet'; import EStyleSheet from 'react-native-extended-stylesheet';
export default EStyleSheet.create({ export default EStyleSheet.create({
textInput: { wrapper: {
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
alignSelf: 'center',
color: '$primaryBackgroundColor', color: '$primaryBackgroundColor',
fontSize: 10,
backgroundColor: '#c1c5c7', backgroundColor: '#c1c5c7',
borderRadius: 50, borderRadius: 50,
height: 20, height: 25,
padding: 5, padding: 5,
paddingHorizontal: 10, paddingHorizontal: 10,
minWidth: 50, minWidth: 50,
marginRight: 8, marginRight: 8,
},
textInput: {
fontFamily: '$editorFont', fontFamily: '$editorFont',
fontSize: 10,
}, },
isPin: { isPin: {
backgroundColor: '$primaryBlue', backgroundColor: '$primaryBlue',
}, },
removeIcon: {
marginLeft: 5,
width: 25,
height: 25,
borderRadius: 25 / 2,
position: 'absolute',
right: 2,
},
iconStyle: {
color: '$primaryLightGray',
},
textInputWithButton: {
marginRight: 15,
},
}); });

View File

@ -1,18 +1,30 @@
import React, { Fragment } from 'react'; import React from 'react';
import { View } from 'react-native';
import { TextInput } from '../../../textInput'; import { TextInput } from '../../../textInput';
import { IconButton } from '../../../iconButton';
import styles from './chipStyle'; import styles from './chipStyle';
const Chip = props => ( const Chip = props => (
<Fragment> <View style={[styles.wrapper, props.isPin && styles.isPin]}>
<TextInput <TextInput
style={[styles.textInput, props.removeButton && styles.textInputWithButton]}
allowFontScaling allowFontScaling
style={[styles.textInput, props.isPin && styles.isPin]}
onChangeText={text => props.handleOnChange(text)} onChangeText={text => props.handleOnChange(text)}
onBlur={() => props.handleOnBlur()} onBlur={() => props.handleOnBlur()}
{...props} {...props}
/> />
</Fragment> {props.removeButton && (
<IconButton
style={styles.removeIcon}
iconStyle={styles.iconStyle}
size={16}
iconType="MaterialIcons"
name="close"
onPress={props.handleOnRemoveButtonPress && props.handleOnRemoveButtonPress}
/>
)}
</View>
); );
export default Chip; export default Chip;

View File

@ -106,6 +106,8 @@ export default class TagAreaView extends Component {
}} }}
isPin={i === 0 && chips[1]} isPin={i === 0 && chips[1]}
placeholderTextColor="#fff" placeholderTextColor="#fff"
removeButton={i !== 0}
handleOnRemoveButtonPress={() => this._handleTagRemove(i)}
editable={!isPreviewActive} editable={!isPreviewActive}
maxLength={50} maxLength={50}
placeholder="tags" placeholder="tags"