diff --git a/src/components/_comment/comment.js b/src/components/_comment/comment.js deleted file mode 100644 index ee271c890..000000000 --- a/src/components/_comment/comment.js +++ /dev/null @@ -1,571 +0,0 @@ -/* eslint-disable no-unused-vars */ -import React from 'react'; -import { - StyleSheet, - Image, - TouchableOpacity, - Dimensions, - ActivityIndicator, - FlatList, -} from 'react-native'; -import { - Card, - CardItem, - Left, - Right, - Thumbnail, - View, - Icon, - Body, - Text, - Button, -} from 'native-base'; -import { Popover, PopoverController } from 'react-native-modal-popover'; -import Slider from 'react-native-slider'; -import Modal from 'react-native-modal'; -import HTML from 'react-native-html-renderer'; - -import { upvote, upvoteAmount } from '../../providers/steem/dsteem'; -import { decryptKey } from '../../utils/crypto'; -import { getUserData } from '../../realm/realm'; -import { parsePost } from '../../utils/postParser'; -import { getComments, getPost } from '../../providers/steem/dsteem'; -/* eslint-enable no-unused-vars */ - -class Comment extends React.PureComponent { - constructor(props) { - super(props); - this.state = { - amount: '0.00', - value: 0.1, - replies: [], - isVoting: false, - isVoted: false, - isModalVisible: false, - }; - } - - componentDidMount() { - if (this.props.comment.children > 1) { - getComments(this.props.comment.author, this.props.comment.permlink) - .then((replies) => { - this.setState({ - replies, - }); - }) - .catch((error) => { - console.log(error); - }); - } - } - - onLinkPress(evt, href, attribs) { - const steemPost = href.match( - /^https?:\/\/(.*)\/(.*)\/(@[\w\.\d-]+)\/(.*)/i, - ); - - if (attribs.class === 'markdown-author-link') { - this.props.navigation.navigate('Author', { author: href }); - } else if (steemPost != null) { - steemPost[3] = steemPost[3].replace('@', ''); - getPost(steemPost[3], steemPost[4]) - .then((result) => { - const content = parsePost(result); - this.props.navigation.push('Post', { content }); - }) - .catch((err) => { - alert(err); - }); - } else { - console.log(href); - console.log(attribs); - } - } - - alterNode(node) { - if (node.name == 'img') { - node.attribs.style = 'width: auto; object-fit: cover'; - } else if (node.name == 'iframe') { - node.attribs.style = `max-width: ${Dimensions.get('window').width}`; - // node.attribs.style = `width: ${Dimensions.get("window").width}`; - node.attribs.height = 200; - } - } - - calculateEstimatedAmount = async () => { - // Calculate total vesting shares - const total_vests = parseFloat(this.props.user.vesting_shares) - + parseFloat(this.props.user.received_vesting_shares) - - parseFloat(this.props.user.delegated_vesting_shares); - - const final_vest = total_vests * 1e6; - - const power = (this.props.user.voting_power * (this.state.value * 10000)) - / 10000 - / 50; - - const rshares = (power * final_vest) / 10000; - - const estimated = await upvoteAmount(rshares); - - this.setState({ - amount: estimated.toFixed(3), - }); - }; - - upvoteContent = async () => { - let postingKey; - let userData; - - if (this.props.isLoggedIn) { - await this.setState({ - isVoting: true, - }); - - await getUserData().then((result) => { - userData = Array.from(result); - postingKey = decryptKey(userData[0].postingKey, 'pinCode'); - }); - upvote( - { - voter: this.props.user.name, - author: this.props.comment.author, - permlink: this.props.comment.permlink, - weight: (this.state.value * 100).toFixed(0) * 100, - }, - postingKey, - ) - .then((res) => { - console.log(res); - this.setState({ - isVoted: true, - isVoting: false, - }); - }) - .catch((err) => { - console.log(err); - this.setState({ - isVoted: false, - isVoting: false, - }); - }); - } - }; - - toggleModal = () => { - this.setState({ - isModalVisible: !this.state.isModalVisible, - }); - }; - - render() { - return ( - - - - - - - - - {this.props.comment.author} - - - - - - {this.props.comment.created} - - - - this.onLinkPress(evt, href, hrefatr) - } - containerStyle={{ padding: 0 }} - textSelectable - tagsStyles={styles} - ignoredTags={['script']} - debug={false} - removeClippedSubviews={false} - alterNode={(node) => { - this.alterNode(node); - }} - imagesMaxWidth={Dimensions.get('window').width} - /> - - - - - {({ - openPopover, - closePopover, - popoverVisible, - setPopoverAnchor, - popoverAnchorRect, - }) => ( - - - {this.state.isVoting ? ( - - ) : ( - - {this.state.isVoted ? ( - - ) : ( - - )} - - )} - - - - $ - {this.state.amount} - - - { - closePopover(); - this.upvoteContent(); - }} - style={{ - flex: 0.1, - alignSelf: 'center', - }} - > - - - { - this.setState( - { value }, - () => { - this.calculateEstimatedAmount(); - }, - ); - }} - /> - - {( - this.state.value - * 100 - ).toFixed(0)} - % - - - - - )} - - - - $ - { - this.props.comment - .pending_payout_value - } - - - - - - Tap to close! - - item.voter.toString() - } - renderItem={({ item }) => ( - - - - {' '} - {item.voter} - {' '} -( - {item.reputation} -) - - - {item.value} -$ - - - {item.percent} -% - - - )} - /> - - - - this.props.navigation.navigate( - 'Reply', - { - content: this.props.comment, - user: this.props.user, - }, - ) - } - style={{ - marginLeft: 10, - flexDirection: 'row', - }} - > - Reply - - - - - - - - {this.props.comment.children > 0 ? ( - // Replies - - {this.state.replies.map(reply => ( - - - - ))} - - ) : ( - - )} - - ); - } -} -const styles = StyleSheet.create({ - comment: { - alignSelf: 'center', - color: '#626262', - borderRadius: 10, - width: '98%', - marginHorizontal: 10, - flexDirection: 'row', - }, - commentBox: { - borderRadius: 10, - flex: 1, - }, - avatar: { - width: 30, - height: 30, - borderRadius: 15, - borderColor: 'lightgray', - borderWidth: 1, - marginTop: 10, - }, - author: { - backgroundColor: 'white', - alignSelf: 'flex-start', - paddingVertical: 5, - }, - timeAgo: { - alignSelf: 'center', - fontSize: 9, - fontWeight: '100', - marginHorizontal: 3, - }, - authorName: { - color: '#222', - fontWeight: '600', - fontSize: 13, - marginHorizontal: 5, - }, - body: { - justifyContent: 'flex-start', - flexDirection: 'row', - }, - upvoteButton: { - margin: 0, - flexDirection: 'row', - paddingVertical: 0, - }, - upvoteIcon: { - alignSelf: 'flex-start', - fontSize: 20, - color: '#007ee5', - margin: 0, - width: 18, - }, - payout: { - alignSelf: 'center', - fontSize: 10, - color: '#626262', - marginLeft: 3, - }, - payoutIcon: { - fontSize: 15, - marginHorizontal: 3, - color: '#a0a0a0', - alignSelf: 'center', - }, - payoutButton: { - flexDirection: 'row', - alignSelf: 'flex-start', - paddingVertical: 2, - }, - popover: { - width: Dimensions.get('window').width - 20, - borderRadius: 5, - padding: 10, - }, - track: { - height: 2, - borderRadius: 1, - }, - thumb: { - width: 30, - height: 30, - borderRadius: 30 / 2, - backgroundColor: 'white', - shadowColor: 'black', - shadowOffset: { width: 0, height: 2 }, - shadowRadius: 2, - shadowOpacity: 0.35, - }, -}); - -export default Comment; diff --git a/src/components/editorHeader/container/editorHeaderContainer.js b/src/components/basicHeader/container/basicHeaderContainer.js similarity index 72% rename from src/components/editorHeader/container/editorHeaderContainer.js rename to src/components/basicHeader/container/basicHeaderContainer.js index 0ec8e5c58..e24213434 100644 --- a/src/components/editorHeader/container/editorHeaderContainer.js +++ b/src/components/basicHeader/container/basicHeaderContainer.js @@ -5,9 +5,9 @@ import { withNavigation } from 'react-navigation'; // import { default as ROUTES } from '../../../constants/routeNames'; // Components -import { EditorHeaderView } from '..'; +import { BasicHeaderView } from '..'; -class EditorHeaderContainer extends Component { +class BasicHeaderContainer extends Component { /* Props * ------------------------------------------------ * @prop { funtion } handleOnPressPreviewButton - Preview button active handler.... @@ -29,9 +29,9 @@ class EditorHeaderContainer extends Component { render() { return ( - + ); } } -export default withNavigation(EditorHeaderContainer); +export default withNavigation(BasicHeaderContainer); diff --git a/src/components/basicHeader/index.js b/src/components/basicHeader/index.js new file mode 100644 index 000000000..ec33224de --- /dev/null +++ b/src/components/basicHeader/index.js @@ -0,0 +1,5 @@ +import BasicHeaderView from './view/basicHeaderView'; +import BasicHeader from './container/basicHeaderContainer'; + +export { BasicHeaderView, BasicHeader }; +export default BasicHeader; diff --git a/src/components/editorHeader/view/editorHeaderStyles.js b/src/components/basicHeader/view/basicHeaderStyles.js similarity index 100% rename from src/components/editorHeader/view/editorHeaderStyles.js rename to src/components/basicHeader/view/basicHeaderStyles.js diff --git a/src/components/editorHeader/view/editorHeaderView.js b/src/components/basicHeader/view/basicHeaderView.js similarity index 97% rename from src/components/editorHeader/view/editorHeaderView.js rename to src/components/basicHeader/view/basicHeaderView.js index d594b03d0..6f598b18a 100644 --- a/src/components/editorHeader/view/editorHeaderView.js +++ b/src/components/basicHeader/view/basicHeaderView.js @@ -10,9 +10,9 @@ import { IconButton } from '../../iconButton'; import { DropdownButton } from '../../dropdownButton'; // Styles -import styles from './editorHeaderStyles'; +import styles from './basicHeaderStyles'; -class EditorHeaderView extends Component { +class BasicHeaderView extends Component { /* Props * ------------------------------------------------ * @prop { boolean } isFormValid - Righst button propertie @@ -186,4 +186,4 @@ class EditorHeaderView extends Component { } } -export default EditorHeaderView; +export default BasicHeaderView; diff --git a/src/components/editorHeader/index.js b/src/components/editorHeader/index.js deleted file mode 100644 index 8c1c2c68c..000000000 --- a/src/components/editorHeader/index.js +++ /dev/null @@ -1,5 +0,0 @@ -import EditorHeaderView from './view/editorHeaderView'; -import EditorHeader from './container/editorHeaderContainer'; - -export { EditorHeaderView, EditorHeader }; -export default EditorHeader; diff --git a/src/screens/editor/screen/editorScreen.js b/src/screens/editor/screen/editorScreen.js index aa8717951..f0682f276 100644 --- a/src/screens/editor/screen/editorScreen.js +++ b/src/screens/editor/screen/editorScreen.js @@ -7,7 +7,7 @@ import { getWordsCount } from '../../../utils/editor'; // Constants // Components -import { EditorHeader } from '../../../components/editorHeader'; +import { BasicHeader } from '../../../components/basicHeader'; import { TitleArea, TagArea, TextArea } from '../../../components/editorElements'; import { PostForm } from '../../../components/postForm'; // Styles @@ -130,7 +130,7 @@ export class EditorScreen extends Component { return ( - - - + ); diff --git a/src/screens/voters/screen/votersScreen.js b/src/screens/voters/screen/votersScreen.js index 89773c32a..07adab2a8 100644 --- a/src/screens/voters/screen/votersScreen.js +++ b/src/screens/voters/screen/votersScreen.js @@ -3,7 +3,7 @@ import { View } from 'react-native'; // Constants // Components -import { EditorHeader } from '../../../components/editorHeader'; +import { BasicHeader } from '../../../components/basicHeader'; import { FilterBar } from '../../../components/filterBar'; import { VotersDisplay } from '../../../components/votersDisplay'; @@ -69,7 +69,7 @@ class VotersScreen extends Component { return ( -