From b87c94e6d95169df2f14ce489a248506a755139f Mon Sep 17 00:00:00 2001 From: dan Date: Mon, 18 Nov 2024 21:51:23 +0000 Subject: Extract RepostButton inner dialog (#6498) * Extract RepostButton inner dialog * use `useDialogContext` instead of passing prop --------- Co-authored-by: Samuel Newman --- src/view/com/util/post-ctrls/RepostButton.tsx | 188 +++++++++++++++----------- 1 file changed, 109 insertions(+), 79 deletions(-) (limited to 'src/view/com/util/post-ctrls/RepostButton.tsx') diff --git a/src/view/com/util/post-ctrls/RepostButton.tsx b/src/view/com/util/post-ctrls/RepostButton.tsx index 28889429f..eb7505d2e 100644 --- a/src/view/com/util/post-ctrls/RepostButton.tsx +++ b/src/view/com/util/post-ctrls/RepostButton.tsx @@ -36,16 +36,12 @@ let RepostButton = ({ const requireAuth = useRequireAuth() const dialogControl = Dialog.useDialogControl() const playHaptic = useHaptics() - const color = React.useMemo( () => ({ color: isReposted ? t.palette.positive_600 : t.palette.contrast_500, }), [t, isReposted], ) - - const close = useCallback(() => dialogControl.close(), [dialogControl]) - return ( <> - - - - - + ) } RepostButton = memo(RepostButton) export {RepostButton} + +let RepostButtonDialogInner = ({ + isReposted, + onRepost, + onQuote, + embeddingDisabled, +}: { + isReposted: boolean + onRepost: () => void + onQuote: () => void + embeddingDisabled: boolean +}): React.ReactNode => { + const t = useTheme() + const {_} = useLingui() + const playHaptic = useHaptics() + const control = Dialog.useDialogContext() + + const onPressRepost = useCallback(() => { + if (!isReposted) playHaptic() + + control.close(() => { + onRepost() + }) + }, [control, isReposted, onRepost, playHaptic]) + + const onPressQuote = useCallback(() => { + playHaptic() + control.close(() => { + onQuote() + }) + }, [control, onQuote, playHaptic]) + + const onPressClose = useCallback(() => control.close(), [control]) + + return ( + + + + + + + + + + ) +} +RepostButtonDialogInner = memo(RepostButtonDialogInner) +export {RepostButtonDialogInner} -- cgit 1.4.1 From a5dbb35237d014a07c0f3f82e9dffce67129e542 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Fri, 22 Nov 2024 13:41:24 +0000 Subject: Use outline style for repost cancel button (#6509) * use outline style for repost cancel button * use trans macro in JSX --- src/view/com/util/post-ctrls/RepostButton.tsx | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) (limited to 'src/view/com/util/post-ctrls/RepostButton.tsx') diff --git a/src/view/com/util/post-ctrls/RepostButton.tsx b/src/view/com/util/post-ctrls/RepostButton.tsx index eb7505d2e..06b1fcaf6 100644 --- a/src/view/com/util/post-ctrls/RepostButton.tsx +++ b/src/view/com/util/post-ctrls/RepostButton.tsx @@ -1,6 +1,6 @@ import React, {memo, useCallback} from 'react' import {View} from 'react-native' -import {msg, plural} from '@lingui/macro' +import {msg, plural, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {POST_CTRL_HITSLOP} from '#/lib/constants' @@ -151,9 +151,11 @@ let RepostButtonDialogInner = ({ color="primary"> - {isReposted - ? _(msg`Remove repost`) - : _(msg({message: `Repost`, context: 'action'}))} + {isReposted ? ( + Remove repost + ) : ( + Repost + )} @@ -193,9 +197,11 @@ let RepostButtonDialogInner = ({ label={_(msg`Cancel quote post`)} onPress={onPressClose} size="large" - variant="solid" + variant="outline" color="primary"> - {_(msg`Cancel`)} + + Cancel + -- cgit 1.4.1