From b03a85ad5380ba17198a6d928e6bfaba57ac9877 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Thu, 12 Dec 2024 16:45:45 -0600 Subject: [PATCH] Add new interstitial to Discover --- src/components/GradientFill.tsx | 7 +- src/components/TrendingTopics.tsx | 2 + src/components/interstitials/Trending.tsx | 84 +++++++++++++++++++ .../Settings/ContentAndMediaSettings.tsx | 48 +++++++---- src/view/com/posts/PostFeed.tsx | 18 +++- 5 files changed, 137 insertions(+), 22 deletions(-) create mode 100644 src/components/interstitials/Trending.tsx diff --git a/src/components/GradientFill.tsx b/src/components/GradientFill.tsx index e7d505d6fc..9ad6ed7dc6 100644 --- a/src/components/GradientFill.tsx +++ b/src/components/GradientFill.tsx @@ -1,10 +1,11 @@ import {LinearGradient} from 'expo-linear-gradient' -import {atoms as a, tokens} from '#/alf' +import {atoms as a, tokens, ViewStyleProp} from '#/alf' export function GradientFill({ gradient, -}: { + style, +}: ViewStyleProp & { gradient: | typeof tokens.gradients.primary | typeof tokens.gradients.sky @@ -27,7 +28,7 @@ export function GradientFill({ } start={{x: 0, y: 0}} end={{x: 1, y: 1}} - style={[a.absolute, a.inset_0]} + style={[a.absolute, a.inset_0, style]} /> ) } diff --git a/src/components/TrendingTopics.tsx b/src/components/TrendingTopics.tsx index dbf9259bd5..090415ae61 100644 --- a/src/components/TrendingTopics.tsx +++ b/src/components/TrendingTopics.tsx @@ -16,6 +16,7 @@ export function TopicLarge({topic, style}: {topic: string} & ViewStyleProp) { a.rounded_md, a.border, t.atoms.border_contrast_medium, + t.atoms.bg, style, ]}> + + + + + Trending + + + + BETA + + + + + + + + {Trending.TOPICS.slice(0, 8).map(topic => ( + + {({hovered}) => ( + + )} + + ))} + + + setTrendingDiscoverHidden(true)} + /> + + ) +} diff --git a/src/screens/Settings/ContentAndMediaSettings.tsx b/src/screens/Settings/ContentAndMediaSettings.tsx index 488b0f9f8b..7782a94ff8 100644 --- a/src/screens/Settings/ContentAndMediaSettings.tsx +++ b/src/screens/Settings/ContentAndMediaSettings.tsx @@ -34,8 +34,9 @@ export function ContentAndMediaSettingsScreen({}: Props) { const setAutoplayDisabledPref = useSetAutoplayDisabled() const inAppBrowserPref = useInAppBrowser() const setUseInAppBrowser = useSetInAppBrowser() - const {trendingSidebarHidden} = useTrendingSettings() - const {setTrendingSidebarHidden} = useTrendingSettingsApi() + const {trendingSidebarHidden, trendingDiscoverHidden} = useTrendingSettings() + const {setTrendingSidebarHidden, setTrendingDiscoverHidden} = + useTrendingSettingsApi() return ( @@ -111,24 +112,35 @@ export function ContentAndMediaSettingsScreen({}: Props) { + {!isNative && ( - <> - - setTrendingSidebarHidden(!value)}> - - - - Show trending topics in your sidebar - - - - - + setTrendingSidebarHidden(!value)}> + + + + Show trending topics in your sidebar + + + + )} + setTrendingDiscoverHidden(!value)}> + + + + Show trending topics in your feed + + + + diff --git a/src/view/com/posts/PostFeed.tsx b/src/view/com/posts/PostFeed.tsx index 10eb47d0a4..d88d16955b 100644 --- a/src/view/com/posts/PostFeed.tsx +++ b/src/view/com/posts/PostFeed.tsx @@ -23,6 +23,7 @@ import {logger} from '#/logger' import {isIOS, isWeb} from '#/platform/detection' import {listenPostCreated} from '#/state/events' import {useFeedFeedbackContext} from '#/state/feed-feedback' +import {useTrendingSettings} from '#/state/preferences/trending' import {STALE} from '#/state/queries' import { FeedDescriptor, @@ -35,6 +36,7 @@ import { import {useSession} from '#/state/session' import {useProgressGuide} from '#/state/shell/progress-guide' import {ProgressGuide, SuggestedFollows} from '#/components/FeedInterstitials' +import {TrendingInterstitial} from '#/components/interstitials/Trending' import {List, ListRef} from '../util/List' import {PostFeedLoadingPlaceholder} from '../util/LoadingPlaceholder' import {LoadMoreRetryBtn} from '../util/LoadMoreRetryBtn' @@ -90,6 +92,10 @@ type FeedRow = type: 'interstitialProgressGuide' key: string } + | { + type: 'interstitialTrending' + key: string + } export function getFeedPostSlice(feedRow: FeedRow): FeedPostSlice | null { if (feedRow.type === 'sliceItem') { @@ -259,6 +265,8 @@ let PostFeed = ({ const showProgressIntersitial = (followProgressGuide || followAndLikeProgressGuide) && !isDesktop + const {trendingDiscoverHidden} = useTrendingSettings() + const feedItems: FeedRow[] = React.useMemo(() => { let feedKind: 'following' | 'discover' | 'profile' | undefined if (feedType === 'following') { @@ -304,7 +312,12 @@ let PostFeed = ({ type: 'interstitialProgressGuide', key: 'interstitial-' + sliceIndex + '-' + lastFetchedAt, }) - } else if (sliceIndex === 20) { + } else if (sliceIndex === 15 && !trendingDiscoverHidden) { + arr.push({ + type: 'interstitialTrending', + key: 'interstitial-' + sliceIndex + '-' + lastFetchedAt, + }) + } else if (sliceIndex === 30) { arr.push({ type: 'interstitialFollows', key: 'interstitial-' + sliceIndex + '-' + lastFetchedAt, @@ -390,6 +403,7 @@ let PostFeed = ({ feedTab, hasSession, showProgressIntersitial, + trendingDiscoverHidden, ]) // events @@ -476,6 +490,8 @@ let PostFeed = ({ return } else if (row.type === 'interstitialProgressGuide') { return + } else if (row.type === 'interstitialTrending') { + return } else if (row.type === 'sliceItem') { const slice = row.slice if (slice.isFallbackMarker) {