From 64c9d864889f54ae89aa91eabd31d51b49b29929 Mon Sep 17 00:00:00 2001 From: Hailey Date: Tue, 1 Oct 2024 13:59:20 -0700 Subject: [PATCH 01/62] remove --- src/components/Dialog/index.tsx | 2 -- src/state/dialogs/index.tsx | 36 ++++++++------------------------- src/view/shell/index.tsx | 26 ++++++++++-------------- 3 files changed, 19 insertions(+), 45 deletions(-) diff --git a/src/components/Dialog/index.tsx b/src/components/Dialog/index.tsx index d5d92048ad..67603ed2d8 100644 --- a/src/components/Dialog/index.tsx +++ b/src/components/Dialog/index.tsx @@ -176,8 +176,6 @@ export function Outer({ Keyboard.dismiss()}> diff --git a/src/state/dialogs/index.tsx b/src/state/dialogs/index.tsx index 26bb6792fd..c674175a20 100644 --- a/src/state/dialogs/index.tsx +++ b/src/state/dialogs/index.tsx @@ -1,5 +1,4 @@ import React from 'react' -import {SharedValue, useSharedValue} from 'react-native-reanimated' import {DialogControlRefProps} from '#/components/Dialog' import {Provider as GlobalDialogsProvider} from '#/components/dialogs/Context' @@ -16,14 +15,6 @@ interface IDialogContext { * `useId`. */ openDialogs: React.MutableRefObject> - /** - * The counterpart to `accessibilityViewIsModal` for Android. This property - * applies to the parent of all non-modal views, and prevents TalkBack from - * navigating within content beneath an open dialog. - * - * @see https://reactnative.dev/docs/accessibility#importantforaccessibility-android - */ - importantForAccessibility: SharedValue<'auto' | 'no-hide-descendants'> } const DialogContext = React.createContext({} as IDialogContext) @@ -49,9 +40,6 @@ export function Provider({children}: React.PropsWithChildren<{}>) { Map> >(new Map()) const openDialogs = React.useRef>(new Set()) - const importantForAccessibility = useSharedValue< - 'auto' | 'no-hide-descendants' - >('auto') const closeAllDialogs = React.useCallback(() => { openDialogs.current.forEach(id => { @@ -61,28 +49,20 @@ export function Provider({children}: React.PropsWithChildren<{}>) { return openDialogs.current.size > 0 }, []) - const setDialogIsOpen = React.useCallback( - (id: string, isOpen: boolean) => { - if (isOpen) { - openDialogs.current.add(id) - importantForAccessibility.value = 'no-hide-descendants' - } else { - openDialogs.current.delete(id) - if (openDialogs.current.size < 1) { - importantForAccessibility.value = 'auto' - } - } - }, - [importantForAccessibility], - ) + const setDialogIsOpen = React.useCallback((id: string, isOpen: boolean) => { + if (isOpen) { + openDialogs.current.add(id) + } else { + openDialogs.current.delete(id) + } + }, []) const context = React.useMemo( () => ({ activeDialogs, openDialogs, - importantForAccessibility, }), - [importantForAccessibility, activeDialogs, openDialogs], + [activeDialogs, openDialogs], ) const controls = React.useMemo( () => ({closeAllDialogs, setDialogIsOpen}), diff --git a/src/view/shell/index.tsx b/src/view/shell/index.tsx index aed92cbb7a..83468ecf3e 100644 --- a/src/view/shell/index.tsx +++ b/src/view/shell/index.tsx @@ -13,6 +13,13 @@ import * as NavigationBar from 'expo-navigation-bar' import {StatusBar} from 'expo-status-bar' import {useNavigation, useNavigationState} from '@react-navigation/native' +import {useDedupe} from '#/lib/hooks/useDedupe' +import {useNotificationsHandler} from '#/lib/hooks/useNotificationHandler' +import {usePalette} from '#/lib/hooks/usePalette' +import {useNotificationsRegistration} from '#/lib/notifications/notifications' +import {isStateAtTabRoot} from '#/lib/routes/helpers' +import {useTheme} from '#/lib/ThemeContext' +import {isAndroid} from '#/platform/detection' import {useSession} from '#/state/session' import { useIsDrawerOpen, @@ -20,17 +27,9 @@ import { useSetDrawerOpen, } from '#/state/shell' import {useCloseAnyActiveElement} from '#/state/util' -import {useDedupe} from 'lib/hooks/useDedupe' -import {useNotificationsHandler} from 'lib/hooks/useNotificationHandler' -import {usePalette} from 'lib/hooks/usePalette' -import {useNotificationsRegistration} from 'lib/notifications/notifications' -import {isStateAtTabRoot} from 'lib/routes/helpers' -import {useTheme} from 'lib/ThemeContext' -import {isAndroid} from 'platform/detection' -import {useDialogStateContext} from 'state/dialogs' -import {Lightbox} from 'view/com/lightbox/Lightbox' -import {ModalsContainer} from 'view/com/modals/Modal' -import {ErrorBoundary} from 'view/com/util/ErrorBoundary' +import {Lightbox} from '#/view/com/lightbox/Lightbox' +import {ModalsContainer} from '#/view/com/modals/Modal' +import {ErrorBoundary} from '#/view/com/util/ErrorBoundary' import {MutedWordsDialog} from '#/components/dialogs/MutedWords' import {SigninDialog} from '#/components/dialogs/Signin' import {Outlet as PortalOutlet} from '#/components/Portal' @@ -61,7 +60,6 @@ function ShellInner() { const canGoBack = useNavigationState(state => !isStateAtTabRoot(state)) const {hasSession} = useSession() const closeAnyActiveElement = useCloseAnyActiveElement() - const {importantForAccessibility} = useDialogStateContext() useNotificationsRegistration() useNotificationsHandler() @@ -101,9 +99,7 @@ function ShellInner() { return ( <> - + Date: Wed, 2 Oct 2024 14:43:27 -0700 Subject: [PATCH 02/62] [Sheets] [Pt. 2] Remove a bunch of now-unnecessary things (#5560) Co-authored-by: Samuel Newman --- src/components/Dialog/index.tsx | 198 +++++------------- src/components/Dialog/index.web.tsx | 4 - src/components/LikesDialog.tsx | 17 +- src/components/Menu/index.tsx | 4 +- src/components/NewskieDialog.tsx | 7 +- src/components/Prompt.tsx | 2 - src/components/ReportDialog/index.tsx | 2 - src/components/StarterPack/QrCodeDialog.tsx | 1 - src/components/StarterPack/ShareDialog.tsx | 15 +- .../Wizard/WizardEditListDialog.tsx | 7 +- src/components/TagMenu/index.tsx | 2 - src/components/WhoCanReply.tsx | 1 - src/components/dialogs/BirthDateSettings.tsx | 2 - src/components/dialogs/Embed.tsx | 1 - src/components/dialogs/EmbedConsent.tsx | 2 - src/components/dialogs/GifSelect.ios.tsx | 2 - src/components/dialogs/GifSelect.tsx | 1 - src/components/dialogs/MutedWords.tsx | 1 - .../dialogs/PostInteractionSettingsDialog.tsx | 2 - src/components/dialogs/Signin.tsx | 1 - src/components/dialogs/SwitchAccount.tsx | 2 - .../dialogs/nuxs/NeueTypography.tsx | 2 - src/components/dms/MessagesNUX.tsx | 1 - src/components/dms/ReportDialog.tsx | 1 - src/components/forms/DateField/index.tsx | 1 - .../intents/VerifyEmailIntentDialog.tsx | 3 +- .../moderation/LabelsOnMeDialog.tsx | 2 - .../moderation/ModerationDetailsDialog.tsx | 1 - .../Messages/Conversation/ChatDisabled.tsx | 1 - src/screens/Onboarding/StepProfile/index.tsx | 1 - src/state/dialogs/index.tsx | 18 +- src/view/com/auth/server-input/index.tsx | 2 - src/view/com/composer/GifAltText.tsx | 1 - .../composer/photos/ImageAltTextDialog.tsx | 2 - .../com/composer/videos/SubtitleDialog.tsx | 1 - src/view/com/util/post-ctrls/RepostButton.tsx | 1 - .../Settings/DisableEmail2FADialog.tsx | 2 - src/view/screens/Settings/ExportCarDialog.tsx | 2 - src/view/screens/Storybook/Dialogs.tsx | 10 +- yarn.lock | 5 + 40 files changed, 89 insertions(+), 242 deletions(-) diff --git a/src/components/Dialog/index.tsx b/src/components/Dialog/index.tsx index 67603ed2d8..2a59ac7f67 100644 --- a/src/components/Dialog/index.tsx +++ b/src/components/Dialog/index.tsx @@ -1,24 +1,13 @@ import React, {useImperativeHandle} from 'react' -import { - Dimensions, - Keyboard, - Pressable, - StyleProp, - View, - ViewStyle, -} from 'react-native' -import Animated, {useAnimatedStyle} from 'react-native-reanimated' +import {Dimensions, Keyboard, StyleProp, View, ViewStyle} from 'react-native' import {useSafeAreaInsets} from 'react-native-safe-area-context' import BottomSheet, { - BottomSheetBackdropProps, BottomSheetFlatList, BottomSheetFlatListMethods, BottomSheetScrollView, BottomSheetScrollViewMethods, BottomSheetTextInput, BottomSheetView, - useBottomSheet, - WINDOW_HEIGHT, } from '@discord/bottom-sheet/src' import {BottomSheetFlatListProps} from '@discord/bottom-sheet/src/components/bottomSheetScrollable/types' @@ -32,7 +21,6 @@ import { DialogOuterProps, } from '#/components/Dialog/types' import {createInput} from '#/components/forms/TextField' -import {FullWindowOverlay} from '#/components/FullWindowOverlay' import {Portal} from '#/components/Portal' export {useDialogContext, useDialogControl} from '#/components/Dialog/context' @@ -41,71 +29,20 @@ export * from '#/components/Dialog/utils' // @ts-ignore export const Input = createInput(BottomSheetTextInput) -function Backdrop(props: BottomSheetBackdropProps) { - const t = useTheme() - const bottomSheet = useBottomSheet() - - const animatedStyle = useAnimatedStyle(() => { - const opacity = - (Math.abs(WINDOW_HEIGHT - props.animatedPosition.value) - 50) / 1000 - - return { - opacity: Math.min(Math.max(opacity, 0), 0.55), - } - }) - - const onPress = React.useCallback(() => { - bottomSheet.close() - }, [bottomSheet]) - - return ( - - - - ) -} - export function Outer({ children, control, onClose, - nativeOptions, + nativeOptions: _nativeOptions, // @TODO DIALOG REFACTOR testID, }: React.PropsWithChildren) { const t = useTheme() const sheet = React.useRef(null) - const sheetOptions = nativeOptions?.sheet || {} - const hasSnapPoints = !!sheetOptions.snapPoints const insets = useSafeAreaInsets() const closeCallbacks = React.useRef<(() => void)[]>([]) const {setDialogIsOpen} = useDialogStateControlContext() - - /* - * Used to manage open/closed, but index is otherwise handled internally by `BottomSheet` - */ - const [openIndex, setOpenIndex] = React.useState(-1) - - /* - * `openIndex` is the index of the snap point to open the bottom sheet to. If >0, the bottom sheet is open. - */ - const isOpen = openIndex > -1 + // @TODO DIALOG REFACTOR - can i get rid of this? seems pointless tbh + const [isOpen, setIsOpen] = React.useState(false) const callQueuedCallbacks = React.useCallback(() => { for (const cb of closeCallbacks.current) { @@ -119,25 +56,21 @@ export function Outer({ closeCallbacks.current = [] }, []) - const open = React.useCallback( - ({index} = {}) => { - // Run any leftover callbacks that might have been queued up before calling `.open()` - callQueuedCallbacks() - - setDialogIsOpen(control.id, true) - // can be set to any index of `snapPoints`, but `0` is the first i.e. "open" - setOpenIndex(index || 0) - sheet.current?.snapToIndex(index || 0) - }, - [setDialogIsOpen, control.id, callQueuedCallbacks], - ) + const open = React.useCallback(() => { + // Run any leftover callbacks that might have been queued up before calling `.open()` + callQueuedCallbacks() + setIsOpen(true) + setDialogIsOpen(control.id, true) + // sheet.current?.open() // @TODO DIALOG REFACTOR + }, [setDialogIsOpen, control.id, callQueuedCallbacks]) // This is the function that we call when we want to dismiss the dialog. const close = React.useCallback(cb => { + setIsOpen(false) if (typeof cb === 'function') { closeCallbacks.current.push(cb) } - sheet.current?.close() + // sheet.current?.close() // @TODO DIALOG REFACTOR }, []) // This is the actual thing we are doing once we "confirm" the dialog. We want the dialog's close animation to @@ -146,8 +79,6 @@ export function Outer({ // This removes the dialog from our list of stored dialogs. Not super necessary on iOS, but on Android this // tells us that we need to toggle the accessibility overlay setting setDialogIsOpen(control.id, false) - setOpenIndex(-1) - callQueuedCallbacks() onClose?.() }, [callQueuedCallbacks, control.id, onClose, setDialogIsOpen]) @@ -161,58 +92,47 @@ export function Outer({ [open, close], ) - React.useEffect(() => { - return () => { - setDialogIsOpen(control.id, false) - } - }, [control.id, setDialogIsOpen]) + // @TODO DIALOG REFACTOR - what is this? rm i think? + // React.useEffect(() => { + // return () => { + // setDialogIsOpen(control.id, false) + // } + // }, [control.id, setDialogIsOpen]) const context = React.useMemo(() => ({close}), [close]) return ( isOpen && ( - - Keyboard.dismiss()}> - - - - {children} - - - - + Keyboard.dismiss()}> + + + + {children} + + + ) ) @@ -294,28 +214,6 @@ export const InnerFlatList = React.forwardRef< ) }) -export function Handle() { - const t = useTheme() - - return ( - - - - ) -} - export function Close() { return null } diff --git a/src/components/Dialog/index.web.tsx b/src/components/Dialog/index.web.tsx index bf20bd2956..f8ecbd5d94 100644 --- a/src/components/Dialog/index.web.tsx +++ b/src/components/Dialog/index.web.tsx @@ -229,10 +229,6 @@ export const InnerFlatList = React.forwardRef< ) }) -export function Handle() { - return null -} - export function Close() { const {_} = useLingui() const {close} = React.useContext(Context) diff --git a/src/components/LikesDialog.tsx b/src/components/LikesDialog.tsx index 94a3f27e26..249c68f3c1 100644 --- a/src/components/LikesDialog.tsx +++ b/src/components/LikesDialog.tsx @@ -1,20 +1,19 @@ -import React, {useMemo, useCallback} from 'react' +import React, {useCallback, useMemo} from 'react' import {ActivityIndicator, FlatList, View} from 'react-native' +import {AppBskyFeedGetLikes as GetLikes} from '@atproto/api' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' -import {AppBskyFeedGetLikes as GetLikes} from '@atproto/api' -import {useResolveUriQuery} from '#/state/queries/resolve-uri' -import {useLikedByQuery} from '#/state/queries/post-liked-by' import {cleanError} from '#/lib/strings/errors' import {logger} from '#/logger' - +import {useLikedByQuery} from '#/state/queries/post-liked-by' +import {useResolveUriQuery} from '#/state/queries/resolve-uri' +import {ProfileCardWithFollowBtn} from '#/view/com/profile/ProfileCard' +import {ErrorMessage} from '#/view/com/util/error/ErrorMessage' import {atoms as a, useTheme} from '#/alf' -import {Text} from '#/components/Typography' import * as Dialog from '#/components/Dialog' -import {ErrorMessage} from '#/view/com/util/error/ErrorMessage' -import {ProfileCardWithFollowBtn} from '#/view/com/profile/ProfileCard' import {Loader} from '#/components/Loader' +import {Text} from '#/components/Typography' interface LikesDialogProps { control: Dialog.DialogOuterProps['control'] @@ -24,8 +23,6 @@ interface LikesDialogProps { export function LikesDialog(props: LikesDialogProps) { return ( - - ) diff --git a/src/components/Menu/index.tsx b/src/components/Menu/index.tsx index a0a21a50f9..b80fc918e0 100644 --- a/src/components/Menu/index.tsx +++ b/src/components/Menu/index.tsx @@ -4,7 +4,7 @@ import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import flattenReactChildren from 'react-keyed-flatten-children' -import {isNative} from 'platform/detection' +import {isNative} from '#/platform/detection' import {atoms as a, useTheme} from '#/alf' import {Button, ButtonText} from '#/components/Button' import * as Dialog from '#/components/Dialog' @@ -85,8 +85,6 @@ export function Outer({ return ( - - {/* Re-wrap with context since Dialogs are portal-ed to root */} diff --git a/src/components/NewskieDialog.tsx b/src/components/NewskieDialog.tsx index 1a523a839d..e25f48edf5 100644 --- a/src/components/NewskieDialog.tsx +++ b/src/components/NewskieDialog.tsx @@ -5,12 +5,12 @@ import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {differenceInSeconds} from 'date-fns' +import {HITSLOP_10} from '#/lib/constants' import {useGetTimeAgo} from '#/lib/hooks/useTimeAgo' +import {sanitizeDisplayName} from '#/lib/strings/display-names' import {isNative} from '#/platform/detection' import {useModerationOpts} from '#/state/preferences/moderation-opts' -import {HITSLOP_10} from 'lib/constants' -import {sanitizeDisplayName} from 'lib/strings/display-names' -import {useSession} from 'state/session' +import {useSession} from '#/state/session' import {atoms as a, useTheme} from '#/alf' import {Button, ButtonText} from '#/components/Button' import * as Dialog from '#/components/Dialog' @@ -78,7 +78,6 @@ export function NewskieDialog({ - diff --git a/src/components/Prompt.tsx b/src/components/Prompt.tsx index 8765cdee31..8aa111bf3d 100644 --- a/src/components/Prompt.tsx +++ b/src/components/Prompt.tsx @@ -41,8 +41,6 @@ export function Outer({ return ( - - - - ) diff --git a/src/components/StarterPack/QrCodeDialog.tsx b/src/components/StarterPack/QrCodeDialog.tsx index b2af8ff73a..2feea0973a 100644 --- a/src/components/StarterPack/QrCodeDialog.tsx +++ b/src/components/StarterPack/QrCodeDialog.tsx @@ -149,7 +149,6 @@ export function QrCodeDialog({ return ( - diff --git a/src/components/StarterPack/ShareDialog.tsx b/src/components/StarterPack/ShareDialog.tsx index 9851b08567..494aceae1f 100644 --- a/src/components/StarterPack/ShareDialog.tsx +++ b/src/components/StarterPack/ShareDialog.tsx @@ -6,14 +6,14 @@ import {AppBskyGraphDefs} from '@atproto/api' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' +import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries' +import {saveImageToMediaLibrary} from '#/lib/media/manip' +import {shareUrl} from '#/lib/sharing' +import {logEvent} from '#/lib/statsig/statsig' +import {getStarterPackOgCard} from '#/lib/strings/starter-pack' import {logger} from '#/logger' -import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries' -import {saveImageToMediaLibrary} from 'lib/media/manip' -import {shareUrl} from 'lib/sharing' -import {logEvent} from 'lib/statsig/statsig' -import {getStarterPackOgCard} from 'lib/strings/starter-pack' -import {isNative, isWeb} from 'platform/detection' -import * as Toast from 'view/com/util/Toast' +import {isNative, isWeb} from '#/platform/detection' +import * as Toast from '#/view/com/util/Toast' import {atoms as a, useTheme} from '#/alf' import {Button, ButtonText} from '#/components/Button' import {DialogControlProps} from '#/components/Dialog' @@ -84,7 +84,6 @@ function ShareDialogInner({ return ( <> - {!imageLoaded || !link ? ( diff --git a/src/components/StarterPack/Wizard/WizardEditListDialog.tsx b/src/components/StarterPack/Wizard/WizardEditListDialog.tsx index f7b0aba344..1d69e4f4a0 100644 --- a/src/components/StarterPack/Wizard/WizardEditListDialog.tsx +++ b/src/components/StarterPack/Wizard/WizardEditListDialog.tsx @@ -7,9 +7,9 @@ import {BottomSheetFlatListMethods} from '@discord/bottom-sheet' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' -import {useInitialNumToRender} from 'lib/hooks/useInitialNumToRender' -import {isWeb} from 'platform/detection' -import {useSession} from 'state/session' +import {useInitialNumToRender} from '#/lib/hooks/useInitialNumToRender' +import {isWeb} from '#/platform/detection' +import {useSession} from '#/state/session' import {WizardAction, WizardState} from '#/screens/StarterPack/Wizard/State' import {atoms as a, native, useTheme, web} from '#/alf' import {Button, ButtonText} from '#/components/Button' @@ -80,7 +80,6 @@ export function WizardEditListDialog({ control={control} testID="newChatDialog" nativeOptions={{sheet: {snapPoints: ['95%']}}}> - - - {isPreferencesLoading ? ( diff --git a/src/components/WhoCanReply.tsx b/src/components/WhoCanReply.tsx index ab6ef8293c..2839943c97 100644 --- a/src/components/WhoCanReply.tsx +++ b/src/components/WhoCanReply.tsx @@ -170,7 +170,6 @@ function WhoCanReplyDialog({ const {_} = useLingui() return ( - diff --git a/src/components/dialogs/BirthDateSettings.tsx b/src/components/dialogs/BirthDateSettings.tsx index 08608f9d88..72ce9690e9 100644 --- a/src/components/dialogs/BirthDateSettings.tsx +++ b/src/components/dialogs/BirthDateSettings.tsx @@ -30,8 +30,6 @@ export function BirthDateSettingsDialog({ return ( - - diff --git a/src/components/dialogs/Embed.tsx b/src/components/dialogs/Embed.tsx index ca75b01390..7aa2a4fc1e 100644 --- a/src/components/dialogs/Embed.tsx +++ b/src/components/dialogs/Embed.tsx @@ -27,7 +27,6 @@ type EmbedDialogProps = { let EmbedDialog = ({control, ...rest}: EmbedDialogProps): React.ReactNode => { return ( - ) diff --git a/src/components/dialogs/EmbedConsent.tsx b/src/components/dialogs/EmbedConsent.tsx index 765b8adc7e..3aa0f0b404 100644 --- a/src/components/dialogs/EmbedConsent.tsx +++ b/src/components/dialogs/EmbedConsent.tsx @@ -49,8 +49,6 @@ export function EmbedConsentDialog({ return ( - - diff --git a/src/components/dialogs/GifSelect.ios.tsx b/src/components/dialogs/GifSelect.ios.tsx index 2f867e8657..abe5aa3cc3 100644 --- a/src/components/dialogs/GifSelect.ios.tsx +++ b/src/components/dialogs/GifSelect.ios.tsx @@ -22,7 +22,6 @@ import {atoms as a, useBreakpoints, useTheme} from '#/alf' import * as TextField from '#/components/forms/TextField' import {MagnifyingGlass2_Stroke2_Corner0_Rounded as Search} from '#/components/icons/MagnifyingGlass2' import {Button, ButtonText} from '../Button' -import {Handle} from '../Dialog' import {useThrottledValue} from '../hooks/useThrottledValue' import {ListFooter, ListMaybePlaceholder} from '../Lists' import {GifPreview} from './GifSelect.shared' @@ -70,7 +69,6 @@ export function GifSelectDialog({ aria-modal accessibilityViewIsModal> - diff --git a/src/components/dialogs/GifSelect.tsx b/src/components/dialogs/GifSelect.tsx index 1afc588dad..a06491c15f 100644 --- a/src/components/dialogs/GifSelect.tsx +++ b/src/components/dialogs/GifSelect.tsx @@ -61,7 +61,6 @@ export function GifSelectDialog({ control={control} nativeOptions={{sheet: {snapPoints: ['100%']}}} onClose={onClose}> - diff --git a/src/components/dialogs/MutedWords.tsx b/src/components/dialogs/MutedWords.tsx index 81a6141038..daa18f94e7 100644 --- a/src/components/dialogs/MutedWords.tsx +++ b/src/components/dialogs/MutedWords.tsx @@ -39,7 +39,6 @@ export function MutedWordsDialog() { const {mutedWordsDialogControl: control} = useGlobalDialogsControlContext() return ( - ) diff --git a/src/components/dialogs/PostInteractionSettingsDialog.tsx b/src/components/dialogs/PostInteractionSettingsDialog.tsx index 47eefae6f9..93be838542 100644 --- a/src/components/dialogs/PostInteractionSettingsDialog.tsx +++ b/src/components/dialogs/PostInteractionSettingsDialog.tsx @@ -61,7 +61,6 @@ export function PostInteractionSettingsControlledDialog({ const {_} = useLingui() return ( - @@ -96,7 +95,6 @@ export function PostInteractionSettingsDialog( ) { return ( - ) diff --git a/src/components/dialogs/Signin.tsx b/src/components/dialogs/Signin.tsx index b9c939e94b..d24f6af644 100644 --- a/src/components/dialogs/Signin.tsx +++ b/src/components/dialogs/Signin.tsx @@ -18,7 +18,6 @@ export function SigninDialog() { const {signinDialogControl: control} = useGlobalDialogsControlContext() return ( - ) diff --git a/src/components/dialogs/SwitchAccount.tsx b/src/components/dialogs/SwitchAccount.tsx index 0bd4bcb8cb..809ed1e3f6 100644 --- a/src/components/dialogs/SwitchAccount.tsx +++ b/src/components/dialogs/SwitchAccount.tsx @@ -42,8 +42,6 @@ export function SwitchAccountDialog({ return ( - - diff --git a/src/components/dialogs/nuxs/NeueTypography.tsx b/src/components/dialogs/nuxs/NeueTypography.tsx index f160c87743..97028b6e54 100644 --- a/src/components/dialogs/nuxs/NeueTypography.tsx +++ b/src/components/dialogs/nuxs/NeueTypography.tsx @@ -43,8 +43,6 @@ export function NeueTypography() { return ( - - diff --git a/src/components/dms/MessagesNUX.tsx b/src/components/dms/MessagesNUX.tsx index 5c21ee05be..723696a04d 100644 --- a/src/components/dms/MessagesNUX.tsx +++ b/src/components/dms/MessagesNUX.tsx @@ -39,7 +39,6 @@ export function MessagesNUX() { return ( - ) diff --git a/src/components/dms/ReportDialog.tsx b/src/components/dms/ReportDialog.tsx index 5493a1c87f..28b5e86202 100644 --- a/src/components/dms/ReportDialog.tsx +++ b/src/components/dms/ReportDialog.tsx @@ -44,7 +44,6 @@ let ReportDialog = ({ - diff --git a/src/components/forms/DateField/index.tsx b/src/components/forms/DateField/index.tsx index 1c78d2abbb..7546aec484 100644 --- a/src/components/forms/DateField/index.tsx +++ b/src/components/forms/DateField/index.tsx @@ -57,7 +57,6 @@ export function DateField({ accessibilityHint={accessibilityHint} /> - diff --git a/src/components/intents/VerifyEmailIntentDialog.tsx b/src/components/intents/VerifyEmailIntentDialog.tsx index e8c63af82f..9f3808020a 100644 --- a/src/components/intents/VerifyEmailIntentDialog.tsx +++ b/src/components/intents/VerifyEmailIntentDialog.tsx @@ -3,7 +3,7 @@ import {View} from 'react-native' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' -import {useAgent, useSession} from 'state/session' +import {useAgent, useSession} from '#/state/session' import {atoms as a} from '#/alf' import {Button, ButtonText} from '#/components/Button' import * as Dialog from '#/components/Dialog' @@ -17,7 +17,6 @@ export function VerifyEmailIntentDialog() { return ( - ) diff --git a/src/components/moderation/LabelsOnMeDialog.tsx b/src/components/moderation/LabelsOnMeDialog.tsx index e63cea93b2..389c722c87 100644 --- a/src/components/moderation/LabelsOnMeDialog.tsx +++ b/src/components/moderation/LabelsOnMeDialog.tsx @@ -31,8 +31,6 @@ export interface LabelsOnMeDialogProps { export function LabelsOnMeDialog(props: LabelsOnMeDialogProps) { return ( - - ) diff --git a/src/components/moderation/ModerationDetailsDialog.tsx b/src/components/moderation/ModerationDetailsDialog.tsx index 2259178538..1198e8b921 100644 --- a/src/components/moderation/ModerationDetailsDialog.tsx +++ b/src/components/moderation/ModerationDetailsDialog.tsx @@ -26,7 +26,6 @@ export interface ModerationDetailsDialogProps { export function ModerationDetailsDialog(props: ModerationDetailsDialogProps) { return ( - ) diff --git a/src/screens/Messages/Conversation/ChatDisabled.tsx b/src/screens/Messages/Conversation/ChatDisabled.tsx index c768d2504b..efe8545bf1 100644 --- a/src/screens/Messages/Conversation/ChatDisabled.tsx +++ b/src/screens/Messages/Conversation/ChatDisabled.tsx @@ -54,7 +54,6 @@ function AppealDialog() { - diff --git a/src/screens/Onboarding/StepProfile/index.tsx b/src/screens/Onboarding/StepProfile/index.tsx index 663418f220..c6a39ab45e 100644 --- a/src/screens/Onboarding/StepProfile/index.tsx +++ b/src/screens/Onboarding/StepProfile/index.tsx @@ -286,7 +286,6 @@ export function StepProfile() { - ) { const openDialogs = React.useRef>(new Set()) const closeAllDialogs = React.useCallback(() => { - openDialogs.current.forEach(id => { - const dialog = activeDialogs.current.get(id) - if (dialog) dialog.current.close() - }) - return openDialogs.current.size > 0 + if (isWeb) { + openDialogs.current.forEach(id => { + const dialog = activeDialogs.current.get(id) + if (dialog) dialog.current.close() + }) + + return openDialogs.current.size > 0 + } else { + // @TODO DIALOGS REFACTOR + console.error('HAILEY FIX THIS πŸ₯ΊπŸ“‹') + return false + } }, []) const setDialogIsOpen = React.useCallback((id: string, isOpen: boolean) => { diff --git a/src/view/com/auth/server-input/index.tsx b/src/view/com/auth/server-input/index.tsx index fb69e1d9c7..4e36688aec 100644 --- a/src/view/com/auth/server-input/index.tsx +++ b/src/view/com/auth/server-input/index.tsx @@ -70,8 +70,6 @@ export function ServerInputDialog({ control={control} nativeOptions={{sheet: {snapPoints: ['100%']}}} onClose={onClose}> - - diff --git a/src/view/com/composer/GifAltText.tsx b/src/view/com/composer/GifAltText.tsx index a05607c76c..53db2da941 100644 --- a/src/view/com/composer/GifAltText.tsx +++ b/src/view/com/composer/GifAltText.tsx @@ -99,7 +99,6 @@ export function GifAltText({ - { return ( - - ) diff --git a/src/view/com/composer/videos/SubtitleDialog.tsx b/src/view/com/composer/videos/SubtitleDialog.tsx index c07fdfc562..5926244908 100644 --- a/src/view/com/composer/videos/SubtitleDialog.tsx +++ b/src/view/com/composer/videos/SubtitleDialog.tsx @@ -59,7 +59,6 @@ export function SubtitleDialogBtn(props: Props) { - diff --git a/src/view/com/util/post-ctrls/RepostButton.tsx b/src/view/com/util/post-ctrls/RepostButton.tsx index 0ecdf25b93..8a41ec88ac 100644 --- a/src/view/com/util/post-ctrls/RepostButton.tsx +++ b/src/view/com/util/post-ctrls/RepostButton.tsx @@ -87,7 +87,6 @@ let RepostButton = ({ ) : undefined} - diff --git a/src/view/screens/Settings/DisableEmail2FADialog.tsx b/src/view/screens/Settings/DisableEmail2FADialog.tsx index a27cff9a3e..bbc6902543 100644 --- a/src/view/screens/Settings/DisableEmail2FADialog.tsx +++ b/src/view/screens/Settings/DisableEmail2FADialog.tsx @@ -78,8 +78,6 @@ export function DisableEmail2FADialog({ return ( - - diff --git a/src/view/screens/Settings/ExportCarDialog.tsx b/src/view/screens/Settings/ExportCarDialog.tsx index a6ddb38204..3d21d7cb5e 100644 --- a/src/view/screens/Settings/ExportCarDialog.tsx +++ b/src/view/screens/Settings/ExportCarDialog.tsx @@ -52,8 +52,6 @@ export function ExportCarDialog({ return ( - - diff --git a/src/view/screens/Storybook/Dialogs.tsx b/src/view/screens/Storybook/Dialogs.tsx index 3a9f67de81..bb13831046 100644 --- a/src/view/screens/Storybook/Dialogs.tsx +++ b/src/view/screens/Storybook/Dialogs.tsx @@ -2,8 +2,8 @@ import React from 'react' import {View} from 'react-native' import {useNavigation} from '@react-navigation/native' +import {NavigationProp} from '#/lib/routes/types' import {useDialogStateControlContext} from '#/state/dialogs' -import {NavigationProp} from 'lib/routes/types' import {atoms as a} from '#/alf' import {Button, ButtonText} from '#/components/Button' import * as Dialog from '#/components/Dialog' @@ -179,8 +179,6 @@ export function Dialogs() { - -

Dialog

A basic dialog

@@ -190,8 +188,6 @@ export function Dialogs() { - - @@ -230,8 +226,6 @@ export function Dialogs() { - - @@ -356,8 +350,6 @@ export function Dialogs() { {shouldRenderUnmountTest && ( - -

Unmount Test Dialog

Will unmount in about 5 seconds

diff --git a/yarn.lock b/yarn.lock index 8f68ea4f3f..e3dc084342 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4120,6 +4120,11 @@ resolved "https://registry.yarnpkg.com/@graphql-typed-document-node/core/-/core-3.2.0.tgz#5f3d96ec6b2354ad6d8a28bf216a1d97b5426861" integrity sha512-mB9oAsNCm9aM3/SOv4YtBMqZbYj10R7dkq8byBqxGY/ncFwhf2oQzMV+LCRlWoDSEBJ3COiR1yeDvMtsoOsuFQ== +"@haileyok/bluesky-bottom-sheet@^0.1.1-alpha.4": + version "0.1.1-alpha.4" + resolved "https://registry.yarnpkg.com/@haileyok/bluesky-bottom-sheet/-/bluesky-bottom-sheet-0.1.1-alpha.4.tgz#19717e57e63d70e79b8bd86984903c448deb83bc" + integrity sha512-bEZRbErsI6OJCgmFolbr9Ta5LxNvyaltzRPFOVtwsykIwL8tqNJeNlmfxP8EdJa5lSu2kK1MauQcygmCIouzwg== + "@haileyok/bluesky-video@0.1.10": version "0.1.10" resolved "https://registry.yarnpkg.com/@haileyok/bluesky-video/-/bluesky-video-0.1.10.tgz#2756e8c83a78caeb6b120a175578eac1eb6889a9" From 5b08aad014aa8b4b42df15765f82c7e7a78c1d7a Mon Sep 17 00:00:00 2001 From: Hailey Date: Wed, 2 Oct 2024 14:58:12 -0700 Subject: [PATCH 03/62] [Sheets] [Pt. 3] Get new sheet working with `ScrollableInner` (#5561) --- package.json | 1 + src/components/Dialog/index.tsx | 106 +++++++++++--------------------- yarn.lock | 8 +-- 3 files changed, 42 insertions(+), 73 deletions(-) diff --git a/package.json b/package.json index 4ab196b6aa..7b972e662f 100644 --- a/package.json +++ b/package.json @@ -68,6 +68,7 @@ "@fortawesome/free-regular-svg-icons": "^6.1.1", "@fortawesome/free-solid-svg-icons": "^6.1.1", "@fortawesome/react-native-fontawesome": "^0.3.2", + "@haileyok/bluesky-bottom-sheet": "^0.1.1-alpha.7", "@haileyok/bluesky-video": "0.1.10", "@lingui/react": "^4.5.0", "@mattermost/react-native-paste-input": "^0.7.1", diff --git a/src/components/Dialog/index.tsx b/src/components/Dialog/index.tsx index 2a59ac7f67..4cb431462b 100644 --- a/src/components/Dialog/index.tsx +++ b/src/components/Dialog/index.tsx @@ -1,18 +1,18 @@ import React, {useImperativeHandle} from 'react' -import {Dimensions, Keyboard, StyleProp, View, ViewStyle} from 'react-native' +import {StyleProp, View, ViewStyle} from 'react-native' import {useSafeAreaInsets} from 'react-native-safe-area-context' -import BottomSheet, { +import { BottomSheetFlatList, BottomSheetFlatListMethods, - BottomSheetScrollView, - BottomSheetScrollViewMethods, BottomSheetTextInput, BottomSheetView, } from '@discord/bottom-sheet/src' import {BottomSheetFlatListProps} from '@discord/bottom-sheet/src/components/bottomSheetScrollable/types' +import {BlueskyBottomSheetView} from '@haileyok/bluesky-bottom-sheet' import {logger} from '#/logger' import {useDialogStateControlContext} from '#/state/dialogs' +import {ScrollView} from '#/view/com/util/Views' import {atoms as a, flatten, useTheme} from '#/alf' import {Context} from '#/components/Dialog/context' import { @@ -37,12 +37,11 @@ export function Outer({ testID, }: React.PropsWithChildren) { const t = useTheme() - const sheet = React.useRef(null) + const ref = React.useRef(null) const insets = useSafeAreaInsets() const closeCallbacks = React.useRef<(() => void)[]>([]) const {setDialogIsOpen} = useDialogStateControlContext() // @TODO DIALOG REFACTOR - can i get rid of this? seems pointless tbh - const [isOpen, setIsOpen] = React.useState(false) const callQueuedCallbacks = React.useCallback(() => { for (const cb of closeCallbacks.current) { @@ -59,18 +58,16 @@ export function Outer({ const open = React.useCallback(() => { // Run any leftover callbacks that might have been queued up before calling `.open()` callQueuedCallbacks() - setIsOpen(true) setDialogIsOpen(control.id, true) - // sheet.current?.open() // @TODO DIALOG REFACTOR + ref.current?.present() }, [setDialogIsOpen, control.id, callQueuedCallbacks]) // This is the function that we call when we want to dismiss the dialog. const close = React.useCallback(cb => { - setIsOpen(false) if (typeof cb === 'function') { closeCallbacks.current.push(cb) } - // sheet.current?.close() // @TODO DIALOG REFACTOR + ref.current?.dismiss() }, []) // This is the actual thing we are doing once we "confirm" the dialog. We want the dialog's close animation to @@ -102,39 +99,25 @@ export function Outer({ const context = React.useMemo(() => ({close}), [close]) return ( - isOpen && ( - - Keyboard.dismiss()}> - - - - {children} - - - - - ) + + + { + if (e.nativeEvent.state === 'closed') { + onCloseAnimationComplete() + } + }} + cornerRadius={20}> + + {children} + + + + ) } @@ -158,32 +141,17 @@ export function Inner({children, style}: DialogInnerProps) { ) } -export const ScrollableInner = React.forwardRef< - BottomSheetScrollViewMethods, - DialogInnerProps ->(function ScrollableInner({children, style}, ref) { - const insets = useSafeAreaInsets() - return ( - - {children} - - - ) -}) +export const ScrollableInner = React.forwardRef( + function ScrollableInner({children, style}, ref) { + const insets = useSafeAreaInsets() + return ( + + {children} + + + ) + }, +) export const InnerFlatList = React.forwardRef< BottomSheetFlatListMethods, diff --git a/yarn.lock b/yarn.lock index e3dc084342..2512608e7e 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4120,10 +4120,10 @@ resolved "https://registry.yarnpkg.com/@graphql-typed-document-node/core/-/core-3.2.0.tgz#5f3d96ec6b2354ad6d8a28bf216a1d97b5426861" integrity sha512-mB9oAsNCm9aM3/SOv4YtBMqZbYj10R7dkq8byBqxGY/ncFwhf2oQzMV+LCRlWoDSEBJ3COiR1yeDvMtsoOsuFQ== -"@haileyok/bluesky-bottom-sheet@^0.1.1-alpha.4": - version "0.1.1-alpha.4" - resolved "https://registry.yarnpkg.com/@haileyok/bluesky-bottom-sheet/-/bluesky-bottom-sheet-0.1.1-alpha.4.tgz#19717e57e63d70e79b8bd86984903c448deb83bc" - integrity sha512-bEZRbErsI6OJCgmFolbr9Ta5LxNvyaltzRPFOVtwsykIwL8tqNJeNlmfxP8EdJa5lSu2kK1MauQcygmCIouzwg== +"@haileyok/bluesky-bottom-sheet@^0.1.1-alpha.7": + version "0.1.1-alpha.7" + resolved "https://registry.yarnpkg.com/@haileyok/bluesky-bottom-sheet/-/bluesky-bottom-sheet-0.1.1-alpha.7.tgz#a5845cd2ac386b78716db5940b65b3e78b392042" + integrity sha512-Ps2nsNmfjqUmP/LPAM94/2dWZerwZEjnvSUfi/ipFNHlNp/McIYIObxDaPJaZ0ZLxUcRXxdhmC3UonK25sJKSw== "@haileyok/bluesky-video@0.1.10": version "0.1.10" From 0037353528003a66a0c9dc17a4b24ea79c021810 Mon Sep 17 00:00:00 2001 From: Hailey Date: Wed, 2 Oct 2024 15:49:36 -0700 Subject: [PATCH 04/62] [Sheets] [Pt. 4] Convert Pressable in Menu (WIP) (#5562) --- package.json | 4 ++-- src/components/Dialog/index.tsx | 8 -------- src/components/Menu/index.tsx | 18 ++++++++++-------- src/components/Menu/types.ts | 6 ++++-- yarn.lock | 17 ++++++++--------- 5 files changed, 24 insertions(+), 29 deletions(-) diff --git a/package.json b/package.json index 7b972e662f..e32100ece8 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "@fortawesome/free-regular-svg-icons": "^6.1.1", "@fortawesome/free-solid-svg-icons": "^6.1.1", "@fortawesome/react-native-fontawesome": "^0.3.2", - "@haileyok/bluesky-bottom-sheet": "^0.1.1-alpha.7", + "@haileyok/bluesky-bottom-sheet": "^0.1.1-alpha.8", "@haileyok/bluesky-video": "0.1.10", "@lingui/react": "^4.5.0", "@mattermost/react-native-paste-input": "^0.7.1", @@ -172,7 +172,7 @@ "react-native-compressor": "^1.8.24", "react-native-date-picker": "^4.4.2", "react-native-drawer-layout": "^4.0.0-alpha.3", - "react-native-gesture-handler": "~2.16.2", + "react-native-gesture-handler": "2.20.0", "react-native-get-random-values": "~1.11.0", "react-native-image-crop-picker": "0.41.2", "react-native-ios-context-menu": "^1.15.3", diff --git a/src/components/Dialog/index.tsx b/src/components/Dialog/index.tsx index 4cb431462b..716ad154cf 100644 --- a/src/components/Dialog/index.tsx +++ b/src/components/Dialog/index.tsx @@ -89,20 +89,12 @@ export function Outer({ [open, close], ) - // @TODO DIALOG REFACTOR - what is this? rm i think? - // React.useEffect(() => { - // return () => { - // setDialogIsOpen(control.id, false) - // } - // }, [control.id, setDialogIsOpen]) - const context = React.useMemo(() => ({close}), [close]) return ( { + control?.close() onPress(e) - - if (!e.defaultPrevented) { - control?.close() - } }} - onFocus={onFocus} - onBlur={onBlur} onPressIn={e => { onPressIn() rest.onPressIn?.(e) @@ -131,6 +131,8 @@ export function Item({children, label, style, onPress, ...rest}: ItemProps) { onPressOut() rest.onPressOut?.(e) }} + onHoverIn={onHoverIn} + onHoverOut={onHoverOut} style={[ a.flex_row, a.align_center, diff --git a/src/components/Menu/types.ts b/src/components/Menu/types.ts index 2f7aea5de5..e5d1d16a8d 100644 --- a/src/components/Menu/types.ts +++ b/src/components/Menu/types.ts @@ -4,6 +4,8 @@ import { GestureResponderEvent, PressableProps, } from 'react-native' +import {PressableEvent} from 'react-native-gesture-handler/lib/typescript/components/Pressable/PressableProps' +import {BueskyBottomSheetPressableProps} from '@haileyok/bluesky-bottom-sheet' import {TextStyleProp, ViewStyleProp} from '#/alf' import * as Dialog from '#/components/Dialog' @@ -87,10 +89,10 @@ export type TriggerChildProps = } export type ItemProps = React.PropsWithChildren< - Omit & + Omit & ViewStyleProp & { label: string - onPress: (e: GestureResponderEvent) => void + onPress: (e: PressableEvent | GestureResponderEvent) => void } > diff --git a/yarn.lock b/yarn.lock index 2512608e7e..d20d4a4cdc 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4120,10 +4120,10 @@ resolved "https://registry.yarnpkg.com/@graphql-typed-document-node/core/-/core-3.2.0.tgz#5f3d96ec6b2354ad6d8a28bf216a1d97b5426861" integrity sha512-mB9oAsNCm9aM3/SOv4YtBMqZbYj10R7dkq8byBqxGY/ncFwhf2oQzMV+LCRlWoDSEBJ3COiR1yeDvMtsoOsuFQ== -"@haileyok/bluesky-bottom-sheet@^0.1.1-alpha.7": - version "0.1.1-alpha.7" - resolved "https://registry.yarnpkg.com/@haileyok/bluesky-bottom-sheet/-/bluesky-bottom-sheet-0.1.1-alpha.7.tgz#a5845cd2ac386b78716db5940b65b3e78b392042" - integrity sha512-Ps2nsNmfjqUmP/LPAM94/2dWZerwZEjnvSUfi/ipFNHlNp/McIYIObxDaPJaZ0ZLxUcRXxdhmC3UonK25sJKSw== +"@haileyok/bluesky-bottom-sheet@^0.1.1-alpha.8": + version "0.1.1-alpha.8" + resolved "https://registry.yarnpkg.com/@haileyok/bluesky-bottom-sheet/-/bluesky-bottom-sheet-0.1.1-alpha.8.tgz#c5fd503cdd5556a686a1f5c0974b1527fceda900" + integrity sha512-305MSNscniLZpxd80QO4OCuMXkm+U/v/YW/x0fVQtBilVTikOOPIkiYge+kCUdryFPD3LU/GdrsQZL+y8qAiMQ== "@haileyok/bluesky-video@0.1.10": version "0.1.10" @@ -18068,15 +18068,14 @@ react-native-drawer-layout@^4.0.0-alpha.3: dependencies: use-latest-callback "^0.1.9" -react-native-gesture-handler@~2.16.2: - version "2.16.2" - resolved "https://registry.yarnpkg.com/react-native-gesture-handler/-/react-native-gesture-handler-2.16.2.tgz#032bd2a07334292d7f6cff1dc9d1ec928f72e26d" - integrity sha512-vGFlrDKlmyI+BT+FemqVxmvO7nqxU33cgXVsn6IKAFishvlG3oV2Ds67D5nPkHMea8T+s1IcuMm0bF8ntZtAyg== +react-native-gesture-handler@2.20.0: + version "2.20.0" + resolved "https://registry.yarnpkg.com/react-native-gesture-handler/-/react-native-gesture-handler-2.20.0.tgz#2d9ec4e9bd22619ebe36269dda3ecb1173928276" + integrity sha512-rFKqgHRfxQ7uSAivk8vxCiW4SB3G0U7jnv7kZD4Y90K5kp6YrU8Q3tWhxe3Rx55BIvSd3mBe9ZWbWVJ0FsSHPA== dependencies: "@egjs/hammerjs" "^2.0.17" hoist-non-react-statics "^3.3.0" invariant "^2.2.4" - lodash "^4.17.21" prop-types "^15.7.2" react-native-get-random-values@^1.6.0: From ede5d0155b6604d1f8cc39d55246cf0235826333 Mon Sep 17 00:00:00 2001 From: Hailey Date: Wed, 2 Oct 2024 16:03:49 -0700 Subject: [PATCH 05/62] [Sheets] [Pt. 5] Update types and props (#5563) --- src/components/Dialog/index.tsx | 6 +-- src/components/Dialog/types.ts | 6 +-- src/components/Menu/index.tsx | 4 +- src/components/ReportDialog/index.tsx | 5 +-- .../Wizard/WizardEditListDialog.tsx | 5 +-- src/components/dialogs/GifSelect.tsx | 5 +-- src/components/dms/ConvoMenu.tsx | 6 +-- src/components/dms/MessageMenu.tsx | 10 ++--- src/components/dms/ReportDialog.tsx | 5 +-- src/components/dms/dialogs/NewChatDialog.tsx | 7 +-- .../dms/dialogs/ShareViaChatDialog.tsx | 7 +-- src/screens/StarterPack/StarterPackScreen.tsx | 44 +++++++++---------- src/view/com/auth/server-input/index.tsx | 5 +-- src/view/com/composer/GifAltText.tsx | 5 +-- .../com/composer/videos/SubtitleDialog.tsx | 6 +-- src/view/com/util/forms/PostDropdownBtn.tsx | 12 ++--- src/view/screens/Storybook/Dialogs.tsx | 4 +- 17 files changed, 59 insertions(+), 83 deletions(-) diff --git a/src/components/Dialog/index.tsx b/src/components/Dialog/index.tsx index 716ad154cf..6799c35afb 100644 --- a/src/components/Dialog/index.tsx +++ b/src/components/Dialog/index.tsx @@ -33,7 +33,7 @@ export function Outer({ children, control, onClose, - nativeOptions: _nativeOptions, // @TODO DIALOG REFACTOR + nativeOptions, testID, }: React.PropsWithChildren) { const t = useTheme() @@ -41,7 +41,6 @@ export function Outer({ const insets = useSafeAreaInsets() const closeCallbacks = React.useRef<(() => void)[]>([]) const {setDialogIsOpen} = useDialogStateControlContext() - // @TODO DIALOG REFACTOR - can i get rid of this? seems pointless tbh const callQueuedCallbacks = React.useCallback(() => { for (const cb of closeCallbacks.current) { @@ -103,7 +102,8 @@ export function Outer({ onCloseAnimationComplete() } }} - cornerRadius={20}> + cornerRadius={20} + {...nativeOptions}> {children} diff --git a/src/components/Dialog/types.ts b/src/components/Dialog/types.ts index 1ddab02eea..ed83bd02b1 100644 --- a/src/components/Dialog/types.ts +++ b/src/components/Dialog/types.ts @@ -4,7 +4,7 @@ import type { GestureResponderEvent, ScrollViewProps, } from 'react-native' -import {BottomSheetProps} from '@discord/bottom-sheet/src' +import {BlueskyBottomSheetViewProps} from '@haileyok/bluesky-bottom-sheet' import {ViewStyleProp} from '#/alf' @@ -52,9 +52,7 @@ export type DialogControlOpenOptions = { export type DialogOuterProps = { control: DialogControlProps onClose?: () => void - nativeOptions?: { - sheet?: Omit - } + nativeOptions?: Omit webOptions?: {} testID?: string } diff --git a/src/components/Menu/index.tsx b/src/components/Menu/index.tsx index 88b4167842..c48d6f9bd0 100644 --- a/src/components/Menu/index.tsx +++ b/src/components/Menu/index.tsx @@ -85,7 +85,9 @@ export function Outer({ const context = React.useContext(Context) return ( - + {/* Re-wrap with context since Dialogs are portal-ed to root */} diff --git a/src/components/ReportDialog/index.tsx b/src/components/ReportDialog/index.tsx index a9f4a63b07..b942659380 100644 --- a/src/components/ReportDialog/index.tsx +++ b/src/components/ReportDialog/index.tsx @@ -1,5 +1,5 @@ import React from 'react' -import {Pressable, View} from 'react-native' +import {Pressable, ScrollView, View} from 'react-native' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' @@ -8,7 +8,6 @@ import {useMyLabelersQuery} from '#/state/queries/preferences' export {useDialogControl as useReportDialogControl} from '#/components/Dialog' import {AppBskyLabelerDefs} from '@atproto/api' -import {BottomSheetScrollViewMethods} from '@discord/bottom-sheet/src' import {atoms as a} from '#/alf' import * as Dialog from '#/components/Dialog' @@ -38,7 +37,7 @@ function ReportDialogInner(props: ReportDialogProps) { } = useMyLabelersQuery() const isLoading = useDelayedLoading(500, isLabelerLoading) - const ref = React.useRef(null) + const ref = React.useRef(null) useOnKeyboardDidShow(() => { ref.current?.scrollToEnd({animated: true}) }) diff --git a/src/components/StarterPack/Wizard/WizardEditListDialog.tsx b/src/components/StarterPack/Wizard/WizardEditListDialog.tsx index 1d69e4f4a0..fab60fc6aa 100644 --- a/src/components/StarterPack/Wizard/WizardEditListDialog.tsx +++ b/src/components/StarterPack/Wizard/WizardEditListDialog.tsx @@ -76,10 +76,7 @@ export function WizardEditListDialog({ ) return ( - + + diff --git a/src/components/dms/ConvoMenu.tsx b/src/components/dms/ConvoMenu.tsx index a4fa625fae..affc292c18 100644 --- a/src/components/dms/ConvoMenu.tsx +++ b/src/components/dms/ConvoMenu.tsx @@ -136,7 +136,7 @@ let ConvoMenu = ({ + onPress={() => leaveConvoControl.open()}> Leave conversation @@ -195,7 +195,7 @@ let ConvoMenu = ({ + onPress={() => reportControl.open()}> Report conversation @@ -206,7 +206,7 @@ let ConvoMenu = ({ + onPress={() => leaveConvoControl.open()}> Leave conversation diff --git a/src/components/dms/MessageMenu.tsx b/src/components/dms/MessageMenu.tsx index 2978d2b220..8680a68bfb 100644 --- a/src/components/dms/MessageMenu.tsx +++ b/src/components/dms/MessageMenu.tsx @@ -7,11 +7,11 @@ import {useLingui} from '@lingui/react' import {richTextToString} from '#/lib/strings/rich-text-helpers' import {getTranslatorLink} from '#/locale/helpers' +import {isWeb} from '#/platform/detection' +import {useConvoActive} from '#/state/messages/convo' import {useLanguagePrefs} from '#/state/preferences' import {useOpenLink} from '#/state/preferences/in-app-browser' -import {isWeb} from 'platform/detection' -import {useConvoActive} from 'state/messages/convo' -import {useSession} from 'state/session' +import {useSession} from '#/state/session' import * as Toast from '#/view/com/util/Toast' import {atoms as a, useTheme} from '#/alf' import {ReportDialog} from '#/components/dms/ReportDialog' @@ -120,7 +120,7 @@ export let MessageMenu = ({ + onPress={() => deleteControl.open()}> {_(msg`Delete for me`)} @@ -128,7 +128,7 @@ export let MessageMenu = ({ + onPress={() => reportControl.open()}> {_(msg`Report`)} diff --git a/src/components/dms/ReportDialog.tsx b/src/components/dms/ReportDialog.tsx index 28b5e86202..60a18723b0 100644 --- a/src/components/dms/ReportDialog.tsx +++ b/src/components/dms/ReportDialog.tsx @@ -10,7 +10,6 @@ import {useLingui} from '@lingui/react' import {useMutation} from '@tanstack/react-query' import {ReportOption} from '#/lib/moderation/useReportOptions' -import {isAndroid} from '#/platform/detection' import {useAgent} from '#/state/session' import {CharProgress} from '#/view/com/composer/char-progress/CharProgress' import * as Toast from '#/view/com/util/Toast' @@ -41,9 +40,7 @@ let ReportDialog = ({ }): React.ReactNode => { const {_} = useLingui() return ( - + diff --git a/src/components/dms/dialogs/NewChatDialog.tsx b/src/components/dms/dialogs/NewChatDialog.tsx index 19f6eb6dfc..e838236e1e 100644 --- a/src/components/dms/dialogs/NewChatDialog.tsx +++ b/src/components/dms/dialogs/NewChatDialog.tsx @@ -2,9 +2,9 @@ import React, {useCallback} from 'react' import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' +import {logEvent} from '#/lib/statsig/statsig' import {logger} from '#/logger' import {useGetConvoForMembers} from '#/state/queries/messages/get-convo-for-members' -import {logEvent} from 'lib/statsig/statsig' import {FAB} from '#/view/com/util/fab/FAB' import * as Toast from '#/view/com/util/Toast' import {useTheme} from '#/alf' @@ -55,10 +55,7 @@ export function NewChat({ accessibilityHint="" /> - + void }) { return ( - + ) diff --git a/src/screens/StarterPack/StarterPackScreen.tsx b/src/screens/StarterPack/StarterPackScreen.tsx index 0aa863f7b2..68803ac005 100644 --- a/src/screens/StarterPack/StarterPackScreen.tsx +++ b/src/screens/StarterPack/StarterPackScreen.tsx @@ -15,35 +15,35 @@ import {useNavigation} from '@react-navigation/native' import {NativeStackScreenProps} from '@react-navigation/native-stack' import {useQueryClient} from '@tanstack/react-query' +import {batchedUpdates} from '#/lib/batchedUpdates' +import {HITSLOP_20} from '#/lib/constants' +import {isBlockedOrBlocking, isMuted} from '#/lib/moderation/blocked-and-muted' +import {makeProfileLink, makeStarterPackLink} from '#/lib/routes/links' +import {CommonNavigatorParams, NavigationProp} from '#/lib/routes/types' +import {logEvent} from '#/lib/statsig/statsig' import {cleanError} from '#/lib/strings/errors' +import {getStarterPackOgCard} from '#/lib/strings/starter-pack' import {logger} from '#/logger' +import {isWeb} from '#/platform/detection' +import {updateProfileShadow} from '#/state/cache/profile-shadow' +import {useModerationOpts} from '#/state/preferences/moderation-opts' +import {getAllListMembers} from '#/state/queries/list-members' +import {useResolvedStarterPackShortLink} from '#/state/queries/resolve-short-link' +import {useResolveDidQuery} from '#/state/queries/resolve-uri' +import {useShortenLink} from '#/state/queries/shorten-link' import {useDeleteStarterPackMutation} from '#/state/queries/starter-packs' +import {useStarterPackQuery} from '#/state/queries/starter-packs' +import {useAgent, useSession} from '#/state/session' +import {useLoggedOutViewControls} from '#/state/shell/logged-out' import { ProgressGuideAction, useProgressGuideControls, } from '#/state/shell/progress-guide' -import {batchedUpdates} from 'lib/batchedUpdates' -import {HITSLOP_20} from 'lib/constants' -import {isBlockedOrBlocking, isMuted} from 'lib/moderation/blocked-and-muted' -import {makeProfileLink, makeStarterPackLink} from 'lib/routes/links' -import {CommonNavigatorParams, NavigationProp} from 'lib/routes/types' -import {logEvent} from 'lib/statsig/statsig' -import {getStarterPackOgCard} from 'lib/strings/starter-pack' -import {isWeb} from 'platform/detection' -import {updateProfileShadow} from 'state/cache/profile-shadow' -import {useModerationOpts} from 'state/preferences/moderation-opts' -import {getAllListMembers} from 'state/queries/list-members' -import {useResolvedStarterPackShortLink} from 'state/queries/resolve-short-link' -import {useResolveDidQuery} from 'state/queries/resolve-uri' -import {useShortenLink} from 'state/queries/shorten-link' -import {useStarterPackQuery} from 'state/queries/starter-packs' -import {useAgent, useSession} from 'state/session' -import {useLoggedOutViewControls} from 'state/shell/logged-out' -import {useSetActiveStarterPack} from 'state/shell/starter-pack' +import {useSetActiveStarterPack} from '#/state/shell/starter-pack' +import {PagerWithHeader} from '#/view/com/pager/PagerWithHeader' +import {ProfileSubpageHeader} from '#/view/com/profile/ProfileSubpageHeader' import * as Toast from '#/view/com/util/Toast' -import {PagerWithHeader} from 'view/com/pager/PagerWithHeader' -import {ProfileSubpageHeader} from 'view/com/profile/ProfileSubpageHeader' -import {CenteredView} from 'view/com/util/Views' +import {CenteredView} from '#/view/com/util/Views' import {bulkWriteFollows} from '#/screens/Onboarding/util' import {atoms as a, useBreakpoints, useTheme} from '#/alf' import {Button, ButtonIcon, ButtonText} from '#/components/Button' @@ -591,7 +591,7 @@ function OverflowMenu({ + onPress={() => reportDialogControl.open()}> Report starter pack diff --git a/src/view/com/auth/server-input/index.tsx b/src/view/com/auth/server-input/index.tsx index 4e36688aec..de7ed6d15b 100644 --- a/src/view/com/auth/server-input/index.tsx +++ b/src/view/com/auth/server-input/index.tsx @@ -66,10 +66,7 @@ export function ServerInputDialog({ ]) return ( - + diff --git a/src/view/com/composer/GifAltText.tsx b/src/view/com/composer/GifAltText.tsx index 53db2da941..1737fc29ca 100644 --- a/src/view/com/composer/GifAltText.tsx +++ b/src/view/com/composer/GifAltText.tsx @@ -12,7 +12,6 @@ import { parseEmbedPlayerFromUrl, } from '#/lib/strings/embed-player' import {enforceLen} from '#/lib/strings/helpers' -import {isAndroid} from '#/platform/detection' import {Gif} from '#/state/queries/tenor' import {atoms as a, native, useTheme} from '#/alf' import {Button, ButtonText} from '#/components/Button' @@ -96,9 +95,7 @@ export function GifAltText({ - + Captions & alt text : Alt text} - +
diff --git a/src/view/com/util/forms/PostDropdownBtn.tsx b/src/view/com/util/forms/PostDropdownBtn.tsx index fe6efc02fa..ef87c24533 100644 --- a/src/view/com/util/forms/PostDropdownBtn.tsx +++ b/src/view/com/util/forms/PostDropdownBtn.tsx @@ -437,7 +437,7 @@ let PostDropdownBtn = ({ + onPress={() => sendViaChatControl.open()}> Send via direct message @@ -465,7 +465,7 @@ let PostDropdownBtn = ({ + onPress={() => embedPostControl.open()}> {_(msg`Embed post`)} @@ -540,7 +540,7 @@ let PostDropdownBtn = ({ ? _(msg`Hide reply for me`) : _(msg`Hide post for me`) } - onPress={hidePromptControl.open}> + onPress={() => hidePromptControl.open()}> {isReply ? _(msg`Hide reply for me`) @@ -628,7 +628,9 @@ let PostDropdownBtn = ({ + postInteractionSettingsDialogControl.open() + } {...(isAuthor ? Platform.select({ web: { @@ -647,7 +649,7 @@ let PostDropdownBtn = ({ + onPress={() => deletePromptControl.open()}> {_(msg`Delete post`)} diff --git a/src/view/screens/Storybook/Dialogs.tsx b/src/view/screens/Storybook/Dialogs.tsx index bb13831046..a0a2a27551 100644 --- a/src/view/screens/Storybook/Dialogs.tsx +++ b/src/view/screens/Storybook/Dialogs.tsx @@ -185,9 +185,7 @@ export function Dialogs() {
- + From 0ed5d48e027eaa886950218a4b0d7ea5443464b5 Mon Sep 17 00:00:00 2001 From: Hailey Date: Wed, 2 Oct 2024 16:14:47 -0700 Subject: [PATCH 06/62] [Sheets] [Pt. 6] Update `Inner` and `InnerFlatList` and their uses (#5564) --- src/components/Dialog/index.tsx | 40 +++++-------------- .../Wizard/WizardEditListDialog.tsx | 14 ++----- src/components/dialogs/GifSelect.tsx | 4 +- .../dms/dialogs/SearchablePeopleList.tsx | 17 ++++---- src/view/com/util/post-ctrls/RepostButton.tsx | 4 +- 5 files changed, 25 insertions(+), 54 deletions(-) diff --git a/src/components/Dialog/index.tsx b/src/components/Dialog/index.tsx index 6799c35afb..303da0d009 100644 --- a/src/components/Dialog/index.tsx +++ b/src/components/Dialog/index.tsx @@ -1,17 +1,11 @@ import React, {useImperativeHandle} from 'react' -import {StyleProp, View, ViewStyle} from 'react-native' +import {StyleProp, TextInput, View, ViewStyle} from 'react-native' import {useSafeAreaInsets} from 'react-native-safe-area-context' -import { - BottomSheetFlatList, - BottomSheetFlatListMethods, - BottomSheetTextInput, - BottomSheetView, -} from '@discord/bottom-sheet/src' -import {BottomSheetFlatListProps} from '@discord/bottom-sheet/src/components/bottomSheetScrollable/types' import {BlueskyBottomSheetView} from '@haileyok/bluesky-bottom-sheet' import {logger} from '#/logger' import {useDialogStateControlContext} from '#/state/dialogs' +import {List, ListMethods, ListProps} from '#/view/com/util/List' import {ScrollView} from '#/view/com/util/Views' import {atoms as a, flatten, useTheme} from '#/alf' import {Context} from '#/components/Dialog/context' @@ -27,7 +21,7 @@ export {useDialogContext, useDialogControl} from '#/components/Dialog/context' export * from '#/components/Dialog/types' export * from '#/components/Dialog/utils' // @ts-ignore -export const Input = createInput(BottomSheetTextInput) +export const Input = createInput(TextInput) export function Outer({ children, @@ -116,20 +110,16 @@ export function Outer({ export function Inner({children, style}: DialogInnerProps) { const insets = useSafeAreaInsets() return ( - {children} - +
) } @@ -146,13 +136,12 @@ export const ScrollableInner = React.forwardRef( ) export const InnerFlatList = React.forwardRef< - BottomSheetFlatListMethods, - BottomSheetFlatListProps & {webInnerStyle?: StyleProp} + ListMethods, + ListProps & {webInnerStyle?: StyleProp} >(function InnerFlatList({style, contentContainerStyle, ...props}, ref) { const insets = useSafeAreaInsets() - return ( - ) }) diff --git a/src/components/StarterPack/Wizard/WizardEditListDialog.tsx b/src/components/StarterPack/Wizard/WizardEditListDialog.tsx index fab60fc6aa..d1ecdc8821 100644 --- a/src/components/StarterPack/Wizard/WizardEditListDialog.tsx +++ b/src/components/StarterPack/Wizard/WizardEditListDialog.tsx @@ -3,13 +3,13 @@ import type {ListRenderItemInfo} from 'react-native' import {View} from 'react-native' import {AppBskyActorDefs, ModerationOpts} from '@atproto/api' import {GeneratorView} from '@atproto/api/dist/client/types/app/bsky/feed/defs' -import {BottomSheetFlatListMethods} from '@discord/bottom-sheet' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {useInitialNumToRender} from '#/lib/hooks/useInitialNumToRender' import {isWeb} from '#/platform/detection' import {useSession} from '#/state/session' +import {ListMethods} from '#/view/com/util/List' import {WizardAction, WizardState} from '#/screens/StarterPack/Wizard/State' import {atoms as a, native, useTheme, web} from '#/alf' import {Button, ButtonText} from '#/components/Button' @@ -45,7 +45,7 @@ export function WizardEditListDialog({ const {currentAccount} = useSession() const initialNumToRender = useInitialNumToRender() - const listRef = useRef(null) + const listRef = useRef(null) const getData = () => { if (state.currentStep === 'Feeds') return state.feeds @@ -99,13 +99,7 @@ export function WizardEditListDialog({ height: 48, }, ] - : [ - a.pb_sm, - a.align_end, - { - height: 68, - }, - ], + : [a.pb_sm, a.align_end], ]}> @@ -139,8 +133,6 @@ export function WizardEditListDialog({ paddingHorizontal: 0, marginTop: 0, paddingTop: 0, - borderTopLeftRadius: 40, - borderTopRightRadius: 40, }), ]} webInnerStyle={[a.py_0, {maxWidth: 500, minWidth: 200}]} diff --git a/src/components/dialogs/GifSelect.tsx b/src/components/dialogs/GifSelect.tsx index 903722562c..887cc30378 100644 --- a/src/components/dialogs/GifSelect.tsx +++ b/src/components/dialogs/GifSelect.tsx @@ -6,7 +6,6 @@ import React, { useState, } from 'react' import {TextInput, View} from 'react-native' -import {BottomSheetFlatListMethods} from '@discord/bottom-sheet' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' @@ -19,6 +18,7 @@ import { } from '#/state/queries/tenor' import {ErrorScreen} from '#/view/com/util/error/ErrorScreen' import {ErrorBoundary} from '#/view/com/util/ErrorBoundary' +import {ListMethods} from '#/view/com/util/List' import {atoms as a, useBreakpoints, useTheme} from '#/alf' import * as Dialog from '#/components/Dialog' import * as TextField from '#/components/forms/TextField' @@ -76,7 +76,7 @@ function GifList({ const t = useTheme() const {gtMobile} = useBreakpoints() const textInputRef = useRef(null) - const listRef = useRef(null) + const listRef = useRef(null) const [undeferredSearch, setSearch] = useState('') const search = useThrottledValue(undeferredSearch, 500) diff --git a/src/components/dms/dialogs/SearchablePeopleList.tsx b/src/components/dms/dialogs/SearchablePeopleList.tsx index a13dfe509f..17a7f43e57 100644 --- a/src/components/dms/dialogs/SearchablePeopleList.tsx +++ b/src/components/dms/dialogs/SearchablePeopleList.tsx @@ -5,10 +5,8 @@ import React, { useRef, useState, } from 'react' -import type {TextInput as TextInputType} from 'react-native' -import {View} from 'react-native' +import {TextInput, View} from 'react-native' import {AppBskyActorDefs, moderateProfile, ModerationOpts} from '@atproto/api' -import {BottomSheetFlatListMethods} from '@discord/bottom-sheet' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' @@ -16,15 +14,15 @@ import {sanitizeDisplayName} from '#/lib/strings/display-names' import {sanitizeHandle} from '#/lib/strings/handles' import {isWeb} from '#/platform/detection' import {useModerationOpts} from '#/state/preferences/moderation-opts' +import {useActorAutocompleteQuery} from '#/state/queries/actor-autocomplete' import {useListConvosQuery} from '#/state/queries/messages/list-converations' import {useProfileFollowsQuery} from '#/state/queries/profile-follows' import {useSession} from '#/state/session' -import {useActorAutocompleteQuery} from 'state/queries/actor-autocomplete' +import {ListMethods} from '#/view/com/util/List' import {UserAvatar} from '#/view/com/util/UserAvatar' import {atoms as a, native, useTheme, web} from '#/alf' import {Button} from '#/components/Button' import * as Dialog from '#/components/Dialog' -import {TextInput} from '#/components/dms/dialogs/TextInput' import {canBeMessaged} from '#/components/dms/util' import {useInteractionState} from '#/components/hooks/useInteractionState' import {ChevronLeft_Stroke2_Corner0_Rounded as ChevronLeft} from '#/components/icons/Chevron' @@ -66,9 +64,9 @@ export function SearchablePeopleList({ const {_} = useLingui() const moderationOpts = useModerationOpts() const control = Dialog.useDialogContext() - const listRef = useRef(null) + const listRef = useRef(null) const {currentAccount} = useSession() - const inputRef = useRef(null) + const inputRef = useRef(null) const [searchText, setSearchText] = useState('') @@ -242,13 +240,12 @@ export function SearchablePeopleList({ void onEscape: () => void - inputRef: React.RefObject + inputRef: React.RefObject }) { const t = useTheme() const {_} = useLingui() diff --git a/src/view/com/util/post-ctrls/RepostButton.tsx b/src/view/com/util/post-ctrls/RepostButton.tsx index 8a41ec88ac..14c869df8d 100644 --- a/src/view/com/util/post-ctrls/RepostButton.tsx +++ b/src/view/com/util/post-ctrls/RepostButton.tsx @@ -86,7 +86,9 @@ let RepostButton = ({ ) : undefined} - + From ecf7215a34a8751af4fc9a166545858c441516f0 Mon Sep 17 00:00:00 2001 From: Hailey Date: Wed, 2 Oct 2024 21:11:27 -0700 Subject: [PATCH 07/62] [Sheets] [Pt. 7] Part seven rework, much simplier! (#5582) --- src/components/BottomSheetButton.tsx | 12 ++ src/components/BottomSheetLink.tsx | 92 +++++++++++++ src/components/BottomSheetLink.web.tsx | 3 + src/components/Button.tsx | 20 ++- src/components/Dialog/context.ts | 1 + src/components/Dialog/index.tsx | 2 +- src/components/Dialog/types.ts | 1 + src/components/Link.tsx | 46 ++++++- src/components/Menu/index.tsx | 6 +- src/components/Menu/types.ts | 6 +- src/components/NormalizedRNGHPressable.tsx | 128 ++++++++++++++++++ .../NormalizedRNGHPressable.web.tsx | 3 + .../ReportDialog/SelectLabelerView.tsx | 8 +- .../ReportDialog/SelectReportOptionView.tsx | 6 +- .../moderation/LabelsOnMeDialog.tsx | 50 +++---- 15 files changed, 341 insertions(+), 43 deletions(-) create mode 100644 src/components/BottomSheetButton.tsx create mode 100644 src/components/BottomSheetLink.tsx create mode 100644 src/components/BottomSheetLink.web.tsx create mode 100644 src/components/NormalizedRNGHPressable.tsx create mode 100644 src/components/NormalizedRNGHPressable.web.tsx diff --git a/src/components/BottomSheetButton.tsx b/src/components/BottomSheetButton.tsx new file mode 100644 index 0000000000..9eaee55deb --- /dev/null +++ b/src/components/BottomSheetButton.tsx @@ -0,0 +1,12 @@ +import React from 'react' + +import {Button, ButtonProps} from '#/components/Button' +import {NormalizedRNGHPressable} from '#/components/NormalizedRNGHPressable' + +export function BottomSheetButton({children, ...rest}: ButtonProps) { + return ( + + ) +} diff --git a/src/components/BottomSheetLink.tsx b/src/components/BottomSheetLink.tsx new file mode 100644 index 0000000000..36d52c90c1 --- /dev/null +++ b/src/components/BottomSheetLink.tsx @@ -0,0 +1,92 @@ +import React from 'react' +import {StackActions, useNavigation} from '@react-navigation/native' + +import {NavigationProp} from '#/lib/routes/types' +import {flatten, useTheme} from '#/alf' +import {useDialogContext} from '#/components/Dialog' +import {useInteractionState} from '#/components/hooks/useInteractionState' +import {InlineLinkProps, useLink} from '#/components/Link' +import {NormalizedRNGHPressable} from '#/components/NormalizedRNGHPressable' +import {Text} from '#/components/Typography' +import {router} from '#/routes' + +export function BottomSheetInlineLinkText({ + children, + to, + action = 'push', + disableMismatchWarning, + style, + onPress: outerOnPress, + label, + shareOnLongPress, + disableUnderline, + ...rest +}: InlineLinkProps) { + const t = useTheme() + const stringChildren = typeof children === 'string' + const navigation = useNavigation() + const dialog = useDialogContext() + + const {href, isExternal, onLongPress} = useLink({ + to, + displayText: stringChildren ? children : '', + action, + disableMismatchWarning, + onPress: outerOnPress, + shareOnLongPress, + }) + const { + state: pressed, + onIn: onPressIn, + onOut: onPressOut, + } = useInteractionState() + + const onPress = () => { + if (isExternal) { + return + } + + dialog.close() + + if (action === 'push') { + navigation.dispatch(StackActions.push(...router.matchPath(href))) + } else if (action === 'replace') { + navigation.dispatch(StackActions.replace(...router.matchPath(href))) + } else if (action === 'navigate') { + // @ts-ignore + navigation.navigate(...router.matchPath(href)) + } else { + throw Error('Unsupported navigator action.') + } + } + + const flattenedStyle = flatten(style) || {} + + // eslint-disable-next-line bsky-internal/avoid-unwrapped-text + return ( + + + {children} + + + ) +} diff --git a/src/components/BottomSheetLink.web.tsx b/src/components/BottomSheetLink.web.tsx new file mode 100644 index 0000000000..6bfb275c25 --- /dev/null +++ b/src/components/BottomSheetLink.web.tsx @@ -0,0 +1,3 @@ +import {Link as BottomSheetLink} from './Link' + +export {BottomSheetLink} diff --git a/src/components/Button.tsx b/src/components/Button.tsx index 17179994a9..98ad1709c4 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -15,7 +15,9 @@ import { import {LinearGradient} from 'expo-linear-gradient' import {atoms as a, flatten, select, tokens, useTheme, web} from '#/alf' +import {useDialogContext} from '#/components/Dialog' import {Props as SVGIconProps} from '#/components/icons/common' +import {NormalizedRNGHPressable} from '#/components/NormalizedRNGHPressable' import {Text} from '#/components/Typography' export type ButtonVariant = 'solid' | 'outline' | 'ghost' | 'gradient' @@ -87,6 +89,7 @@ export type ButtonProps = Pick< style?: StyleProp hoverStyle?: StyleProp children: NonTextElements | ((context: ButtonContext) => NonTextElements) + Component?: React.ComponentType } export type ButtonTextProps = TextProps & VariantProps & {disabled?: boolean} @@ -114,10 +117,22 @@ export const Button = React.forwardRef( disabled = false, style, hoverStyle: hoverStyleProp, + Component, ...rest }, ref, ) => { + // This will pick the correct default pressable to use. If we are inside a dialog, we need to use the RNGH + // pressable so that it is usable inside the dialog. + const {insideDialog} = useDialogContext() + if (!Component) { + if (insideDialog) { + Component = NormalizedRNGHPressable + } else { + Component = Pressable + } + } + const t = useTheme() const [state, setState] = React.useState({ pressed: false, @@ -449,10 +464,11 @@ export const Button = React.forwardRef( const flattenedBaseStyles = flatten([baseStyles, style]) return ( - ( {typeof children === 'function' ? children(context) : children} - + ) }, ) diff --git a/src/components/Dialog/context.ts b/src/components/Dialog/context.ts index 859f8edd77..27b8a56375 100644 --- a/src/components/Dialog/context.ts +++ b/src/components/Dialog/context.ts @@ -9,6 +9,7 @@ import { export const Context = React.createContext({ close: () => {}, + insideDialog: false, }) export function useDialogContext() { diff --git a/src/components/Dialog/index.tsx b/src/components/Dialog/index.tsx index 303da0d009..6fbc8d87a0 100644 --- a/src/components/Dialog/index.tsx +++ b/src/components/Dialog/index.tsx @@ -82,7 +82,7 @@ export function Outer({ [open, close], ) - const context = React.useMemo(() => ({close}), [close]) + const context = React.useMemo(() => ({close, insideDialog: true}), [close]) return ( diff --git a/src/components/Dialog/types.ts b/src/components/Dialog/types.ts index ed83bd02b1..a8568e5748 100644 --- a/src/components/Dialog/types.ts +++ b/src/components/Dialog/types.ts @@ -37,6 +37,7 @@ export type DialogControlProps = DialogControlRefProps & { export type DialogContextProps = { close: DialogControlProps['close'] + insideDialog: boolean } export type DialogControlOpenOptions = { diff --git a/src/components/Link.tsx b/src/components/Link.tsx index c80b9f3707..56d030b5df 100644 --- a/src/components/Link.tsx +++ b/src/components/Link.tsx @@ -23,6 +23,7 @@ import {shouldClickOpenNewTab} from '#/platform/urls' import {useModalControls} from '#/state/modals' import {useOpenLink} from '#/state/preferences/in-app-browser' import {atoms as a, flatten, TextStyleProp, useTheme, web} from '#/alf' +import {BottomSheetButton} from '#/components/BottomSheetButton' import {Button, ButtonProps} from '#/components/Button' import {useInteractionState} from '#/components/hooks/useInteractionState' import {Text, TextProps} from '#/components/Typography' @@ -103,17 +104,17 @@ export function useLink({ linkRequiresWarning(href, displayText), ) - if (requiresWarning) { + if (isWeb) { e.preventDefault() + } + if (requiresWarning) { openModal({ name: 'link-warning', text: displayText, href: href, }) } else { - e.preventDefault() - if (isExternal) { openLink(href) } else { @@ -241,6 +242,45 @@ export function Link({ ) } +export function BottomSheetLink({ + children, + to, + action = 'push', + onPress: outerOnPress, + download, + ...rest +}: LinkProps) { + const {href, isExternal, onPress} = useLink({ + to, + displayText: typeof children === 'string' ? children : '', + action, + onPress: outerOnPress, + }) + + return ( + + {children} + + ) +} + export type InlineLinkProps = React.PropsWithChildren< BaseLinkProps & TextStyleProp & Pick > & diff --git a/src/components/Menu/index.tsx b/src/components/Menu/index.tsx index c48d6f9bd0..809df96908 100644 --- a/src/components/Menu/index.tsx +++ b/src/components/Menu/index.tsx @@ -1,6 +1,5 @@ import React from 'react' import {StyleProp, View, ViewStyle} from 'react-native' -import {BlueskyBottomSheetPressable as Pressable} from '@haileyok/bluesky-bottom-sheet' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import flattenReactChildren from 'react-keyed-flatten-children' @@ -19,6 +18,7 @@ import { ItemTextProps, TriggerProps, } from '#/components/Menu/types' +import {NormalizedRNGHPressable} from '#/components/NormalizedRNGHPressable' import {Text} from '#/components/Typography' export { @@ -117,7 +117,7 @@ export function Item({children, label, style, onPress, ...rest}: ItemProps) { } = useInteractionState() return ( - {children} - + ) } diff --git a/src/components/Menu/types.ts b/src/components/Menu/types.ts index e5d1d16a8d..2f7aea5de5 100644 --- a/src/components/Menu/types.ts +++ b/src/components/Menu/types.ts @@ -4,8 +4,6 @@ import { GestureResponderEvent, PressableProps, } from 'react-native' -import {PressableEvent} from 'react-native-gesture-handler/lib/typescript/components/Pressable/PressableProps' -import {BueskyBottomSheetPressableProps} from '@haileyok/bluesky-bottom-sheet' import {TextStyleProp, ViewStyleProp} from '#/alf' import * as Dialog from '#/components/Dialog' @@ -89,10 +87,10 @@ export type TriggerChildProps = } export type ItemProps = React.PropsWithChildren< - Omit & + Omit & ViewStyleProp & { label: string - onPress: (e: PressableEvent | GestureResponderEvent) => void + onPress: (e: GestureResponderEvent) => void } > diff --git a/src/components/NormalizedRNGHPressable.tsx b/src/components/NormalizedRNGHPressable.tsx new file mode 100644 index 0000000000..351005619d --- /dev/null +++ b/src/components/NormalizedRNGHPressable.tsx @@ -0,0 +1,128 @@ +import React from 'react' +import { + GestureResponderEvent, + MeasureOnSuccessCallback, + NativeMouseEvent, + NativeSyntheticEvent, + PressableProps, +} from 'react-native' +import {Pressable as BSPressable} from 'react-native-gesture-handler' +import {PressableEvent} from 'react-native-gesture-handler/lib/typescript/components/Pressable/PressableProps' + +function pressableEventToGestureResponderEvent( + event: PressableEvent, + target: NormalizedRNGHPressable, +): GestureResponderEvent { + return { + nativeEvent: { + ...event.nativeEvent, + touches: [], + changedTouches: [], + identifier: event.nativeEvent.identifier.toString(), + target: event.nativeEvent.target.toString(), + }, + // @ts-expect-error + target: target, + // @ts-expect-error + currentTarget: target, + preventDefault() {}, + stopPropagation() {}, + cancelable: false, + defaultPrevented: false, + eventPhase: 0, + isTrusted: false, + bubbles: false, + timeStamp: event.nativeEvent.timestamp, + isDefaultPrevented(): boolean { + return false + }, + isPropagationStopped(): boolean { + return false + }, + persist() {}, + type: 'press', + } +} + +function pressableEventToMouseEvent( + event: PressableEvent, + target: NormalizedRNGHPressable, +): MouseEvent & NativeSyntheticEvent { + return { + ...event.nativeEvent, + // @ts-expect-error + target: target, + // @ts-expect-error + currentTarget: target, + preventDefault() {}, + stopPropagation() {}, + cancelable: false, + defaultPrevented: false, + eventPhase: 0, + isTrusted: false, + bubbles: false, + timeStamp: event.nativeEvent.timestamp, + } +} + +export class NormalizedRNGHPressable extends React.Component { + static displayName = 'Pressable' + + measure = (_: MeasureOnSuccessCallback) => {} + + measureLayout = (_: number) => {} + + measureInWindow = ( + _: (x: number, y: number, width: number, height: number) => void, + ) => {} + + setNativeProps = (_: PressableProps) => {} + + focus = () => {} + + blur = () => {} + + onPress = (event: PressableEvent) => { + if (!this.props.onPress) return + this.props.onPress(pressableEventToGestureResponderEvent(event, this)) + } + + onLongPress = (event: PressableEvent) => { + if (!this.props.onLongPress) return + this.props.onLongPress(pressableEventToGestureResponderEvent(event, this)) + } + + onPressIn = (event: PressableEvent) => { + if (!this.props.onPressIn) return + this.props.onPressIn(pressableEventToGestureResponderEvent(event, this)) + } + + onPressOut = (event: PressableEvent) => { + if (!this.props.onPressOut) return + this.props.onPressOut(pressableEventToGestureResponderEvent(event, this)) + } + + onHoverIn = (event: PressableEvent) => { + if (!this.props.onHoverIn) return + this.props.onHoverIn(pressableEventToMouseEvent(event, this)) + } + + onHoverOut = (event: PressableEvent) => { + if (!this.props.onHoverOut) return + this.props.onHoverOut(pressableEventToMouseEvent(event, this)) + } + + render() { + return ( + + ) + } +} diff --git a/src/components/NormalizedRNGHPressable.web.tsx b/src/components/NormalizedRNGHPressable.web.tsx new file mode 100644 index 0000000000..86f5730495 --- /dev/null +++ b/src/components/NormalizedRNGHPressable.web.tsx @@ -0,0 +1,3 @@ +import {Pressable as NormalizedRNGHPressable} from 'react-native' + +export {NormalizedRNGHPressable} diff --git a/src/components/ReportDialog/SelectLabelerView.tsx b/src/components/ReportDialog/SelectLabelerView.tsx index f7a8139ea5..e62dc9910b 100644 --- a/src/components/ReportDialog/SelectLabelerView.tsx +++ b/src/components/ReportDialog/SelectLabelerView.tsx @@ -4,10 +4,10 @@ import {AppBskyLabelerDefs} from '@atproto/api' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' -export {useDialogControl as useReportDialogControl} from '#/components/Dialog' import {getLabelingServiceTitle} from '#/lib/moderation' import {atoms as a, useBreakpoints, useTheme} from '#/alf' -import {Button, useButtonContext} from '#/components/Button' +import {BottomSheetButton} from '#/components/BottomSheetButton' +import {useButtonContext} from '#/components/Button' import {Divider} from '#/components/Divider' import * as LabelingServiceCard from '#/components/LabelingServiceCard' import {Text} from '#/components/Typography' @@ -39,12 +39,12 @@ export function SelectLabelerView({ {props.labelers.map(labeler => { return ( - + ) })} diff --git a/src/components/ReportDialog/SelectReportOptionView.tsx b/src/components/ReportDialog/SelectReportOptionView.tsx index 169c07d732..7e27cacf0c 100644 --- a/src/components/ReportDialog/SelectReportOptionView.tsx +++ b/src/components/ReportDialog/SelectReportOptionView.tsx @@ -5,7 +5,7 @@ import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' import {ReportOption, useReportOptions} from '#/lib/moderation/useReportOptions' -import {Link} from '#/components/Link' +import {BottomSheetLink} from '#/components/Link' import {DMCA_LINK} from '#/components/ReportDialog/const' export {useDialogControl as useReportDialogControl} from '#/components/Dialog' @@ -129,7 +129,7 @@ export function SelectReportOptionView({ ]}> Need to report a copyright violation?
- View details - +
)}
diff --git a/src/components/moderation/LabelsOnMeDialog.tsx b/src/components/moderation/LabelsOnMeDialog.tsx index 389c722c87..22eb406a00 100644 --- a/src/components/moderation/LabelsOnMeDialog.tsx +++ b/src/components/moderation/LabelsOnMeDialog.tsx @@ -13,7 +13,9 @@ import {logger} from '#/logger' import {useAgent, useSession} from '#/state/session' import * as Toast from '#/view/com/util/Toast' import {atoms as a, useBreakpoints, useTheme} from '#/alf' -import {Button, ButtonIcon, ButtonText} from '#/components/Button' +import {BottomSheetButton} from '#/components/BottomSheetButton' +import {BottomSheetInlineLinkText} from '#/components/BottomSheetLink' +import {ButtonIcon, ButtonText} from '#/components/Button' import * as Dialog from '#/components/Dialog' import {InlineLinkText} from '#/components/Link' import {Text} from '#/components/Typography' @@ -139,7 +141,7 @@ function Label({
{!isSelfLabel && ( - + )}
@@ -156,23 +158,25 @@ function Label({ - - {isSelfLabel ? ( + {isSelfLabel ? ( + This label was applied by you. - ) : ( - - Source:{' '} - control.close()}> - {sourceName} - - - )} - + + ) : ( + + + Source: {' '} + + control.close()}> + {sourceName} + + + )}
) @@ -275,7 +279,7 @@ function AppealForm({ ? [a.flex_row, a.justify_between] : [{flexDirection: 'column-reverse'}, a.gap_sm] }> - - +
) From c49182009a256ec8ef77bd2cc1830620534a21d5 Mon Sep 17 00:00:00 2001 From: Hailey Date: Wed, 2 Oct 2024 21:26:58 -0700 Subject: [PATCH 08/62] [Sheets] [Pt. 8] Allow nesting in other sheets or native modals (#5567) --- package.json | 2 +- src/components/Dialog/index.tsx | 61 +++++++++++++------ src/components/Dialog/index.web.tsx | 1 + src/components/Link.tsx | 5 +- src/components/Prompt.tsx | 23 +++++-- .../ReportDialog/SelectLabelerView.tsx | 7 +-- src/components/ReportDialog/index.tsx | 3 +- .../moderation/LabelsOnMeDialog.tsx | 15 +++-- .../moderation/ModerationDetailsDialog.tsx | 34 ++++++----- src/view/com/composer/Composer.tsx | 1 + yarn.lock | 8 +-- 11 files changed, 97 insertions(+), 63 deletions(-) diff --git a/package.json b/package.json index e32100ece8..273d8ddb35 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "@fortawesome/free-regular-svg-icons": "^6.1.1", "@fortawesome/free-solid-svg-icons": "^6.1.1", "@fortawesome/react-native-fontawesome": "^0.3.2", - "@haileyok/bluesky-bottom-sheet": "^0.1.1-alpha.8", + "@haileyok/bluesky-bottom-sheet": "^0.1.1-alpha.9", "@haileyok/bluesky-video": "0.1.10", "@lingui/react": "^4.5.0", "@mattermost/react-native-paste-input": "^0.7.1", diff --git a/src/components/Dialog/index.tsx b/src/components/Dialog/index.tsx index 6fbc8d87a0..7493e7748b 100644 --- a/src/components/Dialog/index.tsx +++ b/src/components/Dialog/index.tsx @@ -1,12 +1,13 @@ import React, {useImperativeHandle} from 'react' import {StyleProp, TextInput, View, ViewStyle} from 'react-native' +import {GestureHandlerRootView, ScrollView} from 'react-native-gesture-handler' import {useSafeAreaInsets} from 'react-native-safe-area-context' import {BlueskyBottomSheetView} from '@haileyok/bluesky-bottom-sheet' import {logger} from '#/logger' +import {isIOS} from '#/platform/detection' import {useDialogStateControlContext} from '#/state/dialogs' import {List, ListMethods, ListProps} from '#/view/com/util/List' -import {ScrollView} from '#/view/com/util/Views' import {atoms as a, flatten, useTheme} from '#/alf' import {Context} from '#/components/Dialog/context' import { @@ -29,6 +30,26 @@ export function Outer({ onClose, nativeOptions, testID, +}: React.PropsWithChildren) { + return ( + + + {children} + + + ) +} + +export function OuterWithoutPortal({ + children, + control, + onClose, + nativeOptions, + testID, }: React.PropsWithChildren) { const t = useTheme() const ref = React.useRef(null) @@ -84,26 +105,26 @@ export function Outer({ const context = React.useMemo(() => ({close, insideDialog: true}), [close]) + const Wrapper = isIOS ? View : GestureHandlerRootView + return ( - - - { - if (e.nativeEvent.state === 'closed') { - onCloseAnimationComplete() - } - }} - cornerRadius={20} - {...nativeOptions}> - - {children} - - - - + + { + if (e.nativeEvent.state === 'closed') { + onCloseAnimationComplete() + } + }} + cornerRadius={20} + {...nativeOptions}> + + {children} + + + ) } diff --git a/src/components/Dialog/index.web.tsx b/src/components/Dialog/index.web.tsx index f8ecbd5d94..a50e960a8a 100644 --- a/src/components/Dialog/index.web.tsx +++ b/src/components/Dialog/index.web.tsx @@ -103,6 +103,7 @@ export function Outer({ const context = React.useMemo( () => ({ close, + insideDialog: true, }), [close], ) diff --git a/src/components/Link.tsx b/src/components/Link.tsx index 56d030b5df..5a66767243 100644 --- a/src/components/Link.tsx +++ b/src/components/Link.tsx @@ -23,7 +23,6 @@ import {shouldClickOpenNewTab} from '#/platform/urls' import {useModalControls} from '#/state/modals' import {useOpenLink} from '#/state/preferences/in-app-browser' import {atoms as a, flatten, TextStyleProp, useTheme, web} from '#/alf' -import {BottomSheetButton} from '#/components/BottomSheetButton' import {Button, ButtonProps} from '#/components/Button' import {useInteractionState} from '#/components/hooks/useInteractionState' import {Text, TextProps} from '#/components/Typography' @@ -258,7 +257,7 @@ export function BottomSheetLink({ }) return ( - {children} - + ) } diff --git a/src/components/Prompt.tsx b/src/components/Prompt.tsx index 8aa111bf3d..3e877a6630 100644 --- a/src/components/Prompt.tsx +++ b/src/components/Prompt.tsx @@ -3,8 +3,9 @@ import {GestureResponderEvent, View} from 'react-native' import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' +import {isNative} from '#/platform/detection' import {atoms as a, useBreakpoints, useTheme} from '#/alf' -import {Button, ButtonColor, ButtonProps, ButtonText} from '#/components/Button' +import {Button, ButtonColor, ButtonText} from '#/components/Button' import * as Dialog from '#/components/Dialog' import {Text} from '#/components/Typography' @@ -25,9 +26,11 @@ export function Outer({ children, control, testID, + withoutPortal, }: React.PropsWithChildren<{ control: Dialog.DialogControlProps testID?: string + withoutPortal?: boolean }>) { const {gtMobile} = useBreakpoints() const titleId = React.useId() @@ -38,8 +41,11 @@ export function Outer({ [titleId, descriptionId], ) + const Wrapper = + withoutPortal && isNative ? Dialog.OuterWithoutPortal : Dialog.Outer + return ( - + - + ) } @@ -139,7 +145,7 @@ export function Action({ * Note: The dialog will close automatically when the action is pressed, you * should NOT close the dialog as a side effect of this method. */ - onPress: ButtonProps['onPress'] + onPress: (e: GestureResponderEvent) => void color?: ButtonColor /** * Optional i18n string. If undefined, it will default to "Confirm". @@ -179,6 +185,7 @@ export function Basic({ onConfirm, confirmButtonColor, showCancel = true, + withoutPortal, }: React.PropsWithChildren<{ control: Dialog.DialogOuterProps['control'] title: string @@ -192,12 +199,16 @@ export function Basic({ * Note: The dialog will close automatically when the action is pressed, you * should NOT close the dialog as a side effect of this method. */ - onConfirm: ButtonProps['onPress'] + onConfirm: (e: GestureResponderEvent) => void confirmButtonColor?: ButtonColor showCancel?: boolean + withoutPortal?: boolean }>) { return ( - + {title} {description} diff --git a/src/components/ReportDialog/SelectLabelerView.tsx b/src/components/ReportDialog/SelectLabelerView.tsx index e62dc9910b..039bbf123f 100644 --- a/src/components/ReportDialog/SelectLabelerView.tsx +++ b/src/components/ReportDialog/SelectLabelerView.tsx @@ -6,8 +6,7 @@ import {useLingui} from '@lingui/react' import {getLabelingServiceTitle} from '#/lib/moderation' import {atoms as a, useBreakpoints, useTheme} from '#/alf' -import {BottomSheetButton} from '#/components/BottomSheetButton' -import {useButtonContext} from '#/components/Button' +import {Button, useButtonContext} from '#/components/Button' import {Divider} from '#/components/Divider' import * as LabelingServiceCard from '#/components/LabelingServiceCard' import {Text} from '#/components/Typography' @@ -39,12 +38,12 @@ export function SelectLabelerView({ {props.labelers.map(labeler => { return ( - props.onSelectLabeler(labeler.creator.did)}> - + ) })} diff --git a/src/components/ReportDialog/index.tsx b/src/components/ReportDialog/index.tsx index b942659380..b781d9f39e 100644 --- a/src/components/ReportDialog/index.tsx +++ b/src/components/ReportDialog/index.tsx @@ -1,5 +1,6 @@ import React from 'react' -import {Pressable, ScrollView, View} from 'react-native' +import {Pressable, View} from 'react-native' +import {ScrollView} from 'react-native-gesture-handler' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' diff --git a/src/components/moderation/LabelsOnMeDialog.tsx b/src/components/moderation/LabelsOnMeDialog.tsx index 22eb406a00..fc30b004ad 100644 --- a/src/components/moderation/LabelsOnMeDialog.tsx +++ b/src/components/moderation/LabelsOnMeDialog.tsx @@ -13,9 +13,8 @@ import {logger} from '#/logger' import {useAgent, useSession} from '#/state/session' import * as Toast from '#/view/com/util/Toast' import {atoms as a, useBreakpoints, useTheme} from '#/alf' -import {BottomSheetButton} from '#/components/BottomSheetButton' import {BottomSheetInlineLinkText} from '#/components/BottomSheetLink' -import {ButtonIcon, ButtonText} from '#/components/Button' +import {Button, ButtonIcon, ButtonText} from '#/components/Button' import * as Dialog from '#/components/Dialog' import {InlineLinkText} from '#/components/Link' import {Text} from '#/components/Typography' @@ -141,7 +140,7 @@ function Label({
{!isSelfLabel && ( - Appeal - + )}
@@ -279,7 +278,7 @@ function AppealForm({ ? [a.flex_row, a.justify_between] : [{flexDirection: 'column-reverse'}, a.gap_sm] }> - {_(msg`Back`)} - - + ) diff --git a/src/components/moderation/ModerationDetailsDialog.tsx b/src/components/moderation/ModerationDetailsDialog.tsx index 1198e8b921..2fb190efa5 100644 --- a/src/components/moderation/ModerationDetailsDialog.tsx +++ b/src/components/moderation/ModerationDetailsDialog.tsx @@ -10,6 +10,7 @@ import {listUriToHref} from '#/lib/strings/url-helpers' import {isNative} from '#/platform/detection' import {useSession} from '#/state/session' import {atoms as a, useTheme} from '#/alf' +import {BottomSheetInlineLinkText} from '#/components/BottomSheetLink' import * as Dialog from '#/components/Dialog' import {Divider} from '#/components/Divider' import {InlineLinkText} from '#/components/Link' @@ -140,23 +141,24 @@ function ModerationDetailsDialogInner({ {modcause?.type === 'label' && ( - - {modcause.source.type === 'user' ? ( + {modcause.source.type === 'user' ? ( + This label was applied by the author. - ) : ( - - This label was applied by{' '} - control.close()} - style={a.text_md}> - {desc.source || _(msg`an unknown labeler`)} - - . - - )} - + + ) : ( + <> + + This label was applied by + + control.close()} + style={a.text_md}> + {desc.source || _(msg`an unknown labeler`)} + + + )} )} diff --git a/src/view/com/composer/Composer.tsx b/src/view/com/composer/Composer.tsx index f354f0f0dc..eb15a78a4b 100644 --- a/src/view/com/composer/Composer.tsx +++ b/src/view/com/composer/Composer.tsx @@ -861,6 +861,7 @@ export const ComposePost = ({ onConfirm={onClose} confirmButtonCta={_(msg`Discard`)} confirmButtonColor="negative" + withoutPortal={true} /> ) diff --git a/yarn.lock b/yarn.lock index d20d4a4cdc..e9f02f5ec4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4120,10 +4120,10 @@ resolved "https://registry.yarnpkg.com/@graphql-typed-document-node/core/-/core-3.2.0.tgz#5f3d96ec6b2354ad6d8a28bf216a1d97b5426861" integrity sha512-mB9oAsNCm9aM3/SOv4YtBMqZbYj10R7dkq8byBqxGY/ncFwhf2oQzMV+LCRlWoDSEBJ3COiR1yeDvMtsoOsuFQ== -"@haileyok/bluesky-bottom-sheet@^0.1.1-alpha.8": - version "0.1.1-alpha.8" - resolved "https://registry.yarnpkg.com/@haileyok/bluesky-bottom-sheet/-/bluesky-bottom-sheet-0.1.1-alpha.8.tgz#c5fd503cdd5556a686a1f5c0974b1527fceda900" - integrity sha512-305MSNscniLZpxd80QO4OCuMXkm+U/v/YW/x0fVQtBilVTikOOPIkiYge+kCUdryFPD3LU/GdrsQZL+y8qAiMQ== +"@haileyok/bluesky-bottom-sheet@^0.1.1-alpha.9": + version "0.1.1-alpha.9" + resolved "https://registry.yarnpkg.com/@haileyok/bluesky-bottom-sheet/-/bluesky-bottom-sheet-0.1.1-alpha.9.tgz#f23a9245d4fed5e1825222249f2ad64ec99896e6" + integrity sha512-duGQ/l20Mr/lmjS7lUu0T0QgARA/V47PrmpL7LZJMoK4IhSBHT4HMSjjOaBcSJhQg2I5/uSX3pShFzCfdGttVQ== "@haileyok/bluesky-video@0.1.10": version "0.1.10" From 4466f68b812aab39cc6f16cf783c25b9de44f04d Mon Sep 17 00:00:00 2001 From: Hailey Date: Wed, 2 Oct 2024 21:38:34 -0700 Subject: [PATCH 09/62] [Sheets] [Pt. 10] (#5581) Co-authored-by: Eric Bailey Co-authored-by: Samuel Newman --- .prettierignore | 3 + bskyweb/cmd/bskyweb/server.go | 1 + package.json | 2 +- src/Navigation.tsx | 2 +- src/alf/atoms.ts | 28 +++ src/alf/fonts.ts | 14 ++ src/components/BottomSheetButton.tsx | 12 -- src/components/Button.tsx | 14 +- src/components/Menu/index.tsx | 14 +- src/components/ReportDialog/SubmitView.tsx | 4 +- src/components/dialogs/MutedWords.tsx | 22 ++- .../dialogs/PostInteractionSettingsDialog.tsx | 4 +- src/components/dms/MessagesNUX.tsx | 174 ------------------ src/components/forms/Toggle.tsx | 10 +- .../intents/VerifyEmailIntentDialog.tsx | 84 ++++----- .../Messages/{List/index.tsx => ChatList.tsx} | 6 +- .../index.tsx => Conversation.tsx} | 14 +- .../ChatDisabled.tsx | 0 .../{List => components}/ChatListItem.tsx | 0 .../MessageInput.tsx | 2 +- .../MessageInput.web.tsx | 4 +- .../MessageInputEmbed.tsx | 0 .../MessageListError.tsx | 0 .../MessagesList.tsx | 14 +- .../StepProfile/PlaceholderCanvas.tsx | 48 ++--- src/view/com/auth/server-input/index.tsx | 9 +- .../post-thread/PostThreadComposePrompt.tsx | 24 ++- src/view/com/util/post-ctrls/RepostButton.tsx | 1 - yarn.lock | 8 +- 29 files changed, 201 insertions(+), 317 deletions(-) delete mode 100644 src/components/BottomSheetButton.tsx delete mode 100644 src/components/dms/MessagesNUX.tsx rename src/screens/Messages/{List/index.tsx => ChatList.tsx} (98%) rename src/screens/Messages/{Conversation/index.tsx => Conversation.tsx} (93%) rename src/screens/Messages/{Conversation => components}/ChatDisabled.tsx (100%) rename src/screens/Messages/{List => components}/ChatListItem.tsx (100%) rename src/screens/Messages/{Conversation => components}/MessageInput.tsx (99%) rename src/screens/Messages/{Conversation => components}/MessageInput.web.tsx (98%) rename src/screens/Messages/{Conversation => components}/MessageInputEmbed.tsx (100%) rename src/screens/Messages/{Conversation => components}/MessageListError.tsx (100%) rename src/screens/Messages/{Conversation => components}/MessagesList.tsx (97%) diff --git a/.prettierignore b/.prettierignore index 8ccbae2148..e107e129a4 100644 --- a/.prettierignore +++ b/.prettierignore @@ -15,3 +15,6 @@ android ios src/locale/locales lib/react-compiler-runtime +bskyweb/static +coverage +web-build diff --git a/bskyweb/cmd/bskyweb/server.go b/bskyweb/cmd/bskyweb/server.go index 0f49ce5c3a..54c5f075ac 100644 --- a/bskyweb/cmd/bskyweb/server.go +++ b/bskyweb/cmd/bskyweb/server.go @@ -255,6 +255,7 @@ func serve(cctx *cli.Context) error { e.GET("/support/community-guidelines", server.WebGeneric) e.GET("/support/copyright", server.WebGeneric) e.GET("/intent/compose", server.WebGeneric) + e.GET("/intent/verify-email", server.WebGeneric) e.GET("/messages", server.WebGeneric) e.GET("/messages/:conversation", server.WebGeneric) diff --git a/package.json b/package.json index 273d8ddb35..e40634685f 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "@fortawesome/free-regular-svg-icons": "^6.1.1", "@fortawesome/free-solid-svg-icons": "^6.1.1", "@fortawesome/react-native-fontawesome": "^0.3.2", - "@haileyok/bluesky-bottom-sheet": "^0.1.1-alpha.9", + "@haileyok/bluesky-bottom-sheet": "^0.1.1-alpha.11", "@haileyok/bluesky-video": "0.1.10", "@lingui/react": "^4.5.0", "@mattermost/react-native-paste-input": "^0.7.1", diff --git a/src/Navigation.tsx b/src/Navigation.tsx index 53e8274d54..323f668b79 100644 --- a/src/Navigation.tsx +++ b/src/Navigation.tsx @@ -78,8 +78,8 @@ import {BottomBar} from '#/view/shell/bottom-bar/BottomBar' import {createNativeStackNavigatorWithAuth} from '#/view/shell/createNativeStackNavigatorWithAuth' import {SharedPreferencesTesterScreen} from '#/screens/E2E/SharedPreferencesTesterScreen' import HashtagScreen from '#/screens/Hashtag' +import {MessagesScreen} from '#/screens/Messages/ChatList' import {MessagesConversationScreen} from '#/screens/Messages/Conversation' -import {MessagesScreen} from '#/screens/Messages/List' import {MessagesSettingsScreen} from '#/screens/Messages/Settings' import {ModerationScreen} from '#/screens/Moderation' import {PostLikedByScreen} from '#/screens/Post/PostLikedBy' diff --git a/src/alf/atoms.ts b/src/alf/atoms.ts index 0c8eb330d7..2625beda27 100644 --- a/src/alf/atoms.ts +++ b/src/alf/atoms.ts @@ -901,4 +901,32 @@ export const atoms = { hidden: { display: 'none', }, + + /* + * Transition + */ + transition_none: web({ + transitionProperty: 'none', + }), + transition_all: web({ + transitionProperty: 'all', + transitionTimingFunction: 'cubic-bezier(0.17, 0.73, 0.14, 1)', + transitionDuration: '100ms', + }), + transition_color: web({ + transitionProperty: + 'color, background-color, border-color, text-decoration-color, fill, stroke', + transitionTimingFunction: 'cubic-bezier(0.17, 0.73, 0.14, 1)', + transitionDuration: '100ms', + }), + transition_opacity: web({ + transitionProperty: 'opacity', + transitionTimingFunction: 'cubic-bezier(0.17, 0.73, 0.14, 1)', + transitionDuration: '100ms', + }), + transition_transform: web({ + transitionProperty: 'transform', + transitionTimingFunction: 'cubic-bezier(0.17, 0.73, 0.14, 1)', + transitionDuration: '100ms', + }), } as const diff --git a/src/alf/fonts.ts b/src/alf/fonts.ts index ae2aaa97a0..54fe7a34e0 100644 --- a/src/alf/fonts.ts +++ b/src/alf/fonts.ts @@ -1,3 +1,5 @@ +import {useFonts} from 'expo-font' + import {isWeb} from '#/platform/detection' import {Device, device} from '#/storage' @@ -63,3 +65,15 @@ export function applyFonts( */ style.fontVariant = ['no-contextual'] } + +/* + * IMPORTANT: This is unused. Expo statically extracts these fonts. + * + * All used fonts MUST be configured here. Unused fonts can be commented out. + */ +export function DO_NOT_USE() { + return useFonts({ + InterVariable: require('../../assets/fonts/inter/InterVariable.ttf'), + 'InterVariable-Italic': require('../../assets/fonts/inter/InterVariable-Italic.ttf'), + }) +} diff --git a/src/components/BottomSheetButton.tsx b/src/components/BottomSheetButton.tsx deleted file mode 100644 index 9eaee55deb..0000000000 --- a/src/components/BottomSheetButton.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import React from 'react' - -import {Button, ButtonProps} from '#/components/Button' -import {NormalizedRNGHPressable} from '#/components/NormalizedRNGHPressable' - -export function BottomSheetButton({children, ...rest}: ButtonProps) { - return ( - - ) -} diff --git a/src/components/Button.tsx b/src/components/Button.tsx index 98ad1709c4..0c7c1ac46d 100644 --- a/src/components/Button.tsx +++ b/src/components/Button.tsx @@ -89,7 +89,7 @@ export type ButtonProps = Pick< style?: StyleProp hoverStyle?: StyleProp children: NonTextElements | ((context: ButtonContext) => NonTextElements) - Component?: React.ComponentType + PressableComponent?: React.ComponentType } export type ButtonTextProps = TextProps & VariantProps & {disabled?: boolean} @@ -117,7 +117,7 @@ export const Button = React.forwardRef( disabled = false, style, hoverStyle: hoverStyleProp, - Component, + PressableComponent, ...rest }, ref, @@ -125,11 +125,11 @@ export const Button = React.forwardRef( // This will pick the correct default pressable to use. If we are inside a dialog, we need to use the RNGH // pressable so that it is usable inside the dialog. const {insideDialog} = useDialogContext() - if (!Component) { + if (!PressableComponent) { if (insideDialog) { - Component = NormalizedRNGHPressable + PressableComponent = NormalizedRNGHPressable } else { - Component = Pressable + PressableComponent = Pressable } } @@ -464,7 +464,7 @@ export const Button = React.forwardRef( const flattenedBaseStyles = flatten([baseStyles, style]) return ( - ( {typeof children === 'function' ? children(context) : children} - + ) }, ) diff --git a/src/components/Menu/index.tsx b/src/components/Menu/index.tsx index 809df96908..bfdcf4099d 100644 --- a/src/components/Menu/index.tsx +++ b/src/components/Menu/index.tsx @@ -105,11 +105,7 @@ export function Outer({ export function Item({children, label, style, onPress, ...rest}: ItemProps) { const t = useTheme() const {control} = React.useContext(Context) - const { - state: focused, - onIn: onHoverIn, - onOut: onHoverOut, - } = useInteractionState() + const {state: focused, onIn: onFocus, onOut: onBlur} = useInteractionState() const { state: pressed, onIn: onPressIn, @@ -121,9 +117,15 @@ export function Item({children, label, style, onPress, ...rest}: ItemProps) { {...rest} accessibilityHint="" accessibilityLabel={label} + onFocus={onFocus} + onBlur={onBlur} onPress={e => { control?.close() onPress(e) + + if (!e.defaultPrevented) { + control?.close() + } }} onPressIn={e => { onPressIn() @@ -133,8 +135,6 @@ export function Item({children, label, style, onPress, ...rest}: ItemProps) { onPressOut() rest.onPressOut?.(e) }} - onHoverIn={onHoverIn} - onHoverOut={onHoverOut} style={[ a.flex_row, a.align_center, diff --git a/src/components/ReportDialog/SubmitView.tsx b/src/components/ReportDialog/SubmitView.tsx index e323d15042..682e918c2d 100644 --- a/src/components/ReportDialog/SubmitView.tsx +++ b/src/components/ReportDialog/SubmitView.tsx @@ -16,6 +16,7 @@ import * as Toggle from '#/components/forms/Toggle' import {Check_Stroke2_Corner0_Rounded as Check} from '#/components/icons/Check' import {ChevronLeft_Stroke2_Corner0_Rounded as ChevronLeft} from '#/components/icons/Chevron' import {Loader} from '#/components/Loader' +import {NormalizedRNGHPressable} from '#/components/NormalizedRNGHPressable' import {Text} from '#/components/Typography' import {ReportDialogProps} from './types' @@ -153,7 +154,8 @@ export function SubmitView({ + label={title} + PressableComponent={NormalizedRNGHPressable}> ) diff --git a/src/components/dialogs/MutedWords.tsx b/src/components/dialogs/MutedWords.tsx index daa18f94e7..55fd98d711 100644 --- a/src/components/dialogs/MutedWords.tsx +++ b/src/components/dialogs/MutedWords.tsx @@ -30,6 +30,7 @@ import {PageText_Stroke2_Corner0_Rounded as PageText} from '#/components/icons/P import {PlusLarge_Stroke2_Corner0_Rounded as Plus} from '#/components/icons/Plus' import {TimesLarge_Stroke2_Corner0_Rounded as X} from '#/components/icons/Times' import {Loader} from '#/components/Loader' +import {NormalizedRNGHPressable} from '#/components/NormalizedRNGHPressable' import * as Prompt from '#/components/Prompt' import {Text} from '#/components/Typography' @@ -168,7 +169,8 @@ function MutedWordsInner() { + style={[a.flex_1]} + PressableComponent={NormalizedRNGHPressable}> @@ -183,7 +185,8 @@ function MutedWordsInner() { + style={[a.flex_1]} + PressableComponent={NormalizedRNGHPressable}> @@ -207,7 +210,8 @@ function MutedWordsInner() { + style={[a.flex_1]} + PressableComponent={NormalizedRNGHPressable}> @@ -222,7 +226,8 @@ function MutedWordsInner() { + style={[a.flex_1]} + PressableComponent={NormalizedRNGHPressable}> @@ -256,7 +261,8 @@ function MutedWordsInner() { + style={[a.flex_1]} + PressableComponent={NormalizedRNGHPressable}> @@ -272,7 +278,8 @@ function MutedWordsInner() { + style={[a.flex_1]} + PressableComponent={NormalizedRNGHPressable}> @@ -302,7 +309,8 @@ function MutedWordsInner() { name="exclude_following" style={[a.flex_row, a.justify_between]} value={excludeFollowing} - onChange={setExcludeFollowing}> + onChange={setExcludeFollowing} + PressableComponent={NormalizedRNGHPressable}> diff --git a/src/components/dialogs/PostInteractionSettingsDialog.tsx b/src/components/dialogs/PostInteractionSettingsDialog.tsx index 93be838542..cc8b4fc9bf 100644 --- a/src/components/dialogs/PostInteractionSettingsDialog.tsx +++ b/src/components/dialogs/PostInteractionSettingsDialog.tsx @@ -37,6 +37,7 @@ import * as Toggle from '#/components/forms/Toggle' import {Check_Stroke2_Corner0_Rounded as Check} from '#/components/icons/Check' import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfo} from '#/components/icons/CircleInfo' import {Loader} from '#/components/Loader' +import {NormalizedRNGHPressable} from '#/components/NormalizedRNGHPressable' import {Text} from '#/components/Typography' export type PostInteractionSettingsFormProps = { @@ -303,7 +304,8 @@ export function PostInteractionSettingsForm({ } value={quotesEnabled} onChange={onChangeQuotesEnabled} - style={[, a.justify_between, a.pt_xs]}> + style={[, a.justify_between, a.pt_xs]} + PressableComponent={NormalizedRNGHPressable}> {quotesEnabled ? ( Quote posts enabled diff --git a/src/components/dms/MessagesNUX.tsx b/src/components/dms/MessagesNUX.tsx deleted file mode 100644 index 723696a04d..0000000000 --- a/src/components/dms/MessagesNUX.tsx +++ /dev/null @@ -1,174 +0,0 @@ -import React, {useCallback, useEffect} from 'react' -import {View} from 'react-native' -import {ChatBskyActorDeclaration} from '@atproto/api' -import {msg, Trans} from '@lingui/macro' -import {useLingui} from '@lingui/react' - -import {useUpdateActorDeclaration} from '#/state/queries/messages/actor-declaration' -import {useProfileQuery} from '#/state/queries/profile' -import {useSession} from '#/state/session' -import * as Toast from '#/view/com/util/Toast' -import {atoms as a, useTheme, web} from '#/alf' -import {Button, ButtonText} from '#/components/Button' -import * as Dialog from '#/components/Dialog' -import * as Toggle from '#/components/forms/Toggle' -import {Message_Stroke2_Corner0_Rounded} from '#/components/icons/Message' -import {Text} from '#/components/Typography' - -export function MessagesNUX() { - const control = Dialog.useDialogControl() - - const {currentAccount} = useSession() - const {data: profile} = useProfileQuery({ - did: currentAccount!.did, - }) - - useEffect(() => { - if (profile && typeof profile.associated?.chat === 'undefined') { - const timeout = setTimeout(() => { - control.open() - }, 1000) - - return () => { - clearTimeout(timeout) - } - } - }, [profile, control]) - - if (!profile) return null - - return ( - - - - ) -} - -function DialogInner({ - chatDeclation, -}: { - chatDeclation?: ChatBskyActorDeclaration.Record -}) { - const control = Dialog.useDialogContext() - const {_} = useLingui() - const t = useTheme() - - const [initialized, setInitialzed] = React.useState(false) - const {mutate: updateDeclaration} = useUpdateActorDeclaration({ - onError: () => { - Toast.show(_(msg`Failed to update settings`), 'xmark') - }, - }) - - const onSelectItem = useCallback( - (keys: string[]) => { - const key = keys[0] - if (!key) return - updateDeclaration(key as 'all' | 'none' | 'following') - }, - [updateDeclaration], - ) - - useEffect(() => { - if (!chatDeclation && !initialized) { - updateDeclaration('following') - setInitialzed(true) - } - }, [chatDeclation, updateDeclaration, initialized]) - - return ( - - - - - - Direct messages are here! - - - Privately chat with other users. - - - - - - Who can message you? - - - You can change this at any time. - - - - - - - - Everyone - - - - - - Users I follow - - - - - - No one - - - - - - - - - - - - ) -} diff --git a/src/components/forms/Toggle.tsx b/src/components/forms/Toggle.tsx index 6dc387b239..bb5f154df0 100644 --- a/src/components/forms/Toggle.tsx +++ b/src/components/forms/Toggle.tsx @@ -1,9 +1,9 @@ import React from 'react' -import {Pressable, View, ViewStyle} from 'react-native' +import {Pressable, PressableProps, View, ViewStyle} from 'react-native' import Animated, {LinearTransition} from 'react-native-reanimated' +import {HITSLOP_10} from '#/lib/constants' import {isNative} from '#/platform/detection' -import {HITSLOP_10} from 'lib/constants' import { atoms as a, flatten, @@ -68,6 +68,7 @@ export type ItemProps = ViewStyleProp & { onChange?: (selected: boolean) => void isInvalid?: boolean children: ((props: ItemState) => React.ReactNode) | React.ReactNode + PressableComponent?: React.ComponentType } export function useItemContext() { @@ -159,6 +160,7 @@ export function Item({ style, type = 'checkbox', label, + PressableComponent = Pressable, ...rest }: ItemProps) { const { @@ -206,7 +208,7 @@ export function Item({ return ( - {typeof children === 'function' ? children(state) : children} - + ) } diff --git a/src/components/intents/VerifyEmailIntentDialog.tsx b/src/components/intents/VerifyEmailIntentDialog.tsx index 9f3808020a..070ba7c40e 100644 --- a/src/components/intents/VerifyEmailIntentDialog.tsx +++ b/src/components/intents/VerifyEmailIntentDialog.tsx @@ -3,11 +3,14 @@ import {View} from 'react-native' import {msg, Trans} from '@lingui/macro' import {useLingui} from '@lingui/react' +import {isNative} from '#/platform/detection' import {useAgent, useSession} from '#/state/session' -import {atoms as a} from '#/alf' -import {Button, ButtonText} from '#/components/Button' +import {atoms as a, useBreakpoints, useTheme} from '#/alf' +import {Button, ButtonIcon, ButtonText} from '#/components/Button' import * as Dialog from '#/components/Dialog' import {DialogControlProps} from '#/components/Dialog' +import {Divider} from '#/components/Divider' +import {ArrowRotateCounterClockwise_Stroke2_Corner0_Rounded as Resend} from '#/components/icons/ArrowRotateCounterClockwise' import {useIntentDialogs} from '#/components/intents/IntentDialogs' import {Loader} from '#/components/Loader' import {Text} from '#/components/Typography' @@ -22,7 +25,9 @@ export function VerifyEmailIntentDialog() { ) } -function Inner({control}: {control: DialogControlProps}) { +function Inner({}: {control: DialogControlProps}) { + const t = useTheme() + const {gtMobile} = useBreakpoints() const {_} = useLingui() const {verifyEmailState: state} = useIntentDialogs() const [status, setStatus] = React.useState< @@ -57,43 +62,47 @@ function Inner({control}: {control: DialogControlProps}) { } return ( - - + {status === 'loading' ? ( - + ) : status === 'success' ? ( - <> - + + Email Verified - + - Thanks, you have successfully verified your email address. + Thanks, you have successfully verified your email address. You + can close this dialog. - + ) : status === 'failure' ? ( - <> - + + Invalid Verification Code - + The verification code you have provided is invalid. Please make sure that you have used the correct verification link or request a new one. - + ) : ( - <> - + + Email Resent - + We have sent another verification email to{' '} @@ -102,38 +111,29 @@ function Inner({control}: {control: DialogControlProps}) { . - + )} - {status !== 'loading' ? ( - + + {status === 'failure' && ( + <> + - {status === 'failure' ? ( - - ) : null} - - ) : null} + + )} + + ) } diff --git a/src/screens/Messages/List/index.tsx b/src/screens/Messages/ChatList.tsx similarity index 98% rename from src/screens/Messages/List/index.tsx rename to src/screens/Messages/ChatList.tsx index efd717f0b4..9912456e13 100644 --- a/src/screens/Messages/List/index.tsx +++ b/src/screens/Messages/ChatList.tsx @@ -22,7 +22,6 @@ import {atoms as a, useBreakpoints, useTheme, web} from '#/alf' import {Button, ButtonIcon, ButtonText} from '#/components/Button' import {DialogControlProps, useDialogControl} from '#/components/Dialog' import {NewChat} from '#/components/dms/dialogs/NewChatDialog' -import {MessagesNUX} from '#/components/dms/MessagesNUX' import {useRefreshOnFocus} from '#/components/hooks/useRefreshOnFocus' import {ArrowRotateCounterClockwise_Stroke2_Corner0_Rounded as Retry} from '#/components/icons/ArrowRotateCounterClockwise' import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfo} from '#/components/icons/CircleInfo' @@ -33,7 +32,7 @@ import {Link} from '#/components/Link' import {ListFooter} from '#/components/Lists' import {Loader} from '#/components/Loader' import {Text} from '#/components/Typography' -import {ChatListItem} from './ChatListItem' +import {ChatListItem} from './components/ChatListItem' type Props = NativeStackScreenProps @@ -151,8 +150,6 @@ export function MessagesScreen({navigation, route}: Props) { if (conversations.length < 1) { return ( - - {gtMobile ? ( - {!gtMobile && ( ( return ( - - - - - + + + + + + + ) }, diff --git a/src/view/com/auth/server-input/index.tsx b/src/view/com/auth/server-input/index.tsx index de7ed6d15b..659ff7f733 100644 --- a/src/view/com/auth/server-input/index.tsx +++ b/src/view/com/auth/server-input/index.tsx @@ -12,6 +12,7 @@ import * as TextField from '#/components/forms/TextField' import * as ToggleButton from '#/components/forms/ToggleButton' import {Globe_Stroke2_Corner0_Rounded as Globe} from '#/components/icons/Globe' import {InlineLinkText} from '#/components/Link' +import {NormalizedRNGHPressable} from '#/components/NormalizedRNGHPressable' import {P, Text} from '#/components/Typography' export function ServerInputDialog({ @@ -82,7 +83,10 @@ export function ServerInputDialog({ label="Preferences" values={fixedOption} onChange={setFixedOption}> - + {_(msg`Bluesky`)} @@ -90,7 +94,8 @@ export function ServerInputDialog({ + label={_(msg`Custom`)} + PressableComponent={NormalizedRNGHPressable}> {_(msg`Custom`)} diff --git a/src/view/com/post-thread/PostThreadComposePrompt.tsx b/src/view/com/post-thread/PostThreadComposePrompt.tsx index 67981618e1..5ad4c256dd 100644 --- a/src/view/com/post-thread/PostThreadComposePrompt.tsx +++ b/src/view/com/post-thread/PostThreadComposePrompt.tsx @@ -5,12 +5,12 @@ import {useLingui} from '@lingui/react' import {PressableScale} from '#/lib/custom-animations/PressableScale' import {useHaptics} from '#/lib/haptics' -import {useWebMediaQueries} from '#/lib/hooks/useWebMediaQueries' import {useHapticsDisabled} from '#/state/preferences' import {useProfileQuery} from '#/state/queries/profile' import {useSession} from '#/state/session' import {UserAvatar} from '#/view/com/util/UserAvatar' -import {atoms as a, useTheme} from '#/alf' +import {atoms as a, useBreakpoints, useTheme} from '#/alf' +import {useInteractionState} from '#/components/hooks/useInteractionState' import {Text} from '#/components/Typography' export function PostThreadComposePrompt({ @@ -21,10 +21,15 @@ export function PostThreadComposePrompt({ const {currentAccount} = useSession() const {data: profile} = useProfileQuery({did: currentAccount?.did}) const {_} = useLingui() - const {isTabletOrDesktop} = useWebMediaQueries() + const {gtMobile} = useBreakpoints() const t = useTheme() const playHaptics = useHaptics() const isHapticsDisabled = useHapticsDisabled() + const { + state: hovered, + onIn: onHoverIn, + onOut: onHoverOut, + } = useInteractionState() const onPress = () => { playHaptics('Light') @@ -42,13 +47,15 @@ export function PostThreadComposePrompt({ accessibilityLabel={_(msg`Compose reply`)} accessibilityHint={_(msg`Opens composer`)} style={[ - {paddingTop: 8, paddingBottom: isTabletOrDesktop ? 8 : 11}, - a.px_sm, + gtMobile ? a.py_xs : {paddingTop: 8, paddingBottom: 11}, + gtMobile ? {paddingLeft: 6, paddingRight: 6} : a.px_sm, a.border_t, t.atoms.border_contrast_low, t.atoms.bg, ]} - onPress={onPress}> + onPress={onPress} + onHoverIn={onHoverIn} + onHoverOut={onHoverOut}> diff --git a/src/view/com/util/post-ctrls/RepostButton.tsx b/src/view/com/util/post-ctrls/RepostButton.tsx index 14c869df8d..896e197b65 100644 --- a/src/view/com/util/post-ctrls/RepostButton.tsx +++ b/src/view/com/util/post-ctrls/RepostButton.tsx @@ -156,7 +156,6 @@ let RepostButton = ({