From 2dc6932f298ce00bc83a66b7db0539eb7798e030 Mon Sep 17 00:00:00 2001 From: Paul Frazee Date: Tue, 31 Dec 2024 09:44:52 -0800 Subject: [PATCH] Rework discover-feed trending interstitial (#7314) * Rework discover-feed trending interstitial to take one row * Fix loading state * Try putting it at the top * Color consistency * Tweak some spacing * Show trending when progress guide is there --- src/components/hooks/useHeaderOffset.ts | 2 +- src/components/interstitials/Trending.tsx | 131 ++++++++++------------ src/view/com/posts/PostFeed.tsx | 27 +++-- 3 files changed, 71 insertions(+), 89 deletions(-) diff --git a/src/components/hooks/useHeaderOffset.ts b/src/components/hooks/useHeaderOffset.ts index c9987df770..2d18fb99bd 100644 --- a/src/components/hooks/useHeaderOffset.ts +++ b/src/components/hooks/useHeaderOffset.ts @@ -12,5 +12,5 @@ export function useHeaderOffset() { const tabBarPad = 10 + 10 + 3 // padding + border const normalLineHeight = 20 // matches tab bar const tabBarText = normalLineHeight * fontScale - return navBarHeight + tabBarPad + tabBarText + return navBarHeight + tabBarPad + tabBarText - 4 // for some reason, this calculation is wrong by 4 pixels, which we adjust } diff --git a/src/components/interstitials/Trending.tsx b/src/components/interstitials/Trending.tsx index 153f08aaab..1da361ef79 100644 --- a/src/components/interstitials/Trending.tsx +++ b/src/components/interstitials/Trending.tsx @@ -1,6 +1,7 @@ import React from 'react' import {View} from 'react-native' -import {msg, Trans} from '@lingui/macro' +import {ScrollView} from 'react-native-gesture-handler' +import {msg} from '@lingui/macro' import {useLingui} from '@lingui/react' import {logEvent} from '#/lib/statsig/statsig' @@ -8,22 +9,14 @@ import { useTrendingSettings, useTrendingSettingsApi, } from '#/state/preferences/trending' -import { - DEFAULT_LIMIT as TRENDING_TOPICS_COUNT, - useTrendingTopics, -} from '#/state/queries/trending/useTrendingTopics' +import {useTrendingTopics} from '#/state/queries/trending/useTrendingTopics' import {useTrendingConfig} from '#/state/trending-config' -import {atoms as a, tokens, useGutters, useTheme} from '#/alf' +import {atoms as a, useGutters, useTheme} from '#/alf' import {Button, ButtonIcon} from '#/components/Button' -import {GradientFill} from '#/components/GradientFill' import {TimesLarge_Stroke2_Corner0_Rounded as X} from '#/components/icons/Times' import {Trending2_Stroke2_Corner2_Rounded as Graph} from '#/components/icons/Trending2' import * as Prompt from '#/components/Prompt' -import { - TrendingTopic, - TrendingTopicLink, - TrendingTopicSkeleton, -} from '#/components/TrendingTopics' +import {TrendingTopicLink} from '#/components/TrendingTopics' import {Text} from '#/components/Typography' export function TrendingInterstitial() { @@ -35,7 +28,7 @@ export function TrendingInterstitial() { export function Inner() { const t = useTheme() const {_} = useLingui() - const gutters = useGutters(['wide', 'base']) + const gutters = useGutters([0, 'base', 0, 'base']) const trendingPrompt = Prompt.usePromptControl() const {setTrendingDisabled} = useTrendingSettingsApi() const {data: trending, error, isLoading} = useTrendingTopics() @@ -47,69 +40,59 @@ export function Inner() { }, [setTrendingDisabled]) return error || noTopics ? null : ( - - - - - - Trending - - - - - BETA - + + + + + - - - - - - - {isLoading ? ( - Array(TRENDING_TOPICS_COUNT) - .fill(0) - .map((_n, i) => ) - ) : !trending?.topics ? null : ( - <> - {trending.topics.map(topic => ( - { - logEvent('trendingTopic:click', {context: 'interstitial'}) - }}> - {({hovered}) => ( - + + {' '} + + + ) : !trending?.topics ? null : ( + <> + {trending.topics.map(topic => ( + <> + - )} - - ))} - - )} - + onPress={() => { + logEvent('trendingTopic:click', {context: 'interstitial'}) + }}> + + + {topic.topic} + + + + + ))} + + + )} + +