Skip to content

Commit

Permalink
Merge pull request #2740 from ecency/nt/waves
Browse files Browse the repository at this point in the history
Nt/waves
  • Loading branch information
feruzm authored Aug 30, 2023
2 parents a920a12 + 496dedb commit 0c530f2
Show file tree
Hide file tree
Showing 45 changed files with 1,263 additions and 406 deletions.
1 change: 1 addition & 0 deletions src/components/atoms/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export * from './optionsModal';
export * from './progressBar';
export * from './assetIcon';
export * from './writePostButton';
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,17 @@ import { View, Text, TouchableOpacity } from 'react-native';
import React, { forwardRef, useImperativeHandle, useRef } from 'react';
import { View as AnimatedView } from 'react-native-animatable';
import { useIntl } from 'react-intl';
import UserAvatar from '../../userAvatar';
import styles from '../styles/writeCommentButton.styles';
import { useAppSelector } from '../../../hooks';
import showLoginAlert from '../../../utils/showLoginAlert';
import UserAvatar from '../../../userAvatar';
import styles from '../styles/writePostButton.styles';
import { useAppSelector } from '../../../../hooks';
import showLoginAlert from '../../../../utils/showLoginAlert';

interface WriteCommentButtonProps {
interface WritePostButtonProps {
placeholderId: string;
onPress: () => void;
}

export const WriteCommentButton = forwardRef(({ onPress }: WriteCommentButtonProps, ref) => {
export const WritePostButton = forwardRef(({ placeholderId: placeholder, onPress }: WritePostButtonProps, ref) => {
const intl = useIntl();

const animatedContainer = useRef<AnimatedView>();
Expand Down Expand Up @@ -45,7 +46,7 @@ export const WriteCommentButton = forwardRef(({ onPress }: WriteCommentButtonPro
<UserAvatar username={currentAccount.username} />
<View style={styles.inputContainer}>
<Text style={styles.inputPlaceholder}>
{intl.formatMessage({ id: 'quick_reply.placeholder' })}
{intl.formatMessage({ id: placeholder })}
</Text>
</View>
</View>
Expand Down
1 change: 1 addition & 0 deletions src/components/atoms/writePostButton/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './container/writePostButton';
31 changes: 28 additions & 3 deletions src/components/bottomTabBar/view/bottomTabBarView.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { useEffect } from 'react';
import { SafeAreaView, View, TouchableOpacity } from 'react-native';
import { SafeAreaView, View, TouchableOpacity, Alert } from 'react-native';

// Components
// import TabBar from './tabbar';
Expand All @@ -13,22 +13,41 @@ import ROUTES from '../../../constants/routeNames';
import styles from './bottomTabBarStyles';
import Icon, { IconContainer } from '../../icon';
import scalePx from '../../../utils/scalePx';
import { updateActiveBottomTab } from '../../../redux/actions/uiAction';
import { showReplyModal, updateActiveBottomTab } from '../../../redux/actions/uiAction';
import { useAppSelector } from '../../../hooks';
import showLoginAlert from '../../../utils/showLoginAlert';
import { useIntl } from 'react-intl';

const BottomTabBarView = ({
state: { routes, index },
navigation,
descriptors,
}: BottomTabBarProps) => {
const intl = useIntl();
const dispatch = useDispatch();
const isLoggedIn = useAppSelector((state) => state.application.isLoggedIn);

useEffect(() => {
dispatch(updateActiveBottomTab(routes[index].name));
}, [index]);



const _jumpTo = (route, isFocused) => {

if (route.name === ROUTES.TABBAR.POST_BUTTON) {
navigation.navigate(ROUTES.SCREENS.EDITOR, { key: 'editor_post' });

if(!isLoggedIn){
showLoginAlert({intl})
return;
}

if (routes[index].name === ROUTES.TABBAR.WAVES) {
dispatch(showReplyModal({mode:'wave'}));
} else {
navigation.navigate(ROUTES.SCREENS.EDITOR, { key: 'editor_post' });
}

return;
}

Expand All @@ -44,6 +63,8 @@ const BottomTabBarView = ({
}
};



const _tabButtons = routes.map((route, idx) => {
const { tabBarActiveTintColor, tabBarInactiveTintColor } = descriptors[route.key].options;
const isFocused = index == idx;
Expand All @@ -63,9 +84,11 @@ const BottomTabBarView = ({
_tabBarIcon = <IconContainer isBadge badgeType="notification" {..._iconProps} />;
break;
case ROUTES.TABBAR.POST_BUTTON:
case ROUTES.TABBAR.WAVES:
_iconProps.iconType = 'MaterialCommunityIcons';
_tabBarIcon = <Icon {..._iconProps} />;
break;

}

return (
Expand All @@ -75,6 +98,8 @@ const BottomTabBarView = ({
);
});



return <SafeAreaView style={styles.wrapper}>{_tabButtons}</SafeAreaView>;
};

Expand Down
9 changes: 7 additions & 2 deletions src/components/comment/view/commentView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ const CommentView = ({
const _currentUsername = currentAccountUsername || currentAccount?.username;

const _showSubCommentsToggle = async (force = false) => {
if ((replies && replies.length > 0) || force) {
if (!!comment.commentKey && ((replies && replies.length > 0) || force)) {
setIsOpeningReplies(true);
await delay(10); // hack to rendering inidcator first before start loading comments
handleOnToggleReplies(comment.commentKey);
Expand All @@ -71,9 +71,13 @@ const CommentView = ({
}
};

const _handleOnContentPress = () => {
openReplyThread(comment);
}

const _handleOnReplyPress = () => {
if (isLoggedIn) {
dispatch(showReplyModal(comment));
dispatch(showReplyModal({mode:'comment', parentPost:comment}));
} else {
console.log('Not LoggedIn');
}
Expand All @@ -98,6 +102,7 @@ const CommentView = ({
<CommentBody
commentDepth={_depth}
reputation={comment.author_reputation}
handleOnContentPress={_handleOnContentPress}
handleOnUserPress={handleOnUserPress}
handleOnLongPress={() => handleOnLongPress(comment)}
handleLinkPress={handleLinkPress}
Expand Down
2 changes: 2 additions & 0 deletions src/components/comments/container/commentsContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const CommentsContainer = ({
isLoggedIn,
commentNumber,
mainAuthor,
handleOnOptionsPress,
selectedPermlink,
isHideImage,
isShowSubComments,
Expand Down Expand Up @@ -296,6 +297,7 @@ const CommentsContainer = ({
fetchPost={fetchPost}
handleDeleteComment={_handleDeleteComment}
handleOnPressCommentMenu={_handleOnPressCommentMenu}
handleOnOptionsPress={handleOnOptionsPress}
isOwnProfile={isOwnProfile}
isHideImage={isHideImage}
handleOnVotersPress={_handleOnVotersPress}
Expand Down
32 changes: 21 additions & 11 deletions src/components/comments/view/commentsView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const CommentsView = ({
isLoggedIn,
isShowSubComments,
mainAuthor,
handleOnOptionsPress,
marginLeft,
showAllComments,
hideManyCommentsButton,
Expand All @@ -48,7 +49,10 @@ const CommentsView = ({
const postInteractionRef = useRef(null);

const _openCommentMenu = (item) => {
if (commentMenu.current) {

if (handleOnOptionsPress) {
handleOnOptionsPress(item);
} else if (commentMenu.current) {
setSelectedComment(item);
commentMenu.current.show();
}
Expand Down Expand Up @@ -139,9 +143,9 @@ const CommentsView = ({
const styleOerride =
commentNumber > 1
? {
backgroundColor: EStyleSheet.value('$primaryLightBackground'),
marginTop: 8,
}
backgroundColor: EStyleSheet.value('$primaryLightBackground'),
marginTop: 8,
}
: null;

const _renderEmptyContent = () => {
Expand Down Expand Up @@ -169,15 +173,21 @@ const CommentsView = ({
ListEmptyComponent={_renderEmptyContent()}
ListHeaderComponent={postContentView}
overScrollMode="never"
onEndReachedThreshold={1}
maxToRenderPerBatch={7}
initialNumToRender={5}
windowSize={10}
{...flatListProps}
/>
<OptionsModal
ref={commentMenu}
options={menuItems}
title={get(selectedComment, 'summary')}
cancelButtonIndex={3}
onPress={_onMenuItemPress}
/>
{!handleOnOptionsPress && (
<OptionsModal
ref={commentMenu}
options={menuItems}
title={get(selectedComment, 'summary')}
cancelButtonIndex={3}
onPress={_onMenuItemPress}
/>
)}
<UpvotePopover ref={upvotePopoverRef} />
<PostHtmlInteractionHandler ref={postInteractionRef} />
</Fragment>
Expand Down
Loading

0 comments on commit 0c530f2

Please sign in to comment.