feat: favorites tab

This commit is contained in:
Fredrik Burmester
2025-01-01 15:46:22 +01:00
parent a994868be4
commit 27609e7789
21 changed files with 204 additions and 10 deletions

View File

@@ -0,0 +1,24 @@
import { nestedTabPageScreenOptions } from "@/components/stacks/NestedTabPageStack";
import { Stack } from "expo-router";
import { Platform } from "react-native";
export default function SearchLayout() {
return (
<Stack>
<Stack.Screen
name="index"
options={{
headerShown: true,
headerLargeTitle: true,
headerTitle: "Favorites",
headerBlurEffect: "prominent",
headerTransparent: Platform.OS === "ios" ? true : false,
headerShadowVisible: false,
}}
/>
{Object.entries(nestedTabPageScreenOptions).map(([name, options]) => (
<Stack.Screen key={name} name={name} options={options} />
))}
</Stack>
);
}

View File

@@ -0,0 +1,34 @@
import { Favorites } from "@/components/home/Favorites";
import { useInvalidatePlaybackProgressCache } from "@/hooks/useRevalidatePlaybackProgressCache";
import React, { useCallback, useState } from "react";
import { RefreshControl, ScrollView, View } from "react-native";
import { useSafeAreaInsets } from "react-native-safe-area-context";
export default function favorites() {
const invalidateCache = useInvalidatePlaybackProgressCache();
const [loading, setLoading] = useState(false);
const refetch = useCallback(async () => {
setLoading(true);
await invalidateCache();
setLoading(false);
}, []);
const insets = useSafeAreaInsets();
return (
<ScrollView
nestedScrollEnabled
contentInsetAdjustmentBehavior="automatic"
refreshControl={
<RefreshControl refreshing={loading} onRefresh={refetch} />
}
contentContainerStyle={{
paddingLeft: insets.left,
paddingRight: insets.right,
paddingBottom: 16,
}}
>
<Favorites />
</ScrollView>
);
}

View File

@@ -318,7 +318,7 @@ export default function search() {
text="Library"
textClass="p-1"
className={
searchType === "Library" ? "bg-neutral-600" : undefined
searchType === "Library" ? "bg-purple-600" : undefined
}
/>
</TouchableOpacity>
@@ -327,7 +327,7 @@ export default function search() {
text="Discover"
textClass="p-1"
className={
searchType === "Discover" ? "bg-neutral-600" : undefined
searchType === "Discover" ? "bg-purple-600" : undefined
}
/>
</TouchableOpacity>

View File

@@ -62,6 +62,17 @@ export default function TabLayout() {
: () => ({ sfSymbol: "magnifyingglass" }),
}}
/>
<NativeTabs.Screen
name="(favorites)"
options={{
title: "Favorites",
tabBarIcon:
Platform.OS == "android"
? ({ color, focused, size }) =>
require("@/assets/icons/heart.png")
: () => ({ sfSymbol: "heart" }),
}}
/>
<NativeTabs.Screen
name="(libraries)"
options={{