forked from
jollywhoppers.com/witchsky.app
Bluesky app fork with some witchin' additions 馃挮
1import {msg} from '@lingui/core/macro'
2import {useLingui} from '@lingui/react'
3import {Trans} from '@lingui/react/macro'
4import {type NativeStackScreenProps} from '@react-navigation/native-stack'
5
6import {type CommonNavigatorParams} from '#/lib/routes/types'
7import {useAutoplayDisabled, useSetAutoplayDisabled} from '#/state/preferences'
8import {
9 useInAppBrowser,
10 useSetInAppBrowser,
11} from '#/state/preferences/in-app-browser'
12import {
13 useTrendingSettings,
14 useTrendingSettingsApi,
15} from '#/state/preferences/trending'
16import {useTrendingConfig} from '#/state/service-config'
17import * as SettingsList from '#/screens/Settings/components/SettingsList'
18import * as Toggle from '#/components/forms/Toggle'
19import {Bubbles_Stroke2_Corner2_Rounded as BubblesIcon} from '#/components/icons/Bubble'
20import {CircleInfo_Stroke2_Corner0_Rounded as CircleInfo} from '#/components/icons/CircleInfo'
21import {Hashtag_Stroke2_Corner0_Rounded as HashtagIcon} from '#/components/icons/Hashtag'
22import {Home_Stroke2_Corner2_Rounded as HomeIcon} from '#/components/icons/Home'
23import {Macintosh_Stroke2_Corner2_Rounded as MacintoshIcon} from '#/components/icons/Macintosh'
24import {Play_Stroke2_Corner2_Rounded as PlayIcon} from '#/components/icons/Play'
25import {Trending2_Stroke2_Corner2_Rounded as Graph} from '#/components/icons/Trending'
26import {Window_Stroke2_Corner2_Rounded as WindowIcon} from '#/components/icons/Window'
27import * as Layout from '#/components/Layout'
28import {useAnalytics} from '#/analytics'
29import {IS_NATIVE} from '#/env'
30
31type Props = NativeStackScreenProps<
32 CommonNavigatorParams,
33 'ContentAndMediaSettings'
34>
35export function ContentAndMediaSettingsScreen({}: Props) {
36 const {_} = useLingui()
37 const ax = useAnalytics()
38 const autoplayDisabledPref = useAutoplayDisabled()
39 const setAutoplayDisabledPref = useSetAutoplayDisabled()
40 const inAppBrowserPref = useInAppBrowser()
41 const setUseInAppBrowser = useSetInAppBrowser()
42 const {enabled: trendingEnabled} = useTrendingConfig()
43 const {trendingDisabled, trendingVideoDisabled} = useTrendingSettings()
44 const {setTrendingDisabled, setTrendingVideoDisabled} =
45 useTrendingSettingsApi()
46
47 return (
48 <Layout.Screen>
49 <Layout.Header.Outer>
50 <Layout.Header.BackButton />
51 <Layout.Header.Content>
52 <Layout.Header.TitleText>
53 <Trans>Content & Media</Trans>
54 </Layout.Header.TitleText>
55 </Layout.Header.Content>
56 <Layout.Header.Slot />
57 </Layout.Header.Outer>
58 <Layout.Content>
59 <SettingsList.Container>
60 <SettingsList.LinkItem
61 to="/settings/saved-feeds"
62 label={_(msg`Manage saved feeds`)}>
63 <SettingsList.ItemIcon icon={HashtagIcon} />
64 <SettingsList.ItemText>
65 <Trans>Manage saved feeds</Trans>
66 </SettingsList.ItemText>
67 </SettingsList.LinkItem>
68 <SettingsList.LinkItem
69 to="/settings/threads"
70 label={_(msg`Thread preferences`)}>
71 <SettingsList.ItemIcon icon={BubblesIcon} />
72 <SettingsList.ItemText>
73 <Trans>Thread preferences</Trans>
74 </SettingsList.ItemText>
75 </SettingsList.LinkItem>
76 <SettingsList.LinkItem
77 to="/settings/following-feed"
78 label={_(msg`Following feed preferences`)}>
79 <SettingsList.ItemIcon icon={HomeIcon} />
80 <SettingsList.ItemText>
81 <Trans>Following feed preferences</Trans>
82 </SettingsList.ItemText>
83 </SettingsList.LinkItem>
84 <SettingsList.LinkItem
85 to="/settings/external-embeds"
86 label={_(msg`External media`)}>
87 <SettingsList.ItemIcon icon={MacintoshIcon} />
88 <SettingsList.ItemText>
89 <Trans>External media</Trans>
90 </SettingsList.ItemText>
91 </SettingsList.LinkItem>
92 <SettingsList.LinkItem
93 to="/settings/interests"
94 label={_(msg`Your interests`)}>
95 <SettingsList.ItemIcon icon={CircleInfo} />
96 <SettingsList.ItemText>
97 <Trans>Your interests</Trans>
98 </SettingsList.ItemText>
99 </SettingsList.LinkItem>
100 <SettingsList.Divider />
101 {IS_NATIVE && (
102 <Toggle.Item
103 name="use_in_app_browser"
104 label={_(msg`Use in-app browser to open links`)}
105 value={inAppBrowserPref ?? false}
106 onChange={value => setUseInAppBrowser(value)}>
107 <SettingsList.Item>
108 <SettingsList.ItemIcon icon={WindowIcon} />
109 <SettingsList.ItemText>
110 <Trans>Use in-app browser to open links</Trans>
111 </SettingsList.ItemText>
112 <Toggle.Platform />
113 </SettingsList.Item>
114 </Toggle.Item>
115 )}
116 <Toggle.Item
117 name="disable_autoplay"
118 label={_(msg`Autoplay videos and GIFs`)}
119 value={!autoplayDisabledPref}
120 onChange={value => setAutoplayDisabledPref(!value)}>
121 <SettingsList.Item>
122 <SettingsList.ItemIcon icon={PlayIcon} />
123 <SettingsList.ItemText>
124 <Trans>Autoplay videos and GIFs</Trans>
125 </SettingsList.ItemText>
126 <Toggle.Platform />
127 </SettingsList.Item>
128 </Toggle.Item>
129 {trendingEnabled ? (
130 <>
131 <SettingsList.Divider />
132 <Toggle.Item
133 name="show_trending_topics"
134 label={_(msg`Enable trending topics`)}
135 value={!trendingDisabled}
136 onChange={value => {
137 const hide = Boolean(!value)
138 if (hide) {
139 ax.metric('trendingTopics:hide', {context: 'settings'})
140 } else {
141 ax.metric('trendingTopics:show', {context: 'settings'})
142 }
143 setTrendingDisabled(hide)
144 }}>
145 <SettingsList.Item>
146 <SettingsList.ItemIcon icon={Graph} />
147 <SettingsList.ItemText>
148 <Trans>Enable trending topics</Trans>
149 </SettingsList.ItemText>
150 <Toggle.Platform />
151 </SettingsList.Item>
152 </Toggle.Item>
153 <Toggle.Item
154 name="show_trending_videos"
155 label={_(msg`Enable trending videos in your Discover feed`)}
156 value={!trendingVideoDisabled}
157 onChange={value => {
158 const hide = Boolean(!value)
159 if (hide) {
160 ax.metric('trendingVideos:hide', {context: 'settings'})
161 } else {
162 ax.metric('trendingVideos:show', {context: 'settings'})
163 }
164 setTrendingVideoDisabled(hide)
165 }}>
166 <SettingsList.Item>
167 <SettingsList.ItemIcon icon={Graph} />
168 <SettingsList.ItemText>
169 <Trans>Enable trending videos in your Discover feed</Trans>
170 </SettingsList.ItemText>
171 <Toggle.Platform />
172 </SettingsList.Item>
173 </Toggle.Item>
174 </>
175 ) : null}
176 </SettingsList.Container>
177 </Layout.Content>
178 </Layout.Screen>
179 )
180}