From 75c9da931c87a7514b1566f75cae1442a153441b Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Wed, 3 Apr 2024 11:03:54 -0700 Subject: [PATCH] Add share warning to big share button in post ctrl (#3367) --- src/components/Prompt.tsx | 7 +- src/view/com/util/forms/PostDropdownBtn.tsx | 52 ++++++------- src/view/com/util/post-ctrls/PostCtrls.tsx | 86 ++++++++++++++------- 3 files changed, 87 insertions(+), 58 deletions(-) diff --git a/src/components/Prompt.tsx b/src/components/Prompt.tsx index b81b207075..37d1b700aa 100644 --- a/src/components/Prompt.tsx +++ b/src/components/Prompt.tsx @@ -3,11 +3,10 @@ import {View} from 'react-native' import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' -import {useTheme, atoms as a, useBreakpoints} from '#/alf' -import {Text} from '#/components/Typography' +import {atoms as a, useBreakpoints, useTheme} from '#/alf' import {Button, ButtonColor, ButtonText} from '#/components/Button' - import * as Dialog from '#/components/Dialog' +import {Text} from '#/components/Typography' export {useDialogControl as usePromptControl} from '#/components/Dialog' @@ -80,7 +79,7 @@ export function Actions({children}: React.PropsWithChildren<{}>) { { + return !!post.author.labels?.find( + label => label.val === '!no-unauthenticated', + ) + }, [post]) const defaultCtrlColor = React.useMemo( () => ({ @@ -209,18 +219,38 @@ let PostCtrls = ({ {big && ( - - - - - + <> + + { + if (shouldShowLoggedOutWarning) { + loggedOutWarningPromptControl.open() + } else { + onShare() + } + }} + accessibilityRole="button" + accessibilityLabel={`${_(msg`Share`)}`} + accessibilityHint="" + hitSlop={big ? HITSLOP_20 : HITSLOP_10}> + + + + + )}