Merge pull request #297 from esteemapp/enhancment/ui

updated a bit
This commit is contained in:
uğur erdal 2018-12-22 22:03:32 +03:00 committed by GitHub
commit 6ebbf86622
5 changed files with 40 additions and 36 deletions

View File

@ -39,7 +39,7 @@ export default class MarkdownEditorView extends Component {
});
}
if (nextProps.uploadedImage && nextProps.uploadedImage !== uploadedImage) {
if (nextProps.uploadedImage && nextProps.uploadedImage.url && nextProps.uploadedImage !== uploadedImage) {
applyImageLink({
getState: this._getState,
setState: (state, callback) => {

View File

@ -6,7 +6,6 @@ import { View, TouchableOpacity, Animated } from 'react-native';
// Components
// Styles
// eslint-disable-next-line
import styles from './toggleSwitchStyles';
class ToggleSwitchView extends PureComponent {
@ -24,11 +23,18 @@ class ToggleSwitchView extends PureComponent {
circleWidth: 28,
circleHeight: 28,
translateX: 36,
isOn: false || props.isOn,
isOn: props.isOn,
};
}
// Component Life Cycles
componentWillMount() {
this.setState({ duration: 0 });
}
componentDidMount() {
this.setState({ duration: 300 });
}
// Component Functions
_createCircleStyle = () => {
@ -70,25 +76,28 @@ class ToggleSwitchView extends PureComponent {
_onToggle = () => {
const { onToggle } = this.props;
const { isOn } = this.state;
this.setState({ isOn: !isOn });
this.setState(
{
isOn: !isOn,
},
() => {
onToggle && onToggle(!isOn);
},
);
// For debounce
setTimeout(() => {
if (onToggle) onToggle(!isOn);
}, 300);
};
render() {
const { width, translateX, isOn } = this.state;
_triggerAnimation = () => {
const {
width, translateX, isOn, duration,
} = this.state;
const toValue = isOn ? width - translateX : 0;
Animated.timing(this.offsetX, {
toValue,
duration: 300,
duration,
}).start();
};
render() {
this._triggerAnimation();
return (
<View style={styles.container}>

View File

@ -617,7 +617,6 @@ export const lookupAccounts = async (username) => {
*/
export const postContent = async (
account,
digitPinCode,
parentAuthor,
parentPermlink,
permlink,
@ -628,6 +627,7 @@ export const postContent = async (
voteWeight = null,
) => {
const { name: author } = account;
const digitPinCode = await getDigitPinCode();
if (account.local.authType === AUTH_TYPE.MASTER_KEY) {
const opArray = [

View File

@ -8,9 +8,6 @@ import ImagePicker from 'react-native-image-crop-picker';
import { uploadImage } from '../../../providers/esteem/esteem';
import { postContent } from '../../../providers/steem/dsteem';
import { setDraftPost, getDraftPost } from '../../../realm/realm';
import { getDigitPinCode } from '../../../providers/steem/auth';
// Middleware
// Constants
import { default as ROUTES } from '../../../constants/routeNames';
@ -102,9 +99,9 @@ class EditorContainer extends Component {
_handleOpenImagePicker = () => {
ImagePicker.openPicker({
//width: 300,
//height: 400,
//cropping: true,
// width: 300,
// height: 400,
// cropping: true,
// writeTempFile: true,
// includeBase64: true,
// multiple: true,
@ -119,9 +116,9 @@ class EditorContainer extends Component {
_handleOpenCamera = () => {
ImagePicker.openCamera({
//width: 300,
//height: 400,
//cropping: true,
// width: 300,
// height: 400,
// cropping: true,
// includeBase64: true,
})
.then((image) => {
@ -138,7 +135,7 @@ class EditorContainer extends Component {
});
// For new image api
// const { currentAccount } = this.props;
// const digitPinCode = await getDigitPinCode();
// const digitPinCode = await getPinCode();
// const privateKey = decryptKey(currentAccount.local.postingKey, digitPinCode);
// const sign = generateSignature(media, privateKey);
// const data = new Buffer(media.data, 'base64');
@ -168,12 +165,14 @@ class EditorContainer extends Component {
};
_handleMediaOnSelectFailure = (error) => {
// const { navigation } = this.props;
this.setState({ isCameraOrPickerOpen: false });
Alert.alert(
'Permission Denied',
'Please, go to phone Settings and change eSteem app permissions.',
);
if (error.code === 'E_PERMISSION_MISSING') {
Alert.alert(
'Permission Denied',
'Please, go to phone Settings and change eSteem app permissions.',
);
}
};
// Media select functions <- END ->
@ -212,14 +211,12 @@ class EditorContainer extends Component {
const meta = extractMetadata(fields.body);
const jsonMeta = makeJsonMetadata(meta, fields.tags);
const permlink = generatePermlink(fields.title);
const digitPinCode = await getDigitPinCode();
const author = currentAccount.name;
const options = makeOptions(author, permlink);
const parentPermlink = fields.tags[0];
await postContent(
currentAccount,
digitPinCode,
'',
parentPermlink,
permlink,
@ -249,7 +246,6 @@ class EditorContainer extends Component {
const jsonMeta = makeJsonMetadataReply(post.json_metadata.tags || ['esteem']);
const permlink = generateReplyPermlink(post.author);
const digitPinCode = await getDigitPinCode();
const author = currentAccount.name;
const options = makeOptions(author, permlink);
const parentAuthor = post.author;
@ -257,7 +253,6 @@ class EditorContainer extends Component {
await postContent(
currentAccount,
digitPinCode,
parentAuthor,
parentPermlink,
permlink,

View File

@ -1,5 +1,5 @@
import React, { Component, Fragment } from 'react';
import { View, Text } from 'react-native';
import React, { Component } from 'react';
import { View } from 'react-native';
import { injectIntl } from 'react-intl';
// Utils