Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "fix: nsfw images now open iimage viewer in compact mode" #701

Merged
merged 1 commit into from
Jul 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 0 additions & 42 deletions src/components/common/Comments/CommentActions.tsx

This file was deleted.

63 changes: 0 additions & 63 deletions src/components/common/Comments/CommentHeader.tsx

This file was deleted.

110 changes: 93 additions & 17 deletions src/components/common/Comments/CommentItem.tsx
Original file line number Diff line number Diff line change
@@ -1,31 +1,49 @@
import { Divider, Pressable, useTheme, View, VStack } from "native-base";
import {
Divider,
HStack,
Pressable,
Text,
useTheme,
View,
VStack,
} from "native-base";
import React from "react";
import {
IconChevronDown,
IconDots,
IconMessagePlus,
} from "tabler-icons-react-native";
import { timeFromNowShort } from "../../../helpers/TimeHelper";
import useComment from "../../../hooks/post/useComment";
import ILemmyComment from "../../../types/lemmy/ILemmyComment";
import { ILemmyVote } from "../../../types/lemmy/ILemmyVote";
import AvatarUsername from "../AvatarUsername";
import IconButtonWithText from "../IconButtonWithText";
import { ReplyOption } from "../SwipeableRow/ReplyOption";
import { SwipeableRow } from "../SwipeableRow/SwipeableRow";
import { VoteOption } from "../SwipeableRow/VoteOption";
import SmallVoteIcons from "../Vote/SmallVoteIcons";
import VoteButton from "../Vote/VoteButton";
import CommentBody from "./CommentBody";
import CommentCollapsed from "./CommentCollapsed";
import { selectSettings } from "../../../slices/settings/settingsSlice";
import { useAppSelector } from "../../../../store";
import { getBaseUrl } from "../../../helpers/LinkHelper";
import CommentActions from "./CommentActions";
import CommentHeader from "./CommentHeader";

interface IProps {
comment: ILemmyComment;
setComments: any;
onPressOverride?: () => Promise<void> | void;
depth?: number;
opId?: number;
isUnreadReply?: boolean;
}

function CommentItem({
comment,
setComments,
onPressOverride,
opId,
depth,
isUnreadReply,
}: IProps) {
Expand All @@ -42,6 +60,8 @@ function CommentItem({
onPressOverride,
});

const myVote = comment.comment.my_vote;

return (
<>
<SwipeableRow
Expand Down Expand Up @@ -83,15 +103,42 @@ function CommentItem({
pl={depth > 2 ? 2 : 0}
mt={0}
>
<CommentHeader
myVote={comment.comment.my_vote as ILemmyVote}
collapsed={comment.collapsed}
counts={comment.comment.counts}
opId={comment.comment.post.creator_id}
creator={comment.comment.creator}
onButtonPress={commentHook.onCommentLongPress}
published={comment.comment.comment.published}
/>
<HStack
space={2}
justifyContent="space-between"
alignItems="center"
mb={-3}
pb={2}
>
<AvatarUsername creator={comment.comment.creator} opId={opId}>
<SmallVoteIcons
upvotes={comment.comment.counts.upvotes}
downvotes={comment.comment.counts.downvotes}
myVote={comment.comment.my_vote as ILemmyVote}
/>
</AvatarUsername>
{!comment.collapsed ? (
<HStack alignItems="center" space={2}>
<IconButtonWithText
onPressHandler={commentHook.onCommentLongPress}
icon={
<IconDots
size={24}
color={theme.colors.app.textSecondary}
/>
}
/>
<Text color={theme.colors.app.textSecondary}>
{timeFromNowShort(comment.comment.comment.published)}
</Text>
</HStack>
) : (
<IconChevronDown
size={24}
color={theme.colors.app.textSecondary}
/>
)}
</HStack>
{comment.collapsed ? (
<CommentCollapsed />
) : (
Expand All @@ -103,11 +150,40 @@ function CommentItem({
instance={getBaseUrl(comment.comment.comment.ap_id)}
/>
{settings.showCommentActions && (
<CommentActions
onVote={commentHook.onVote}
onReply={commentHook.onReply}
myVote={comment.comment.my_vote as ILemmyVote}
/>
<HStack justifyContent="flex-end" space={2} mb={1}>
<IconButtonWithText
onPressHandler={commentHook.onReply}
icon={
<IconMessagePlus
color={theme.colors.app.accent}
size={22}
/>
}
/>
<VoteButton
onPressHandler={async () =>
myVote === 1
? commentHook.onVote(0)
: commentHook.onVote(1)
}
type="upvote"
isVoted={myVote === 1}
isAccented
iconSize={22}
/>
<VoteButton
onPressHandler={async () =>
myVote === -1
? commentHook.onVote(0)
: commentHook.onVote(-1)
}
type="downvote"
isVoted={myVote === -1}
isAccented
iconSize={22}
textSize="md"
/>
</HStack>
)}
</>
)}
Expand Down
12 changes: 10 additions & 2 deletions src/components/common/ImageViewer/ImageExitButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,19 @@ import { IconX } from "tabler-icons-react-native";

interface IProps {
onPress: () => void;
visible: boolean;
}

function ImageExitButton({ onPress }: IProps) {
function ImageExitButton({ onPress, visible }: IProps) {
return (
<View style={[styles.buttonPosition]}>
<View
style={[
styles.buttonPosition,
{
opacity: visible ? 0.5 : 0,
},
]}
>
<Pressable onPress={onPress} hitSlop={10} padding={1.5}>
<View>
<IconX color="white" />
Expand Down
11 changes: 9 additions & 2 deletions src/components/common/ImageViewer/ImageViewFooter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import { saveImage } from "../../../helpers/ImageHelper";

interface ImageViewFooterProps {
source: string;
visible: boolean;
}

function ImageViewFooter({ source }: ImageViewFooterProps) {
function ImageViewFooter({ source, visible }: ImageViewFooterProps) {
const theme = useTheme();

const onSave = async () => {
Expand All @@ -32,7 +33,13 @@ function ImageViewFooter({ source }: ImageViewFooterProps) {
};

return (
<View position="absolute" bottom={0} width="100%" zIndex={2}>
<View
position="absolute"
bottom={0}
width="100%"
zIndex={2}
opacity={visible ? 1 : 0}
>
<HStack
flex={1}
mb={10}
Expand Down
Loading
Loading