mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-26 06:42:15 +03:00
enhanced chips on editor
This commit is contained in:
parent
d41098053f
commit
cd13ec6bf6
@ -91,7 +91,7 @@ class BasicHeaderView extends Component {
|
|||||||
name={isModalHeader ? 'close' : 'md-arrow-back'}
|
name={isModalHeader ? 'close' : 'md-arrow-back'}
|
||||||
onPress={() => (isModalHeader ? handleOnPressClose() : handleOnPressBackButton())}
|
onPress={() => (isModalHeader ? handleOnPressClose() : handleOnPressBackButton())}
|
||||||
/>
|
/>
|
||||||
{isHasIcons && (
|
{isHasIcons && !isReply && (
|
||||||
<View>
|
<View>
|
||||||
{!isDraftSaving ? (
|
{!isDraftSaving ? (
|
||||||
<IconButton
|
<IconButton
|
||||||
|
@ -6,7 +6,7 @@ export default EStyleSheet.create({
|
|||||||
fontSize: 10,
|
fontSize: 10,
|
||||||
backgroundColor: '#c1c5c7',
|
backgroundColor: '#c1c5c7',
|
||||||
borderRadius: 50,
|
borderRadius: 50,
|
||||||
maxHeight: 18,
|
height: 20,
|
||||||
padding: 5,
|
padding: 5,
|
||||||
paddingHorizontal: 10,
|
paddingHorizontal: 10,
|
||||||
marginRight: 8,
|
marginRight: 8,
|
||||||
|
@ -10,9 +10,9 @@ import globalStyles from '../../../../globalStyles';
|
|||||||
|
|
||||||
export default class TagAreaView extends Component {
|
export default class TagAreaView extends Component {
|
||||||
/* Props
|
/* Props
|
||||||
* ------------------------------------------------
|
* ------------------------------------------------
|
||||||
* @prop { type } name - Description....
|
* @prop { type } name - Description....
|
||||||
*/
|
*/
|
||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
@ -20,6 +20,7 @@ export default class TagAreaView extends Component {
|
|||||||
currentText: '',
|
currentText: '',
|
||||||
chips: [' '],
|
chips: [' '],
|
||||||
chipsCount: props.chipsCount || 5,
|
chipsCount: props.chipsCount || 5,
|
||||||
|
activeChip: 0,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +38,10 @@ export default class TagAreaView extends Component {
|
|||||||
|
|
||||||
// Component Functions
|
// Component Functions
|
||||||
_handleOnChange = (text, i) => {
|
_handleOnChange = (text, i) => {
|
||||||
this.setState({ currentText: text.trim() });
|
this.setState({
|
||||||
|
currentText: text.replace(/\s/g, ''),
|
||||||
|
});
|
||||||
|
|
||||||
if (text.indexOf(' ') > 0 && text) {
|
if (text.indexOf(' ') > 0 && text) {
|
||||||
this._handleTagAdded();
|
this._handleTagAdded();
|
||||||
}
|
}
|
||||||
@ -53,16 +57,22 @@ export default class TagAreaView extends Component {
|
|||||||
_handleTagAdded = (i = null, text = null) => {
|
_handleTagAdded = (i = null, text = null) => {
|
||||||
const { currentText, chips, chipsCount } = this.state;
|
const { currentText, chips, chipsCount } = this.state;
|
||||||
const { handleTagChanged } = this.props;
|
const { handleTagChanged } = this.props;
|
||||||
const _currentText = (currentText && currentText.trim()) || text;
|
const _currentText = currentText || text;
|
||||||
|
|
||||||
if (_currentText && chips && chips.length < chipsCount) {
|
if (_currentText && chips && chips.length < chipsCount) {
|
||||||
this.setState({
|
this.setState({
|
||||||
chips: [...chips, _currentText],
|
chips: [...chips, _currentText],
|
||||||
currentText: '',
|
currentText: '',
|
||||||
});
|
});
|
||||||
|
} else if (_currentText && chips && chips.length === chipsCount) {
|
||||||
|
let _chips = chips;
|
||||||
|
_chips[chipsCount -1] = currentText;
|
||||||
|
this.setState({
|
||||||
|
chips: _chips,
|
||||||
|
currentText: null,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handleTagChanged && chips.length < chipsCount + 1) {
|
if (handleTagChanged && chips.length < chipsCount) {
|
||||||
handleTagChanged([...chips, _currentText]);
|
handleTagChanged([...chips, _currentText]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -81,10 +91,8 @@ export default class TagAreaView extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const { isPreviewActive, intl } = this.props;
|
||||||
isPreviewActive, draftChips, intl, autoFocus,
|
const { chips, currentText, activeChip } = this.state;
|
||||||
} = this.props;
|
|
||||||
const { chips } = this.state;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={globalStyles.containerHorizontal16}>
|
<View style={globalStyles.containerHorizontal16}>
|
||||||
@ -102,13 +110,14 @@ export default class TagAreaView extends Component {
|
|||||||
placeholder={intl.formatMessage({
|
placeholder={intl.formatMessage({
|
||||||
id: 'editor.tags',
|
id: 'editor.tags',
|
||||||
})}
|
})}
|
||||||
autoFocus={autoFocus ? i !== 0 && chips.length - 1 === i : false}
|
autoFocus={i !== 0 && chips.length - 1 === i}
|
||||||
multiline={false}
|
multiline={false}
|
||||||
handleOnChange={text => this._handleOnChange(text, i)}
|
handleOnChange={text => this._handleOnChange(text, i)}
|
||||||
handleOnBlur={() => this._handleOnBlur(i)}
|
handleOnBlur={() => this._handleOnBlur(i)}
|
||||||
blurOnSubmit
|
blurOnSubmit
|
||||||
value={draftChips.length > 0 ? chip && chip : null}
|
value={activeChip === i ? currentText : chip}
|
||||||
autoCapitalize="none"
|
autoCapitalize="none"
|
||||||
|
onFocus={() => this.setState({ activeChip: i })}
|
||||||
{...this.props}
|
{...this.props}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
@ -17,10 +17,18 @@ export default class TitleAreaView extends Component {
|
|||||||
|
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {};
|
this.state = {
|
||||||
|
text: props.value || null,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Component Life Cycles
|
// Component Life Cycles
|
||||||
|
componentWillReceiveProps = (nextProps) => {
|
||||||
|
const { text } = this.state;
|
||||||
|
if (nextProps.value !== text) {
|
||||||
|
this.setState({ text: nextProps.value });
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Component Functions
|
// Component Functions
|
||||||
_handleOnChange = (text) => {
|
_handleOnChange = (text) => {
|
||||||
@ -35,9 +43,8 @@ export default class TitleAreaView extends Component {
|
|||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const { intl, isPreviewActive, autoFocus } = this.props;
|
||||||
intl, isPreviewActive, value, autoFocus,
|
const { text } = this.state;
|
||||||
} = this.props;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={globalStyles.containerHorizontal16}>
|
<View style={globalStyles.containerHorizontal16}>
|
||||||
@ -53,9 +60,7 @@ export default class TitleAreaView extends Component {
|
|||||||
autoFocus={autoFocus}
|
autoFocus={autoFocus}
|
||||||
numberOfLines={4}
|
numberOfLines={4}
|
||||||
onChangeText={text => this._handleOnChange(text)}
|
onChangeText={text => this._handleOnChange(text)}
|
||||||
// TODO: Fix it
|
value={text}
|
||||||
// value={value && value}
|
|
||||||
// {...this.props}
|
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
@ -113,7 +113,6 @@ class HeaderView extends Component {
|
|||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<IconButton
|
<IconButton
|
||||||
style={styles.searchButton}
|
|
||||||
iconStyle={styles.backIcon}
|
iconStyle={styles.backIcon}
|
||||||
name="md-search"
|
name="md-search"
|
||||||
onPress={() => this.setState({ isSearchModalOpen: true })}
|
onPress={() => this.setState({ isSearchModalOpen: true })}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
import { Alert } from 'react-native'
|
||||||
import ImagePicker from 'react-native-image-crop-picker';
|
import ImagePicker from 'react-native-image-crop-picker';
|
||||||
|
|
||||||
// Services and Actions
|
// Services and Actions
|
||||||
@ -169,7 +170,7 @@ class EditorContainer extends Component {
|
|||||||
_handleMediaOnSelectFailure = (error) => {
|
_handleMediaOnSelectFailure = (error) => {
|
||||||
// const { navigation } = this.props;
|
// const { navigation } = this.props;
|
||||||
this.setState({ isCameraOrPickerOpen: false });
|
this.setState({ isCameraOrPickerOpen: false });
|
||||||
// navigation.navigate(ROUTES.SCREENS.HOME);
|
Alert.alert('Permission Denied', 'Please, go to settings then find eSteem change the app permision settings.');
|
||||||
};
|
};
|
||||||
|
|
||||||
// Media select functions <- END ->
|
// Media select functions <- END ->
|
||||||
|
Loading…
Reference in New Issue
Block a user