2 Commits

8 changed files with 55 additions and 76 deletions

View File

@@ -63,7 +63,7 @@ export default function RootLayout() {
<Stack.Screen name="search" options={{ headerShown: false }} /> <Stack.Screen name="search" options={{ headerShown: false }} />
<Stack.Screen name="live" options={{ headerShown: false }} /> <Stack.Screen name="live" options={{ headerShown: false }} />
<Stack.Screen name="settings" options={{ headerShown: false }} /> <Stack.Screen name="settings" options={{ headerShown: false }} />
{/* <Stack.Screen name="favorites" options={{ headerShown: false }} /> */} <Stack.Screen name="favorites" options={{ headerShown: false }} />
<Stack.Screen name="+not-found" /> <Stack.Screen name="+not-found" />
</Stack> </Stack>
<Toast /> <Toast />

View File

@@ -77,17 +77,23 @@ export default function DetailScreen() {
<View style={styles.topContainer}> <View style={styles.topContainer}>
<Image source={{ uri: detail.poster }} style={styles.poster} /> <Image source={{ uri: detail.poster }} style={styles.poster} />
<View style={styles.infoContainer}> <View style={styles.infoContainer}>
<ThemedText style={styles.title} numberOfLines={1}> <View style={styles.titleContainer}>
{detail.title} <ThemedText style={styles.title} numberOfLines={1} ellipsizeMode="tail">
</ThemedText> {detail.title}
</ThemedText>
<StyledButton onPress={toggleFavorite} variant="ghost" style={styles.favoriteButton}>
<FontAwesome
name={isFavorited ? "heart" : "heart-o"}
size={24}
color={isFavorited ? "#FFD700" : "#ccc"}
/>
</StyledButton>
</View>
<View style={styles.metaContainer}> <View style={styles.metaContainer}>
<ThemedText style={styles.metaText}>{detail.year}</ThemedText> <ThemedText style={styles.metaText}>{detail.year}</ThemedText>
<ThemedText style={styles.metaText}>{detail.type_name}</ThemedText> <ThemedText style={styles.metaText}>{detail.type_name}</ThemedText>
</View> </View>
{/* <Pressable onPress={toggleFavorite} style={styles.favoriteButton}>
<FontAwesome name={isFavorited ? "star" : "star-o"} size={24} color={isFavorited ? "#FFD700" : "#ccc"} />
<ThemedText style={styles.favoriteButtonText}>{isFavorited ? "已收藏" : "收藏"}</ThemedText>
</Pressable> */}
<ScrollView style={styles.descriptionScrollView}> <ScrollView style={styles.descriptionScrollView}>
<ThemedText style={styles.description}>{detail.desc}</ThemedText> <ThemedText style={styles.description}>{detail.desc}</ThemedText>
</ScrollView> </ScrollView>
@@ -167,11 +173,15 @@ const styles = StyleSheet.create({
marginLeft: 20, marginLeft: 20,
justifyContent: "flex-start", justifyContent: "flex-start",
}, },
titleContainer: {
flexDirection: "row",
alignItems: "center",
},
title: { title: {
paddingTop: 16,
fontSize: 28, fontSize: 28,
fontWeight: "bold", fontWeight: "bold",
marginBottom: 10, flexShrink: 1,
paddingTop: 20,
}, },
metaContainer: { metaContainer: {
flexDirection: "row", flexDirection: "row",
@@ -191,13 +201,9 @@ const styles = StyleSheet.create({
lineHeight: 22, lineHeight: 22,
}, },
favoriteButton: { favoriteButton: {
flexDirection: "row",
alignItems: "center",
marginTop: 10,
padding: 10, padding: 10,
backgroundColor: "rgba(255, 255, 255, 0.1)", marginLeft: 10,
borderRadius: 5, backgroundColor: "transparent",
alignSelf: "flex-start",
}, },
favoriteButtonText: { favoriteButtonText: {
marginLeft: 8, marginLeft: 8,

View File

@@ -1,27 +1,19 @@
import React, { useEffect } from "react"; import React, { useEffect } from "react";
import { View, FlatList, StyleSheet, ActivityIndicator, Image, Pressable } from "react-native"; import { View, FlatList, StyleSheet, ActivityIndicator } from "react-native";
import { useRouter } from "expo-router";
import { ThemedView } from "@/components/ThemedView"; import { ThemedView } from "@/components/ThemedView";
import { ThemedText } from "@/components/ThemedText"; import { ThemedText } from "@/components/ThemedText";
import useFavoritesStore from "@/stores/favoritesStore"; import useFavoritesStore from "@/stores/favoritesStore";
import { Favorite } from "@/services/storage"; import { Favorite } from "@/services/storage";
import VideoCard from "@/components/VideoCard.tv";
import { api } from "@/services/api";
export default function FavoritesScreen() { export default function FavoritesScreen() {
const router = useRouter();
const { favorites, loading, error, fetchFavorites } = useFavoritesStore(); const { favorites, loading, error, fetchFavorites } = useFavoritesStore();
useEffect(() => { useEffect(() => {
fetchFavorites(); fetchFavorites();
}, [fetchFavorites]); }, [fetchFavorites]);
const handlePress = (favorite: Favorite & { key: string }) => {
const [source, id] = favorite.key.split("+");
router.push({
pathname: "/detail",
params: { q: favorite.title, source, id },
});
};
if (loading) { if (loading) {
return ( return (
<ThemedView style={styles.centered}> <ThemedView style={styles.centered}>
@@ -46,17 +38,22 @@ export default function FavoritesScreen() {
); );
} }
const renderItem = ({ item }: { item: Favorite & { key: string } }) => ( const renderItem = ({ item }: { item: Favorite & { key: string } }) => {
<Pressable onPress={() => handlePress(item)} style={styles.itemContainer}> const [source, id] = item.key.split("+");
<Image source={{ uri: item.poster }} style={styles.poster} /> return (
<View style={styles.infoContainer}> <VideoCard
<ThemedText style={styles.title} numberOfLines={1}> id={id}
{item.title} source={source}
</ThemedText> title={item.title}
<ThemedText style={styles.year}>{item.year}</ThemedText> sourceName={item.source_name}
</View> poster={item.cover}
</Pressable> year={item.year}
); api={api}
episodeIndex={1}
progress={0}
/>
);
};
return ( return (
<ThemedView style={styles.container}> <ThemedView style={styles.container}>
@@ -67,7 +64,7 @@ export default function FavoritesScreen() {
data={favorites} data={favorites}
renderItem={renderItem} renderItem={renderItem}
keyExtractor={(item) => item.key} keyExtractor={(item) => item.key}
numColumns={3} numColumns={5}
contentContainerStyle={styles.list} contentContainerStyle={styles.list}
/> />
</ThemedView> </ThemedView>
@@ -99,26 +96,4 @@ const styles = StyleSheet.create({
list: { list: {
padding: 10, padding: 10,
}, },
itemContainer: {
flex: 1,
margin: 10,
alignItems: "center",
},
poster: {
width: 120,
height: 180,
borderRadius: 8,
},
infoContainer: {
marginTop: 8,
alignItems: "center",
},
title: {
fontSize: 16,
fontWeight: "bold",
},
year: {
fontSize: 14,
color: "#888",
},
}); });

View File

@@ -124,9 +124,9 @@ export default function HomeScreen() {
</Pressable> </Pressable>
</View> </View>
<View style={styles.rightHeaderButtons}> <View style={styles.rightHeaderButtons}>
{/* <StyledButton style={styles.searchButton} onPress={() => router.push("/favorites")} variant="ghost"> <StyledButton style={styles.searchButton} onPress={() => router.push("/favorites")} variant="ghost">
<Heart color={colorScheme === "dark" ? "white" : "black"} size={24} /> <Heart color={colorScheme === "dark" ? "white" : "black"} size={24} />
</StyledButton> */} </StyledButton>
<StyledButton <StyledButton
style={styles.searchButton} style={styles.searchButton}
onPress={() => router.push({ pathname: "/search" })} onPress={() => router.push({ pathname: "/search" })}

View File

@@ -6,18 +6,17 @@ import { ThemedView } from "@/components/ThemedView";
import { StyledButton } from "@/components/StyledButton"; import { StyledButton } from "@/components/StyledButton";
import { useThemeColor } from "@/hooks/useThemeColor"; import { useThemeColor } from "@/hooks/useThemeColor";
import { useSettingsStore } from "@/stores/settingsStore"; import { useSettingsStore } from "@/stores/settingsStore";
import useAuthStore from "@/stores/authStore"; // import useAuthStore from "@/stores/authStore";
import { useRemoteControlStore } from "@/stores/remoteControlStore"; import { useRemoteControlStore } from "@/stores/remoteControlStore";
import { APIConfigSection } from "@/components/settings/APIConfigSection"; import { APIConfigSection } from "@/components/settings/APIConfigSection";
import { LiveStreamSection } from "@/components/settings/LiveStreamSection"; import { LiveStreamSection } from "@/components/settings/LiveStreamSection";
import { RemoteInputSection } from "@/components/settings/RemoteInputSection"; import { RemoteInputSection } from "@/components/settings/RemoteInputSection";
import { VideoSourceSection } from "@/components/settings/VideoSourceSection"; // import { VideoSourceSection } from "@/components/settings/VideoSourceSection";
import Toast from "react-native-toast-message"; import Toast from "react-native-toast-message";
export default function SettingsScreen() { export default function SettingsScreen() {
const { loadSettings, saveSettings, setApiBaseUrl, setM3uUrl } = useSettingsStore(); const { loadSettings, saveSettings, setApiBaseUrl, setM3uUrl } = useSettingsStore();
const { lastMessage } = useRemoteControlStore(); const { lastMessage } = useRemoteControlStore();
const { isLoggedIn, logout } = useAuthStore();
const backgroundColor = useThemeColor({}, "background"); const backgroundColor = useThemeColor({}, "background");
const [hasChanges, setHasChanges] = useState(false); const [hasChanges, setHasChanges] = useState(false);

View File

@@ -2,7 +2,7 @@
"name": "OrionTV", "name": "OrionTV",
"private": true, "private": true,
"main": "expo-router/entry", "main": "expo-router/entry",
"version": "1.2.3", "version": "1.2.4",
"scripts": { "scripts": {
"start": "EXPO_USE_METRO_WORKSPACE_ROOT=1 expo start", "start": "EXPO_USE_METRO_WORKSPACE_ROOT=1 expo start",
"start-tv": "EXPO_TV=1 EXPO_USE_METRO_WORKSPACE_ROOT=1 expo start", "start-tv": "EXPO_TV=1 EXPO_USE_METRO_WORKSPACE_ROOT=1 expo start",

View File

@@ -43,7 +43,6 @@ export interface SearchResult {
export interface Favorite { export interface Favorite {
cover: string; cover: string;
title: string; title: string;
poster: string;
source_name: string; source_name: string;
total_episodes: number; total_episodes: number;
search_title: string; search_title: string;

View File

@@ -133,11 +133,11 @@ const useDetailStore = create<DetailState>((set, get) => ({
set({ error: "未找到任何播放源" }); set({ error: "未找到任何播放源" });
} }
// if (get().detail) { if (get().detail) {
// const { source, id } = get().detail!; const { source, id } = get().detail!;
// const isFavorited = await FavoriteManager.isFavorited(source, id.toString()); const isFavorited = await FavoriteManager.isFavorited(source, id.toString());
// set({ isFavorited }); set({ isFavorited });
// } }
} catch (e) { } catch (e) {
if ((e as Error).name !== "AbortError") { if ((e as Error).name !== "AbortError") {
set({ error: e instanceof Error ? e.message : "获取数据失败" }); set({ error: e instanceof Error ? e.message : "获取数据失败" });
@@ -151,9 +151,9 @@ const useDetailStore = create<DetailState>((set, get) => ({
setDetail: async (detail) => { setDetail: async (detail) => {
set({ detail }); set({ detail });
// const { source, id } = detail; const { source, id } = detail;
// const isFavorited = await FavoriteManager.isFavorited(source, id.toString()); const isFavorited = await FavoriteManager.isFavorited(source, id.toString());
// set({ isFavorited }); set({ isFavorited });
}, },
abort: () => { abort: () => {