From 6118934b398e52554133f157e33955efd69507b8 Mon Sep 17 00:00:00 2001 From: ue Date: Thu, 7 Nov 2019 22:25:49 +0300 Subject: [PATCH] created custom filter enhanced posts --- .../filterBar/view/filterBarStyles.js | 6 ++++ .../filterBar/view/filterBarView.js | 23 ++++++++------ .../posts/container/postsContainer.js | 4 +++ src/components/posts/view/postsView.js | 31 +++++++++++++------ src/components/profile/profileView.js | 15 ++++++--- src/constants/options/filters.js | 3 ++ src/screens/feed/screen/feedScreen.js | 9 +++++- 7 files changed, 67 insertions(+), 24 deletions(-) diff --git a/src/components/filterBar/view/filterBarStyles.js b/src/components/filterBar/view/filterBarStyles.js index 8b5210bfa..c1d3e0145 100644 --- a/src/components/filterBar/view/filterBarStyles.js +++ b/src/components/filterBar/view/filterBarStyles.js @@ -12,8 +12,14 @@ export default EStyleSheet.create({ }, zIndex: 99, }, + dropdownWrapper: { + flexDirection: 'row', + justifyContent: 'center', + alignItems: 'center', + }, filterBarWrapper: { flexDirection: 'row', + alignItems: 'center', justifyContent: 'space-between', }, rightIconWrapper: { diff --git a/src/components/filterBar/view/filterBarView.js b/src/components/filterBar/view/filterBarView.js index 1b1c7ddd9..bd0d9dfcd 100644 --- a/src/components/filterBar/view/filterBarView.js +++ b/src/components/filterBar/view/filterBarView.js @@ -1,12 +1,12 @@ import React from 'react'; -import { View, TouchableOpacity } from 'react-native'; +import { View, Text, TouchableOpacity } from 'react-native'; import { Icon } from '../../icon'; // External Components import { DropdownButton } from '../../dropdownButton'; // Components -import { LineBreak } from '../../basicUIElements'; +import { LineBreak, Tag } from '../../basicUIElements'; // Styles import styles from './filterBarStyles'; @@ -27,18 +27,23 @@ const FilterBarView = ({ rightIconName, rightIconType, selectedOptionIndex, + customOption, }) => ( {!isHide && ( - + + + {customOption && onDropdownSelect(3)} />} + + {rightIconName && ( onRightIconPress && onRightIconPress()} diff --git a/src/components/posts/container/postsContainer.js b/src/components/posts/container/postsContainer.js index 64da5170b..b646855b9 100644 --- a/src/components/posts/container/postsContainer.js +++ b/src/components/posts/container/postsContainer.js @@ -24,6 +24,8 @@ const PostsContainer = ({ selectedOptionIndex, tag, nsfw, + filterOptionsValue, + customOption, }) => { const dispatch = useDispatch(); @@ -57,6 +59,8 @@ const PostsContainer = ({ selectedOptionIndex={selectedOptionIndex} setFeedPosts={_setFeedPosts} tag={tag} + filterOptionsValue={filterOptionsValue} + customOption={customOption} /> )} diff --git a/src/components/posts/view/postsView.js b/src/components/posts/view/postsView.js index fa468de3b..f7412b1b8 100644 --- a/src/components/posts/view/postsView.js +++ b/src/components/posts/view/postsView.js @@ -38,6 +38,8 @@ const PostsView = ({ navigation, changeForceLoadPostState, forceLoadPost, + filterOptionsValue, + customOption, }) => { const [posts, setPosts] = useState(isConnected ? [] : feedPosts); const [startAuthor, setStartAuthor] = useState(''); @@ -100,9 +102,16 @@ const PostsView = ({ useEffect(() => { if (!startAuthor && !startPermlink) { - _loadPosts(filterOptions[selectedFilterIndex].toLowerCase()); + _loadPosts(filterOptionsValue[selectedFilterIndex]); } - }, [_loadPosts, filterOptions, selectedFilterIndex, startAuthor, startPermlink]); + }, [ + _loadPosts, + filterOptions, + filterOptionsValue, + selectedFilterIndex, + startAuthor, + startPermlink, + ]); const _handleOnDropdownSelect = async index => { setSelectedFilterIndex(index); @@ -135,11 +144,15 @@ const PostsView = ({ const _loadPosts = useCallback( async type => { + if (isLoading) { + return; + } else { + setIsLoading(true); + } + const filter = type || - (filterOptions && - filterOptions.length > 0 && - filterOptions[selectedFilterIndex].toLowerCase()); + (filterOptions && filterOptions.length > 0 && filterOptionsValue[selectedFilterIndex]); let options; const limit = 3; @@ -149,11 +162,6 @@ const PostsView = ({ return null; } - // if (isLoading) { - // return null; - // } - - setIsLoading(true); if (filter === 'feed' || filter === 'blog' || getFor === 'blog' || filter === 'reblogs') { options = { tag, @@ -243,8 +251,10 @@ const PostsView = ({ [ currentAccountUsername, filterOptions, + filterOptionsValue, getFor, isConnected, + isLoading, nsfw, posts, promotedPosts, @@ -342,6 +352,7 @@ const PostsView = ({ rightIconType="MaterialIcons" onDropdownSelect={_handleOnDropdownSelect} onRightIconPress={handleImagesHide} + customOption={customOption} /> )} diff --git a/src/components/profile/profileView.js b/src/components/profile/profileView.js index 03f86c0c5..82a1fb5f8 100644 --- a/src/components/profile/profileView.js +++ b/src/components/profile/profileView.js @@ -15,7 +15,7 @@ import { TabBar } from '../tabBar'; import { Wallet } from '../wallet'; // Constants -import { PROFILE_FILTERS } from '../../constants/options/filters'; +import { PROFILE_FILTERS, PROFILE_FILTERS_VALUE } from '../../constants/options/filters'; // Utils import { getFormatedCreatedDate } from '../../utils/time'; @@ -38,13 +38,17 @@ class ProfileView extends PureComponent { _handleOnScroll = () => { const { isSummaryOpen } = this.state; - if (isSummaryOpen) this.setState({ isSummaryOpen: false }); + if (isSummaryOpen) { + this.setState({ isSummaryOpen: false }); + } }; _handleOnSummaryExpanded = () => { const { isSummaryOpen } = this.state; - if (!isSummaryOpen) this.setState({ isSummaryOpen: true }); + if (!isSummaryOpen) { + this.setState({ isSummaryOpen: true }); + } }; _handleUIChange = height => { @@ -156,7 +160,9 @@ class ProfileView extends PureComponent { estimatedWalletValue: 0, oldEstimatedWalletValue: estimatedWalletValue, }); - } else this.setState({ estimatedWalletValue: oldEstimatedWalletValue }); + } else { + this.setState({ estimatedWalletValue: oldEstimatedWalletValue }); + } }} > { return ( @@ -22,9 +27,11 @@ const FeedScreen = () => {