From 02dbcc134ef9f9870c4f6eab2da93773b8310d67 Mon Sep 17 00:00:00 2001 From: dan Date: Fri, 10 Jan 2025 00:32:08 +0000 Subject: Fix trending swipe gesture (#7417) --- src/components/interstitials/Trending.tsx | 164 ++++++++++++++++-------------- src/view/shell/TrendingGestureContext.tsx | 7 ++ src/view/shell/index.tsx | 13 ++- 3 files changed, 105 insertions(+), 79 deletions(-) create mode 100644 src/view/shell/TrendingGestureContext.tsx (limited to 'src') diff --git a/src/components/interstitials/Trending.tsx b/src/components/interstitials/Trending.tsx index 9a5feb2b6..3e0308e43 100644 --- a/src/components/interstitials/Trending.tsx +++ b/src/components/interstitials/Trending.tsx @@ -1,6 +1,6 @@ -import React from 'react' -import {View} from 'react-native' -import {ScrollView} from 'react-native-gesture-handler' +import React, {useContext} from 'react' +import {ScrollView, View} from 'react-native' +import {GestureDetector} from 'react-native-gesture-handler' import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' @@ -12,6 +12,7 @@ import { import {useTrendingTopics} from '#/state/queries/trending/useTrendingTopics' import {useTrendingConfig} from '#/state/trending-config' import {LoadingPlaceholder} from '#/view/com/util/LoadingPlaceholder' +import {TrendingGestureContext} from '#/view/shell/TrendingGestureContext' import {atoms as a, useGutters, useTheme} from '#/alf' import {Button, ButtonIcon} from '#/components/Button' import {TimesLarge_Stroke2_Corner0_Rounded as X} from '#/components/icons/Times' @@ -40,83 +41,92 @@ export function Inner() { setTrendingDisabled(true) }, [setTrendingDisabled]) + // This is coordinated to take precedence over the drawer pan gesture. + const trendingScrollGesture = useContext(TrendingGestureContext) + return error || noTopics ? null : ( - - - - - - {isLoading ? ( - - - - - - - - {' '} - + + + + + - ) : !trending?.topics ? null : ( - <> - {trending.topics.map(topic => ( - { - logEvent('trendingTopic:click', {context: 'interstitial'}) - }}> - - - {topic.topic} - - - - ))} - - - )} - - + {isLoading ? ( + + + + + + + + {' '} + + + ) : !trending?.topics ? null : ( + <> + {trending.topics.map(topic => ( + { + logEvent('trendingTopic:click', {context: 'interstitial'}) + }}> + + + {topic.topic} + + + + ))} + + + )} + + + Gesture.Native()) return ( <> @@ -101,6 +104,10 @@ function ShellInner() { renderDrawerContent={renderDrawerContent} drawerStyle={{width: Math.min(400, winDim.width * 0.8)}} configureGestureHandler={handler => { + handler = handler.requireExternalGestureToFail( + trendingScrollGesture, + ) + if (swipeEnabled) { if (isDrawerOpen) { return handler.activeOffsetX([-1, 1]) @@ -138,7 +145,9 @@ function ShellInner() { dim: 'rgba(10, 13, 16, 0.8)', }), }}> - + + + -- cgit 1.4.1