Skip to content

Commit 43d07e4

Browse files
committed
feat(mobile): discover language settings
1 parent 0fc79c4 commit 43d07e4

File tree

4 files changed

+68
-3
lines changed

4 files changed

+68
-3
lines changed

apps/mobile/src/modules/discover/Category.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,25 @@ import { FilterCuteReIcon } from "@/src/icons/filter_cute_re"
1111
import { Grid2CuteReIcon } from "@/src/icons/grid_2_cute_re"
1212
import { useNavigation } from "@/src/lib/navigation/hooks"
1313
import { Recommendations } from "@/src/modules/discover/Recommendations"
14+
import { DiscoverSettingsScreen } from "@/src/screens/(modal)/DiscoverSettingsScreen"
1415
import { RecommendationCategoryScreen } from "@/src/screens/(stack)/recommendation/RecommendationCategoryScreen"
1516

1617
export const Category = () => {
18+
const navigation = useNavigation()
19+
1720
return (
1821
<>
1922
<View className="mt-4 flex-row items-center justify-between pb-1 pl-6 pr-5 pt-4">
2023
<View className="flex-row items-center gap-2">
2124
<Grid2CuteReIcon width={24} height={24} />
2225
<Text className="text-label text-2xl font-bold leading-[1.1]">Categories</Text>
2326
</View>
24-
<ItemPressable className="rounded-lg p-1">
27+
<ItemPressable
28+
className="rounded-lg p-1"
29+
onPress={() => {
30+
navigation.presentControllerView(DiscoverSettingsScreen)
31+
}}
32+
>
2533
<FilterCuteReIcon width={20} height={20} />
2634
</ItemPressable>
2735
</View>

apps/mobile/src/modules/discover/Trending.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import { ItemPressableStyle } from "@/src/components/ui/pressable/enum"
88
import { ItemPressable } from "@/src/components/ui/pressable/ItemPressable"
99
import { FilterCuteReIcon } from "@/src/icons/filter_cute_re"
1010
import { TrendingUpCuteReIcon } from "@/src/icons/trending_up_cute_re"
11+
import { useNavigation } from "@/src/lib/navigation/hooks"
12+
import { DiscoverSettingsScreen } from "@/src/screens/(modal)/DiscoverSettingsScreen"
1113

1214
import { fetchFeedTrending } from "./api"
1315
import { FeedSummary } from "./FeedSummary"
@@ -21,13 +23,14 @@ export const Trending = ({
2123
}) => {
2224
const discoverLanguage = useUISettingKey("discoverLanguage")
2325
const { data, isLoading } = useQuery({
24-
queryKey: ["trending", "feeds"],
26+
queryKey: ["trending", "feeds", discoverLanguage],
2527
queryFn: () =>
2628
fetchFeedTrending({
2729
lang: discoverLanguage === "all" ? undefined : discoverLanguage,
2830
limit: 20,
2931
}).then((res) => res.data),
3032
})
33+
const navigation = useNavigation()
3134

3235
return (
3336
<View className={className}>
@@ -36,7 +39,13 @@ export const Trending = ({
3639
<TrendingUpCuteReIcon width={24} height={24} />
3740
<Text className="text-label text-2xl font-bold leading-[1.1]">Trending</Text>
3841
</View>
39-
<ItemPressable className="rounded-lg p-1" itemStyle={ItemPressableStyle.UnStyled}>
42+
<ItemPressable
43+
className="rounded-lg p-1"
44+
itemStyle={ItemPressableStyle.UnStyled}
45+
onPress={() => {
46+
navigation.presentControllerView(DiscoverSettingsScreen)
47+
}}
48+
>
4049
<FilterCuteReIcon width={20} height={20} />
4150
</ItemPressable>
4251
</View>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import { useTranslation } from "react-i18next"
2+
import { View } from "react-native"
3+
4+
import { setUISetting, useUISettingKey } from "@/src/atoms/settings/ui"
5+
import {
6+
NavigationBlurEffectHeaderView,
7+
SafeNavigationScrollView,
8+
} from "@/src/components/layouts/views/SafeNavigationScrollView"
9+
import { Select } from "@/src/components/ui/form/Select"
10+
import {
11+
GroupedInsetListCard,
12+
GroupedInsetListCell,
13+
GroupedInsetListSectionHeader,
14+
} from "@/src/components/ui/grouped/GroupedList"
15+
16+
export const DiscoverSettingsScreen = () => {
17+
const { t } = useTranslation("settings")
18+
const discoverLanguage = useUISettingKey("discoverLanguage")
19+
20+
return (
21+
<SafeNavigationScrollView
22+
className="bg-system-grouped-background"
23+
Header={<NavigationBlurEffectHeaderView title={t("discoverFilters.title")} />}
24+
>
25+
<GroupedInsetListSectionHeader label={t("discoverFilters.filters")} marginSize="small" />
26+
<GroupedInsetListCard>
27+
<GroupedInsetListCell label={t("discoverFilters.language")}>
28+
<View className="w-[100px]">
29+
<Select
30+
options={[
31+
{ label: "All", value: "all" },
32+
{ label: "English", value: "eng" },
33+
{ label: "中文", value: "cmn" },
34+
]}
35+
value={discoverLanguage}
36+
onValueChange={(val) => {
37+
setUISetting("discoverLanguage", val as "all" | "eng" | "cmn")
38+
}}
39+
/>
40+
</View>
41+
</GroupedInsetListCell>
42+
</GroupedInsetListCard>
43+
</SafeNavigationScrollView>
44+
)
45+
}

locales/settings/en.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@
140140
"data_control.export_local_database.label": "Export local database",
141141
"data_control.import_opml.label": "Import subscriptions from OPML",
142142
"data_control.utils": "Utils",
143+
"discoverFilters.filters": "Filters",
144+
"discoverFilters.language": "Language",
145+
"discoverFilters.title": "Discover Filters",
143146
"feeds.claimTips": "To claim your feeds and receive tips, right-click on the feed in your subscription list and select Claim.",
144147
"feeds.noFeeds": "No claimed feeds",
145148
"feeds.tableHeaders.name": "Name",

0 commit comments

Comments
 (0)