mirror of
https://github.com/ecency/ecency-mobile.git
synced 2024-12-23 21:35:04 +03:00
created acccount container enhanced header container & view convert to hooks && merged trending and feed
This commit is contained in:
parent
2c00cf0502
commit
2acf206205
@ -26,13 +26,15 @@ class BasicHeaderContainer extends Component {
|
|||||||
|
|
||||||
if (isNewPost) {
|
if (isNewPost) {
|
||||||
navigation.navigate({
|
navigation.navigate({
|
||||||
routeName: ROUTES.SCREENS.HOME,
|
routeName: ROUTES.SCREENS.FEED,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
navigation.goBack();
|
navigation.goBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (handleOnBackPress) handleOnBackPress();
|
if (handleOnBackPress) {
|
||||||
|
handleOnBackPress();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -21,7 +21,7 @@ import styles from './bottomTabBarStyles';
|
|||||||
const _jumpTo = (route, index, routes, jumpTo) => {
|
const _jumpTo = (route, index, routes, jumpTo) => {
|
||||||
const _routeName = routes[index].routeName;
|
const _routeName = routes[index].routeName;
|
||||||
|
|
||||||
if (!!get(route, 'params.scrollToTop') && _routeName === ROUTES.TABBAR.HOME) {
|
if (!!get(route, 'params.scrollToTop') && _routeName === ROUTES.TABBAR.FEED) {
|
||||||
route.params.scrollToTop();
|
route.params.scrollToTop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,9 +6,9 @@ export default EStyleSheet.create({
|
|||||||
borderTopRightRadius: 8,
|
borderTopRightRadius: 8,
|
||||||
marginTop: 16,
|
marginTop: 16,
|
||||||
flexDirection: 'row',
|
flexDirection: 'row',
|
||||||
backgroundColor: '$primaryLightBackground',
|
|
||||||
height: 60,
|
height: 60,
|
||||||
borderBottomWidth: 2,
|
borderBottomWidth: 2,
|
||||||
|
backgroundColor: '$primaryWhiteLightBackground',
|
||||||
},
|
},
|
||||||
firstImage: {
|
firstImage: {
|
||||||
width: 24,
|
width: 24,
|
||||||
|
@ -1,80 +1,53 @@
|
|||||||
import React, { PureComponent } from 'react';
|
import React from 'react';
|
||||||
import { withNavigation } from 'react-navigation';
|
import { withNavigation } from 'react-navigation';
|
||||||
import { connect } from 'react-redux';
|
import get from 'lodash/get';
|
||||||
import { get, has } from 'lodash';
|
import has from 'lodash/has';
|
||||||
|
|
||||||
// Component
|
// Component
|
||||||
import HeaderView from '../view/headerView';
|
import HeaderView from '../view/headerView';
|
||||||
|
|
||||||
/*
|
import { AccountContainer, ThemeContainer } from '../../../containers';
|
||||||
* Props Name Description Value
|
|
||||||
*@props --> props name here description here Value Type Here
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
class HeaderContainer extends PureComponent {
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Component Life Cycle Functions
|
|
||||||
|
|
||||||
// Component Functions
|
|
||||||
|
|
||||||
_handleOpenDrawer = () => {
|
|
||||||
const { navigation } = this.props;
|
|
||||||
|
|
||||||
|
const HeaderContainer = ({ selectedUser, isReverse, navigation, handleOnBackPress }) => {
|
||||||
|
const _handleOpenDrawer = () => {
|
||||||
if (has(navigation, 'openDrawer') && typeof get(navigation, 'openDrawer') === 'function') {
|
if (has(navigation, 'openDrawer') && typeof get(navigation, 'openDrawer') === 'function') {
|
||||||
navigation.openDrawer();
|
navigation.openDrawer();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
_handleOnPressBackButton = () => {
|
const _handleOnPressBackButton = () => {
|
||||||
const { navigation, handleOnBackPress } = this.props;
|
if (handleOnBackPress) {
|
||||||
|
handleOnBackPress();
|
||||||
if (handleOnBackPress) handleOnBackPress();
|
}
|
||||||
|
|
||||||
navigation.goBack();
|
navigation.goBack();
|
||||||
};
|
};
|
||||||
|
|
||||||
render() {
|
return (
|
||||||
const {
|
<ThemeContainer>
|
||||||
isLoggedIn,
|
{({ isDarkTheme }) => (
|
||||||
currentAccount,
|
<AccountContainer>
|
||||||
selectedUser,
|
{({ currentAccount, isLoggedIn, isLoginDone }) => {
|
||||||
isReverse,
|
|
||||||
isLoginDone,
|
|
||||||
isDarkTheme,
|
|
||||||
} = this.props;
|
|
||||||
const _user = isReverse && selectedUser ? selectedUser : currentAccount;
|
const _user = isReverse && selectedUser ? selectedUser : currentAccount;
|
||||||
|
|
||||||
const displayName = get(_user, 'display_name');
|
|
||||||
const username = get(_user, 'name');
|
|
||||||
const reputation = get(_user, 'reputation');
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<HeaderView
|
<HeaderView
|
||||||
handleOnPressBackButton={this._handleOnPressBackButton}
|
displayName={get(_user, 'display_name')}
|
||||||
handleOpenDrawer={this._handleOpenDrawer}
|
handleOnPressBackButton={_handleOnPressBackButton}
|
||||||
isLoggedIn={isLoggedIn}
|
handleOpenDrawer={_handleOpenDrawer}
|
||||||
isReverse={isReverse}
|
|
||||||
isLoginDone={isLoginDone}
|
|
||||||
displayName={displayName}
|
|
||||||
username={username}
|
|
||||||
reputation={reputation}
|
|
||||||
isDarkTheme={isDarkTheme}
|
isDarkTheme={isDarkTheme}
|
||||||
|
isLoggedIn={isLoggedIn}
|
||||||
|
isLoginDone={isLoginDone}
|
||||||
|
isReverse={isReverse}
|
||||||
|
reputation={get(_user, 'reputation')}
|
||||||
|
username={get(_user, 'name')}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}}
|
||||||
}
|
</AccountContainer>
|
||||||
|
)}
|
||||||
|
</ThemeContainer>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
export default withNavigation(HeaderContainer);
|
||||||
isLoggedIn: state.application.isLoggedIn,
|
|
||||||
isLoginDone: state.application.isLoginDone,
|
|
||||||
isDarkTheme: state.application.isDarkTheme,
|
|
||||||
|
|
||||||
currentAccount: state.account.currentAccount,
|
|
||||||
});
|
|
||||||
|
|
||||||
export default connect(mapStateToProps)(withNavigation(HeaderContainer));
|
|
||||||
|
@ -7,7 +7,7 @@ export default EStyleSheet.create({
|
|||||||
width: '$deviceWidth',
|
width: '$deviceWidth',
|
||||||
backgroundColor: '$primaryBackgroundColor',
|
backgroundColor: '$primaryBackgroundColor',
|
||||||
flex: 1,
|
flex: 1,
|
||||||
maxHeight: Platform.OS === 'ios' ? 95 : 80,
|
maxHeight: Platform.OS === 'ios' ? 105 : 80,
|
||||||
},
|
},
|
||||||
containerReverse: {
|
containerReverse: {
|
||||||
justifyContent: 'space-between',
|
justifyContent: 'space-between',
|
||||||
@ -33,8 +33,7 @@ export default EStyleSheet.create({
|
|||||||
titleWrapper: {
|
titleWrapper: {
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
marginLeft: 8,
|
marginHorizontal: 8,
|
||||||
marginRight: 8,
|
|
||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
fontSize: 14,
|
fontSize: 14,
|
||||||
|
@ -1,57 +1,35 @@
|
|||||||
import React, { Component } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { View, Text, SafeAreaView, TouchableOpacity } from 'react-native';
|
import { View, Text, SafeAreaView, TouchableOpacity } from 'react-native';
|
||||||
import LinearGradient from 'react-native-linear-gradient';
|
import LinearGradient from 'react-native-linear-gradient';
|
||||||
import { injectIntl } from 'react-intl';
|
import { useIntl } from 'react-intl';
|
||||||
|
|
||||||
// Components
|
// Components
|
||||||
import { SearchModal } from '../../searchModal';
|
import { SearchModal } from '../../searchModal';
|
||||||
import { IconButton } from '../../iconButton';
|
import { IconButton } from '../../iconButton';
|
||||||
import { UserAvatar } from '../../userAvatar';
|
import { UserAvatar } from '../../userAvatar';
|
||||||
|
|
||||||
// Styles
|
// Styles
|
||||||
import styles from './headerStyles';
|
import styles from './headerStyles';
|
||||||
|
|
||||||
class HeaderView extends Component {
|
const HeaderView = ({
|
||||||
/* Props
|
|
||||||
* ------------------------------------------------
|
|
||||||
* @prop { boolean } hideStatusBar - Can declare status bar is hide or not.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = {
|
|
||||||
isSearchModalOpen: false,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Component Life Cycles
|
|
||||||
|
|
||||||
// Component Functions
|
|
||||||
|
|
||||||
_handleOnCloseSearch = () => {
|
|
||||||
this.setState({ isSearchModalOpen: false });
|
|
||||||
};
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const {
|
|
||||||
displayName,
|
displayName,
|
||||||
handleOnPressBackButton,
|
handleOnPressBackButton,
|
||||||
handleOpenDrawer,
|
handleOpenDrawer,
|
||||||
intl,
|
|
||||||
isDarkTheme,
|
isDarkTheme,
|
||||||
isLoggedIn,
|
isLoggedIn,
|
||||||
isLoginDone,
|
isLoginDone,
|
||||||
isReverse,
|
isReverse,
|
||||||
reputation,
|
reputation,
|
||||||
username,
|
username,
|
||||||
} = this.props;
|
}) => {
|
||||||
const { isSearchModalOpen } = this.state;
|
const [isSearchModalOpen, setIsSearchModalOpen] = useState(false);
|
||||||
let gredientColor;
|
const intl = useIntl();
|
||||||
|
let gradientColor;
|
||||||
|
|
||||||
if (isReverse) {
|
if (isReverse) {
|
||||||
gredientColor = isDarkTheme ? ['#43638e', '#081c36'] : ['#357ce6', '#2d5aa0'];
|
gradientColor = isDarkTheme ? ['#43638e', '#081c36'] : ['#357ce6', '#2d5aa0'];
|
||||||
} else {
|
} else {
|
||||||
gredientColor = isDarkTheme ? ['#081c36', '#43638e'] : ['#2d5aa0', '#357ce6'];
|
gradientColor = isDarkTheme ? ['#081c36', '#43638e'] : ['#2d5aa0', '#357ce6'];
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -61,17 +39,17 @@ class HeaderView extends Component {
|
|||||||
id: 'header.search',
|
id: 'header.search',
|
||||||
})}
|
})}
|
||||||
isOpen={isSearchModalOpen}
|
isOpen={isSearchModalOpen}
|
||||||
handleOnClose={this._handleOnCloseSearch}
|
handleOnClose={() => setIsSearchModalOpen(false)}
|
||||||
/>
|
/>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={styles.avatarWrapper}
|
style={styles.avatarWrapper}
|
||||||
onPress={() => handleOpenDrawer()}
|
onPress={handleOpenDrawer}
|
||||||
disabled={isReverse}
|
disabled={isReverse}
|
||||||
>
|
>
|
||||||
<LinearGradient
|
<LinearGradient
|
||||||
start={{ x: 0, y: 0 }}
|
start={{ x: 0, y: 0 }}
|
||||||
end={{ x: 1, y: 0 }}
|
end={{ x: 1, y: 0 }}
|
||||||
colors={gredientColor}
|
colors={gradientColor}
|
||||||
style={[
|
style={[
|
||||||
styles.avatarButtonWrapper,
|
styles.avatarButtonWrapper,
|
||||||
isReverse ? styles.avatarButtonWrapperReverse : styles.avatarDefault,
|
isReverse ? styles.avatarButtonWrapperReverse : styles.avatarDefault,
|
||||||
@ -103,7 +81,8 @@ class HeaderView extends Component {
|
|||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
{isReverse && (
|
|
||||||
|
{isReverse ? (
|
||||||
<View style={styles.reverseBackButtonWrapper}>
|
<View style={styles.reverseBackButtonWrapper}>
|
||||||
<IconButton
|
<IconButton
|
||||||
style={styles.backButton}
|
style={styles.backButton}
|
||||||
@ -112,20 +91,17 @@ class HeaderView extends Component {
|
|||||||
onPress={() => handleOnPressBackButton()}
|
onPress={() => handleOnPressBackButton()}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
)}
|
) : (
|
||||||
|
|
||||||
{!isReverse && (
|
|
||||||
<View style={styles.backButtonWrapper}>
|
<View style={styles.backButtonWrapper}>
|
||||||
<IconButton
|
<IconButton
|
||||||
iconStyle={styles.backIcon}
|
iconStyle={styles.backIcon}
|
||||||
name="md-search"
|
name="md-search"
|
||||||
onPress={() => this.setState({ isSearchModalOpen: true })}
|
onPress={() => setIsSearchModalOpen(true)}
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
)}
|
)}
|
||||||
</SafeAreaView>
|
</SafeAreaView>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
}
|
|
||||||
|
|
||||||
export default injectIntl(HeaderView);
|
export default HeaderView;
|
||||||
|
@ -1,48 +1,18 @@
|
|||||||
import React, { PureComponent } from 'react';
|
import React from 'react';
|
||||||
import { connect } from 'react-redux';
|
import { connect, useDispatch } from 'react-redux';
|
||||||
import get from 'lodash/get';
|
|
||||||
|
|
||||||
// Component
|
// Component
|
||||||
import PostsView from '../view/postsView';
|
import PostsView from '../view/postsView';
|
||||||
|
|
||||||
|
// Container
|
||||||
|
import { AccountContainer } from '../../../containers';
|
||||||
|
|
||||||
// Actions
|
// Actions
|
||||||
import { setFeedPosts } from '../../../redux/actions/postsAction';
|
import { setFeedPosts } from '../../../redux/actions/postsAction';
|
||||||
import { hidePostsThumbnails } from '../../../redux/actions/uiAction';
|
import { hidePostsThumbnails } from '../../../redux/actions/uiAction';
|
||||||
|
|
||||||
/*
|
const PostsContainer = ({
|
||||||
* Props Name Description Value
|
|
||||||
*@props --> props name here description here Value Type Here
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
class PostsContainer extends PureComponent {
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = {
|
|
||||||
promotedPosts: [],
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
// Component Life Cycle Functions
|
|
||||||
|
|
||||||
// Component Functions
|
|
||||||
|
|
||||||
_setFeedPosts = posts => {
|
|
||||||
const { dispatch } = this.props;
|
|
||||||
|
|
||||||
dispatch(setFeedPosts(posts));
|
|
||||||
};
|
|
||||||
|
|
||||||
_handleImagesHide = () => {
|
|
||||||
const { dispatch, isHideImages } = this.props;
|
|
||||||
|
|
||||||
dispatch(hidePostsThumbnails(!isHideImages));
|
|
||||||
};
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const {
|
|
||||||
changeForceLoadPostState,
|
changeForceLoadPostState,
|
||||||
currentAccount,
|
|
||||||
feedPosts,
|
feedPosts,
|
||||||
filterOptions,
|
filterOptions,
|
||||||
forceLoadPost,
|
forceLoadPost,
|
||||||
@ -53,42 +23,47 @@ class PostsContainer extends PureComponent {
|
|||||||
pageType,
|
pageType,
|
||||||
selectedOptionIndex,
|
selectedOptionIndex,
|
||||||
tag,
|
tag,
|
||||||
isLoginDone,
|
|
||||||
isLoggedIn,
|
|
||||||
nsfw,
|
nsfw,
|
||||||
} = this.props;
|
}) => {
|
||||||
const { promotedPosts } = this.state;
|
const dispatch = useDispatch();
|
||||||
|
|
||||||
|
const _setFeedPosts = posts => {
|
||||||
|
dispatch(setFeedPosts(posts));
|
||||||
|
};
|
||||||
|
|
||||||
|
const _handleImagesHide = () => {
|
||||||
|
dispatch(hidePostsThumbnails(!isHideImages));
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
<AccountContainer>
|
||||||
|
{({ username, isLoggedIn, isLoginDone }) => (
|
||||||
<PostsView
|
<PostsView
|
||||||
changeForceLoadPostState={changeForceLoadPostState}
|
changeForceLoadPostState={changeForceLoadPostState}
|
||||||
currentAccountUsername={get(currentAccount, 'name', '')}
|
currentAccountUsername={username}
|
||||||
feedPosts={feedPosts}
|
feedPosts={feedPosts}
|
||||||
filterOptions={filterOptions}
|
filterOptions={filterOptions}
|
||||||
forceLoadPost={forceLoadPost}
|
forceLoadPost={forceLoadPost}
|
||||||
getFor={getFor}
|
getFor={getFor}
|
||||||
|
handleImagesHide={_handleImagesHide}
|
||||||
handleOnScroll={handleOnScroll}
|
handleOnScroll={handleOnScroll}
|
||||||
handleImagesHide={this._handleImagesHide}
|
|
||||||
hidePostsThumbnails={hidePostsThumbnails}
|
hidePostsThumbnails={hidePostsThumbnails}
|
||||||
isConnected={isConnected}
|
isConnected={isConnected}
|
||||||
isHideImage={isHideImages}
|
isHideImage={isHideImages}
|
||||||
pageType={pageType}
|
|
||||||
promotedPosts={promotedPosts}
|
|
||||||
selectedOptionIndex={selectedOptionIndex}
|
|
||||||
setFeedPosts={this._setFeedPosts}
|
|
||||||
tag={tag}
|
|
||||||
isLoginDone={isLoginDone}
|
|
||||||
isLoggedIn={isLoggedIn}
|
isLoggedIn={isLoggedIn}
|
||||||
|
isLoginDone={isLoginDone}
|
||||||
nsfw={nsfw}
|
nsfw={nsfw}
|
||||||
|
pageType={pageType}
|
||||||
|
selectedOptionIndex={selectedOptionIndex}
|
||||||
|
setFeedPosts={_setFeedPosts}
|
||||||
|
tag={tag}
|
||||||
/>
|
/>
|
||||||
|
)}
|
||||||
|
</AccountContainer>
|
||||||
);
|
);
|
||||||
}
|
};
|
||||||
}
|
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
const mapStateToProps = state => ({
|
||||||
currentAccount: state.account.currentAccount,
|
|
||||||
isLoggedIn: state.application.isLoggedIn,
|
|
||||||
isLoginDone: state.application.isLoginDone,
|
|
||||||
nsfw: state.application.nsfw,
|
nsfw: state.application.nsfw,
|
||||||
feedPosts: state.posts.feedPosts,
|
feedPosts: state.posts.feedPosts,
|
||||||
isConnected: state.application.isConnected,
|
isConnected: state.application.isConnected,
|
||||||
|
@ -13,7 +13,6 @@ import { getPromotePosts } from '../../../providers/esteem/esteem';
|
|||||||
import { PostCard } from '../../postCard';
|
import { PostCard } from '../../postCard';
|
||||||
import { FilterBar } from '../../filterBar';
|
import { FilterBar } from '../../filterBar';
|
||||||
import { PostCardPlaceHolder, NoPost } from '../../basicUIElements';
|
import { PostCardPlaceHolder, NoPost } from '../../basicUIElements';
|
||||||
import { POPULAR_FILTERS, PROFILE_FILTERS } from '../../../constants/options/filters';
|
|
||||||
import { ThemeContainer } from '../../../containers';
|
import { ThemeContainer } from '../../../containers';
|
||||||
|
|
||||||
// Styles
|
// Styles
|
||||||
@ -39,15 +38,6 @@ class PostsView extends Component {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Component Functions
|
|
||||||
componentWillMount() {
|
|
||||||
const { navigation } = this.props;
|
|
||||||
|
|
||||||
navigation.setParams({
|
|
||||||
scrollToTop: this._scrollToTop,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
const { isConnected, pageType } = this.props;
|
const { isConnected, pageType } = this.props;
|
||||||
|
|
||||||
@ -97,25 +87,24 @@ class PostsView extends Component {
|
|||||||
_getPromotePosts = async () => {
|
_getPromotePosts = async () => {
|
||||||
const { currentAccountUsername } = this.props;
|
const { currentAccountUsername } = this.props;
|
||||||
|
|
||||||
await getPromotePosts().then(async res => {
|
await getPromotePosts()
|
||||||
|
.then(async res => {
|
||||||
if (res && res.length) {
|
if (res && res.length) {
|
||||||
const promotedPosts = await Promise.all(
|
const promotedPosts = await Promise.all(
|
||||||
res.map(item =>
|
res.map(item =>
|
||||||
getPost(get(item, 'author'), get(item, 'permlink'), currentAccountUsername, true).then(
|
getPost(
|
||||||
post => post,
|
get(item, 'author'),
|
||||||
),
|
get(item, 'permlink'),
|
||||||
|
currentAccountUsername,
|
||||||
|
true,
|
||||||
|
).then(post => post),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
this.setState({ promotedPosts });
|
this.setState({ promotedPosts });
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
};
|
.catch(() => {});
|
||||||
|
|
||||||
_scrollToTop = () => {
|
|
||||||
if (this.flatList) {
|
|
||||||
this.flatList.scrollToOffset({ x: 0, y: 0, animated: true });
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
_loadPosts = async () => {
|
_loadPosts = async () => {
|
||||||
@ -123,10 +112,10 @@ class PostsView extends Component {
|
|||||||
getFor,
|
getFor,
|
||||||
tag,
|
tag,
|
||||||
currentAccountUsername,
|
currentAccountUsername,
|
||||||
pageType,
|
|
||||||
nsfw,
|
nsfw,
|
||||||
setFeedPosts,
|
setFeedPosts,
|
||||||
isConnected,
|
isConnected,
|
||||||
|
filterOptions,
|
||||||
} = this.props;
|
} = this.props;
|
||||||
const {
|
const {
|
||||||
posts,
|
posts,
|
||||||
@ -137,10 +126,7 @@ class PostsView extends Component {
|
|||||||
isLoading,
|
isLoading,
|
||||||
promotedPosts,
|
promotedPosts,
|
||||||
} = this.state;
|
} = this.state;
|
||||||
const filter =
|
const filter = filterOptions[selectedFilterIndex].toLowerCase();
|
||||||
pageType === 'posts'
|
|
||||||
? POPULAR_FILTERS[selectedFilterIndex].toLowerCase()
|
|
||||||
: PROFILE_FILTERS[selectedFilterIndex].toLowerCase();
|
|
||||||
let options;
|
let options;
|
||||||
const limit = 3;
|
const limit = 3;
|
||||||
|
|
||||||
@ -157,12 +143,7 @@ class PostsView extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.setState({ isLoading: true });
|
this.setState({ isLoading: true });
|
||||||
if (tag || filter === 'feed' || filter === 'blog' || getFor === 'blog') {
|
if (filter === 'feed' || filter === 'blog' || getFor === 'blog' || filter === 'reblogs') {
|
||||||
options = {
|
|
||||||
tag,
|
|
||||||
limit,
|
|
||||||
};
|
|
||||||
} else if (filter === 'reblogs') {
|
|
||||||
options = {
|
options = {
|
||||||
tag,
|
tag,
|
||||||
limit,
|
limit,
|
||||||
@ -359,12 +340,7 @@ class PostsView extends Component {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { refreshing, posts, isShowFilterBar } = this.state;
|
const { refreshing, posts, isShowFilterBar } = this.state;
|
||||||
const {
|
const { filterOptions, selectedOptionIndex, isHideImage, handleImagesHide } = this.props;
|
||||||
filterOptions,
|
|
||||||
selectedOptionIndex,
|
|
||||||
isHideImage,
|
|
||||||
handleImagesHide,
|
|
||||||
} = this.props;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
@ -413,9 +389,6 @@ class PostsView extends Component {
|
|||||||
)}
|
)}
|
||||||
</ThemeContainer>
|
</ThemeContainer>
|
||||||
}
|
}
|
||||||
ref={ref => {
|
|
||||||
this.flatList = ref;
|
|
||||||
}}
|
|
||||||
/>
|
/>
|
||||||
</View>
|
</View>
|
||||||
);
|
);
|
||||||
|
@ -15,5 +15,6 @@ export default EStyleSheet.create({
|
|||||||
input: {
|
input: {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
minHeight: 50,
|
minHeight: 50,
|
||||||
|
backgroundColor: '$primaryWhiteLightBackground',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
export const POPULAR_FILTERS = [
|
export const POPULAR_FILTERS = ['TRENDING', 'HOT', 'NEW', 'PROMOTED'];
|
||||||
'TRENDING',
|
|
||||||
'HOT',
|
|
||||||
'CREATED',
|
|
||||||
'ACTIVE',
|
|
||||||
'PROMOTED',
|
|
||||||
'VOTES',
|
|
||||||
'CHILDREN',
|
|
||||||
];
|
|
||||||
export const PROFILE_FILTERS = ['BLOG', 'FEED'];
|
export const PROFILE_FILTERS = ['BLOG', 'FEED'];
|
||||||
|
|
||||||
|
// 'TRENDING',
|
||||||
|
// 'HOT',
|
||||||
|
// 'CREATED',
|
||||||
|
// 'ACTIVE',
|
||||||
|
// 'PROMOTED',
|
||||||
|
// 'VOTES',
|
||||||
|
// 'CHILDREN',
|
||||||
|
@ -11,7 +11,7 @@ export default {
|
|||||||
EDITOR: `Editor${SCREEN_SUFFIX}`,
|
EDITOR: `Editor${SCREEN_SUFFIX}`,
|
||||||
FOLLOWS: `Follows${SCREEN_SUFFIX}`,
|
FOLLOWS: `Follows${SCREEN_SUFFIX}`,
|
||||||
SPIN_GAME: `SpinGame${SCREEN_SUFFIX}`,
|
SPIN_GAME: `SpinGame${SCREEN_SUFFIX}`,
|
||||||
HOME: `Home${SCREEN_SUFFIX}`,
|
FEED: `Feed${SCREEN_SUFFIX}`,
|
||||||
LOGIN: `Login${SCREEN_SUFFIX}`,
|
LOGIN: `Login${SCREEN_SUFFIX}`,
|
||||||
PINCODE: `PinCode${SCREEN_SUFFIX}`,
|
PINCODE: `PinCode${SCREEN_SUFFIX}`,
|
||||||
POST: `Post${SCREEN_SUFFIX}`,
|
POST: `Post${SCREEN_SUFFIX}`,
|
||||||
@ -29,7 +29,7 @@ export default {
|
|||||||
MAIN: `Main${DRAWER_SUFFIX}`,
|
MAIN: `Main${DRAWER_SUFFIX}`,
|
||||||
},
|
},
|
||||||
TABBAR: {
|
TABBAR: {
|
||||||
HOME: `Home${TABBAR_SUFFIX}`,
|
FEED: `Feed${TABBAR_SUFFIX}`,
|
||||||
NOTIFICATION: `Notification${TABBAR_SUFFIX}`,
|
NOTIFICATION: `Notification${TABBAR_SUFFIX}`,
|
||||||
POINTS: `Points${TABBAR_SUFFIX}`,
|
POINTS: `Points${TABBAR_SUFFIX}`,
|
||||||
POST_BUTTON: `PostButton${TABBAR_SUFFIX}`,
|
POST_BUTTON: `PostButton${TABBAR_SUFFIX}`,
|
||||||
|
33
src/containers/accountContainer.js
Normal file
33
src/containers/accountContainer.js
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
/* eslint-disable no-unused-vars */
|
||||||
|
import React from 'react';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
|
const AccountContainer = ({
|
||||||
|
accounts,
|
||||||
|
children,
|
||||||
|
currentAccount,
|
||||||
|
isLoggedIn,
|
||||||
|
isLoginDone,
|
||||||
|
username,
|
||||||
|
}) => {
|
||||||
|
return (
|
||||||
|
children &&
|
||||||
|
children({
|
||||||
|
accounts,
|
||||||
|
currentAccount,
|
||||||
|
isLoggedIn,
|
||||||
|
isLoginDone,
|
||||||
|
username,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const mapStateToProps = state => ({
|
||||||
|
accounts: state.account.otherAccounts,
|
||||||
|
currentAccount: state.account.currentAccount,
|
||||||
|
isLoggedIn: state.application.isLoggedIn,
|
||||||
|
isLoginDone: state.application.isLoginDone,
|
||||||
|
username: state.account.currentAccount.name,
|
||||||
|
});
|
||||||
|
|
||||||
|
export default connect(mapStateToProps)(AccountContainer);
|
@ -1,3 +1,4 @@
|
|||||||
|
import AccountContainer from './accountContainer';
|
||||||
import InAppPurchaseContainer from './inAppPurchaseContainer';
|
import InAppPurchaseContainer from './inAppPurchaseContainer';
|
||||||
import PointsContainer from './pointsContainer';
|
import PointsContainer from './pointsContainer';
|
||||||
import ProfileContainer from './profileContainer';
|
import ProfileContainer from './profileContainer';
|
||||||
@ -8,6 +9,7 @@ import TransferContainer from './transferContainer';
|
|||||||
import ThemeContainer from './themeContainer';
|
import ThemeContainer from './themeContainer';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
|
AccountContainer,
|
||||||
InAppPurchaseContainer,
|
InAppPurchaseContainer,
|
||||||
PointsContainer,
|
PointsContainer,
|
||||||
ProfileContainer,
|
ProfileContainer,
|
||||||
|
@ -6,13 +6,13 @@ import ROUTES from '../constants/routeNames';
|
|||||||
|
|
||||||
// Components
|
// Components
|
||||||
import { Icon, IconContainer } from '../components/icon';
|
import { Icon, IconContainer } from '../components/icon';
|
||||||
import { Home, Notification, Profile, Points } from '../screens';
|
import { Feed, Notification, Profile, Points } from '../screens';
|
||||||
import { PostButton, BottomTabBar } from '../components';
|
import { PostButton, BottomTabBar } from '../components';
|
||||||
|
|
||||||
const BaseNavigator = createBottomTabNavigator(
|
const BaseNavigator = createBottomTabNavigator(
|
||||||
{
|
{
|
||||||
[ROUTES.TABBAR.HOME]: {
|
[ROUTES.TABBAR.FEED]: {
|
||||||
screen: Home,
|
screen: Feed,
|
||||||
navigationOptions: () => ({
|
navigationOptions: () => ({
|
||||||
tabBarIcon: ({ tintColor }) => (
|
tabBarIcon: ({ tintColor }) => (
|
||||||
<Icon iconType="MaterialIcons" name="view-day" color={tintColor} size={26} />
|
<Icon iconType="MaterialIcons" name="view-day" color={tintColor} size={26} />
|
||||||
|
@ -31,7 +31,7 @@ import { SideMenu } from '../components';
|
|||||||
|
|
||||||
const mainNavigation = createDrawerNavigator(
|
const mainNavigation = createDrawerNavigator(
|
||||||
{
|
{
|
||||||
[ROUTES.SCREENS.HOME]: {
|
[ROUTES.SCREENS.FEED]: {
|
||||||
screen: BaseNavigator,
|
screen: BaseNavigator,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -357,7 +357,13 @@ export const getSCAccessToken = code =>
|
|||||||
api.post('/sc-token-refresh', { code }).then(resp => resolve(resp.data));
|
api.post('/sc-token-refresh', { code }).then(resp => resolve(resp.data));
|
||||||
});
|
});
|
||||||
|
|
||||||
export const getPromotePosts = () => api.get('/promoted-posts').then(resp => resp.data);
|
export const getPromotePosts = () => {
|
||||||
|
try {
|
||||||
|
return api.get('/promoted-posts').then(resp => resp.data);
|
||||||
|
} catch (error) {
|
||||||
|
return error;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
export const purchaseOrder = data => api.post('/purchase-order', data).then(resp => resp.data);
|
export const purchaseOrder = data => api.post('/purchase-order', data).then(resp => resp.data);
|
||||||
|
|
||||||
|
4
src/screens/feed/index.js
Normal file
4
src/screens/feed/index.js
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
import Feed from './screen/feedScreen';
|
||||||
|
|
||||||
|
export { Feed };
|
||||||
|
export default Feed;
|
36
src/screens/feed/screen/feedScreen.js
Normal file
36
src/screens/feed/screen/feedScreen.js
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
import React, { Fragment } from 'react';
|
||||||
|
import { SafeAreaView } from 'react-native';
|
||||||
|
import get from 'lodash/get';
|
||||||
|
|
||||||
|
// Components
|
||||||
|
import { Posts, Header } from '../../../components';
|
||||||
|
|
||||||
|
// Container
|
||||||
|
import { AccountContainer } from '../../../containers';
|
||||||
|
|
||||||
|
// Styles
|
||||||
|
import styles from './feedStyles';
|
||||||
|
|
||||||
|
import { POPULAR_FILTERS, PROFILE_FILTERS } from '../../../constants/options/filters';
|
||||||
|
|
||||||
|
const FeedScreen = () => {
|
||||||
|
return (
|
||||||
|
<AccountContainer>
|
||||||
|
{({ currentAccount, isLoggedIn }) => (
|
||||||
|
<Fragment>
|
||||||
|
<Header />
|
||||||
|
<SafeAreaView style={styles.container}>
|
||||||
|
<Posts
|
||||||
|
filterOptions={[...PROFILE_FILTERS, ...POPULAR_FILTERS]}
|
||||||
|
getFor={isLoggedIn ? 'feed' : 'trending'}
|
||||||
|
selectedOptionIndex={isLoggedIn ? 1 : 2}
|
||||||
|
tag={get(currentAccount, 'name')}
|
||||||
|
/>
|
||||||
|
</SafeAreaView>
|
||||||
|
</Fragment>
|
||||||
|
)}
|
||||||
|
</AccountContainer>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default FeedScreen;
|
@ -1,38 +0,0 @@
|
|||||||
import React, { PureComponent } from 'react';
|
|
||||||
import { connect } from 'react-redux';
|
|
||||||
|
|
||||||
// Component
|
|
||||||
import HomeScreen from '../screen/homeScreen';
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Props Name Description Value
|
|
||||||
*@props --> props name here description here Value Type Here
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
class HomeContainer extends PureComponent {
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const { isLoggedIn, isLoginDone, currentAccount } = this.props;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<HomeScreen
|
|
||||||
isLoggedIn={isLoggedIn}
|
|
||||||
isLoginDone={isLoginDone}
|
|
||||||
currentAccount={currentAccount}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const mapStateToProps = state => ({
|
|
||||||
isLoggedIn: state.application.isLoggedIn,
|
|
||||||
isLoginDone: state.application.isLoginDone,
|
|
||||||
currentAccount: state.account.currentAccount,
|
|
||||||
});
|
|
||||||
|
|
||||||
export default connect(mapStateToProps)(HomeContainer);
|
|
@ -1,5 +0,0 @@
|
|||||||
import HomeScreen from './screen/homeScreen';
|
|
||||||
import Home from './container/homeContainer';
|
|
||||||
|
|
||||||
export { HomeScreen, Home };
|
|
||||||
export default Home;
|
|
@ -1,73 +0,0 @@
|
|||||||
import React, { PureComponent, Fragment } from 'react';
|
|
||||||
import { View, SafeAreaView } from 'react-native';
|
|
||||||
import ScrollableTabView from 'react-native-scrollable-tab-view';
|
|
||||||
import { injectIntl } from 'react-intl';
|
|
||||||
|
|
||||||
// Components
|
|
||||||
import { TabBar, Posts, Header } from '../../../components';
|
|
||||||
|
|
||||||
// Styles
|
|
||||||
import styles from './homeStyles';
|
|
||||||
import globalStyles from '../../../globalStyles';
|
|
||||||
|
|
||||||
import { POPULAR_FILTERS, PROFILE_FILTERS } from '../../../constants/options/filters';
|
|
||||||
|
|
||||||
class HomeScreen extends PureComponent {
|
|
||||||
constructor(props) {
|
|
||||||
super(props);
|
|
||||||
this.state = {};
|
|
||||||
}
|
|
||||||
|
|
||||||
render() {
|
|
||||||
const { currentAccount, intl, isLoggedIn } = this.props;
|
|
||||||
|
|
||||||
return (
|
|
||||||
<Fragment>
|
|
||||||
<Header />
|
|
||||||
<SafeAreaView style={styles.container}>
|
|
||||||
<ScrollableTabView
|
|
||||||
style={globalStyles.tabView}
|
|
||||||
activeTab={!isLoggedIn ? 1 : 0}
|
|
||||||
renderTabBar={() => (
|
|
||||||
<TabBar
|
|
||||||
style={styles.tabbar}
|
|
||||||
tabUnderlineDefaultWidth={80}
|
|
||||||
tabUnderlineScaleX={2}
|
|
||||||
tabBarPosition="overlayTop"
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<View
|
|
||||||
tabLabel={intl.formatMessage({
|
|
||||||
id: 'home.feed',
|
|
||||||
})}
|
|
||||||
style={styles.tabbarItem}
|
|
||||||
>
|
|
||||||
<Posts
|
|
||||||
filterOptions={PROFILE_FILTERS}
|
|
||||||
getFor={PROFILE_FILTERS[1].toLowerCase()}
|
|
||||||
tag={currentAccount.name}
|
|
||||||
selectedOptionIndex={1}
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
<View
|
|
||||||
tabLabel={intl.formatMessage({
|
|
||||||
id: 'home.popular',
|
|
||||||
})}
|
|
||||||
style={styles.tabbarItem}
|
|
||||||
>
|
|
||||||
<Posts
|
|
||||||
filterOptions={POPULAR_FILTERS}
|
|
||||||
getFor={POPULAR_FILTERS[0].toLowerCase()}
|
|
||||||
selectedOptionIndex={0}
|
|
||||||
pageType="posts"
|
|
||||||
/>
|
|
||||||
</View>
|
|
||||||
</ScrollableTabView>
|
|
||||||
</SafeAreaView>
|
|
||||||
</Fragment>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export default injectIntl(HomeScreen);
|
|
@ -2,7 +2,7 @@ import { Bookmarks } from './bookmarks';
|
|||||||
import { Drafts } from './drafts';
|
import { Drafts } from './drafts';
|
||||||
import { Editor } from './editor';
|
import { Editor } from './editor';
|
||||||
import { Follows } from './follows';
|
import { Follows } from './follows';
|
||||||
import { Home } from './home';
|
import { Feed } from './feed';
|
||||||
import { Launch } from './launch';
|
import { Launch } from './launch';
|
||||||
import { Login } from './login';
|
import { Login } from './login';
|
||||||
import { Notification } from './notification';
|
import { Notification } from './notification';
|
||||||
@ -27,7 +27,7 @@ export {
|
|||||||
Drafts,
|
Drafts,
|
||||||
Editor,
|
Editor,
|
||||||
Follows,
|
Follows,
|
||||||
Home,
|
Feed,
|
||||||
Launch,
|
Launch,
|
||||||
Login,
|
Login,
|
||||||
Notification,
|
Notification,
|
||||||
|
@ -108,7 +108,9 @@ class PinCodeContainer extends Component {
|
|||||||
dispatch(updateCurrentAccount({ ..._currentAccount }));
|
dispatch(updateCurrentAccount({ ..._currentAccount }));
|
||||||
this._savePinCode(pin);
|
this._savePinCode(pin);
|
||||||
|
|
||||||
if (callback) callback(pin, oldPinCode);
|
if (callback) {
|
||||||
|
callback(pin, oldPinCode);
|
||||||
|
}
|
||||||
dispatch(closePinCodeModal());
|
dispatch(closePinCodeModal());
|
||||||
if (navigateTo) {
|
if (navigateTo) {
|
||||||
const navigateAction = NavigationActions.navigate({
|
const navigateAction = NavigationActions.navigate({
|
||||||
@ -171,7 +173,9 @@ class PinCodeContainer extends Component {
|
|||||||
|
|
||||||
setExistUser(true).then(() => {
|
setExistUser(true).then(() => {
|
||||||
this._savePinCode(pin);
|
this._savePinCode(pin);
|
||||||
if (callback) callback(pin, oldPinCode);
|
if (callback) {
|
||||||
|
callback(pin, oldPinCode);
|
||||||
|
}
|
||||||
dispatch(closePinCodeModal());
|
dispatch(closePinCodeModal());
|
||||||
if (navigateTo) {
|
if (navigateTo) {
|
||||||
const navigateAction = NavigationActions.navigate({
|
const navigateAction = NavigationActions.navigate({
|
||||||
@ -197,7 +201,7 @@ class PinCodeContainer extends Component {
|
|||||||
} = this.props;
|
} = this.props;
|
||||||
const { oldPinCode } = this.state;
|
const { oldPinCode } = this.state;
|
||||||
|
|
||||||
// If the user is exist, we are just checking to pin and navigating to home screen
|
// If the user is exist, we are just checking to pin and navigating to feed screen
|
||||||
const pinData = {
|
const pinData = {
|
||||||
pinCode: pin,
|
pinCode: pin,
|
||||||
password: currentAccount ? currentAccount.password : '',
|
password: currentAccount ? currentAccount.password : '',
|
||||||
@ -213,7 +217,9 @@ class PinCodeContainer extends Component {
|
|||||||
[_currentAccount.local] = realmData;
|
[_currentAccount.local] = realmData;
|
||||||
dispatch(updateCurrentAccount({ ..._currentAccount }));
|
dispatch(updateCurrentAccount({ ..._currentAccount }));
|
||||||
dispatch(closePinCodeModal());
|
dispatch(closePinCodeModal());
|
||||||
if (callback) callback(pin, oldPinCode);
|
if (callback) {
|
||||||
|
callback(pin, oldPinCode);
|
||||||
|
}
|
||||||
if (navigateTo) {
|
if (navigateTo) {
|
||||||
const navigateAction = NavigationActions.navigate({
|
const navigateAction = NavigationActions.navigate({
|
||||||
routeName: navigateTo,
|
routeName: navigateTo,
|
||||||
|
Loading…
Reference in New Issue
Block a user