mirror of
https://github.com/movie-web/native-app.git
synced 2025-09-13 12:23:24 +00:00
Fix year NaN, no longer open unreleased
This commit is contained in:
@@ -12,10 +12,5 @@ class CheckIosCertificateModule : Module() {
|
|||||||
// Can be inferred from module's class name, but it's recommended to set it explicitly for clarity.
|
// Can be inferred from module's class name, but it's recommended to set it explicitly for clarity.
|
||||||
// The module will be accessible from `requireNativeModule('CheckIosCertificate')` in JavaScript.
|
// The module will be accessible from `requireNativeModule('CheckIosCertificate')` in JavaScript.
|
||||||
Name("CheckIosCertificate")
|
Name("CheckIosCertificate")
|
||||||
|
|
||||||
// Defines a JavaScript synchronous function that runs the native code on the JavaScript thread.
|
|
||||||
Function("hello") {
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -64,8 +64,6 @@ const DownloadsScreen: React.FC = () => {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log(isDevelopmentProvisioningProfile());
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScreenLayout>
|
<ScreenLayout>
|
||||||
<YStack gap={2} style={{ padding: 10 }}>
|
<YStack gap={2} style={{ padding: 10 }}>
|
||||||
|
@@ -150,6 +150,9 @@ async function fetchSearchResults(query: string): Promise<ItemData[]> {
|
|||||||
id: result.id.toString(),
|
id: result.id.toString(),
|
||||||
title: result.media_type === "tv" ? result.name : result.title,
|
title: result.media_type === "tv" ? result.name : result.title,
|
||||||
posterUrl: getMediaPoster(result.poster_path),
|
posterUrl: getMediaPoster(result.poster_path),
|
||||||
|
release_date: new Date(
|
||||||
|
result.media_type === "tv" ? result.first_air_date : result.release_date,
|
||||||
|
),
|
||||||
year: new Date(
|
year: new Date(
|
||||||
result.media_type === "tv" ? result.first_air_date : result.release_date,
|
result.media_type === "tv" ? result.first_air_date : result.release_date,
|
||||||
).getFullYear(),
|
).getFullYear(),
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import type { NativeSyntheticEvent } from "react-native";
|
import type { NativeSyntheticEvent } from "react-native";
|
||||||
import type { ContextMenuOnPressNativeEvent } from "react-native-context-menu-view";
|
import type { ContextMenuOnPressNativeEvent } from "react-native-context-menu-view";
|
||||||
|
import { useCallback } from "react";
|
||||||
import { Keyboard, TouchableOpacity } from "react-native";
|
import { Keyboard, TouchableOpacity } from "react-native";
|
||||||
import ContextMenu from "react-native-context-menu-view";
|
import ContextMenu from "react-native-context-menu-view";
|
||||||
import { useRouter } from "expo-router";
|
import { useRouter } from "expo-router";
|
||||||
@@ -14,9 +15,31 @@ export interface ItemData {
|
|||||||
title: string;
|
title: string;
|
||||||
type: "movie" | "tv";
|
type: "movie" | "tv";
|
||||||
year: number;
|
year: number;
|
||||||
|
release_date?: Date;
|
||||||
posterUrl: string;
|
posterUrl: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum ContextMenuActions {
|
||||||
|
Bookmark = "Bookmark",
|
||||||
|
RemoveBookmark = "Remove Bookmark",
|
||||||
|
Download = "Download",
|
||||||
|
RemoveWatchHistoryItem = "Remove from Continue Watching",
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkReleased(media: ItemData): boolean {
|
||||||
|
const isReleasedYear = Boolean(
|
||||||
|
media.year && media.year <= new Date().getFullYear(),
|
||||||
|
);
|
||||||
|
const isReleasedDate = Boolean(
|
||||||
|
media.release_date && media.release_date <= new Date(),
|
||||||
|
);
|
||||||
|
|
||||||
|
// If the media has a release date, use that, otherwise use the year
|
||||||
|
const isReleased = media.release_date ? isReleasedDate : isReleasedYear;
|
||||||
|
|
||||||
|
return isReleased;
|
||||||
|
}
|
||||||
|
|
||||||
export default function Item({ data }: { data: ItemData }) {
|
export default function Item({ data }: { data: ItemData }) {
|
||||||
const resetVideo = usePlayerStore((state) => state.resetVideo);
|
const resetVideo = usePlayerStore((state) => state.resetVideo);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
@@ -27,7 +50,17 @@ export default function Item({ data }: { data: ItemData }) {
|
|||||||
|
|
||||||
const { title, type, year, posterUrl } = data;
|
const { title, type, year, posterUrl } = data;
|
||||||
|
|
||||||
|
const isReleased = useCallback(() => checkReleased(data), [data]);
|
||||||
|
|
||||||
const handlePress = () => {
|
const handlePress = () => {
|
||||||
|
if (!isReleased()) {
|
||||||
|
toastController.show("This media is not released yet", {
|
||||||
|
burntOptions: { preset: "error" },
|
||||||
|
native: true,
|
||||||
|
duration: 500,
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
resetVideo();
|
resetVideo();
|
||||||
Keyboard.dismiss();
|
Keyboard.dismiss();
|
||||||
router.push({
|
router.push({
|
||||||
@@ -36,13 +69,6 @@ export default function Item({ data }: { data: ItemData }) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
enum ContextMenuActions {
|
|
||||||
Bookmark = "Bookmark",
|
|
||||||
RemoveBookmark = "Remove Bookmark",
|
|
||||||
Download = "Download",
|
|
||||||
RemoveWatchHistoryItem = "Remove from Continue Watching",
|
|
||||||
}
|
|
||||||
|
|
||||||
const contextMenuActions = [
|
const contextMenuActions = [
|
||||||
{
|
{
|
||||||
title: isBookmarked(data)
|
title: isBookmarked(data)
|
||||||
@@ -112,12 +138,17 @@ export default function Item({ data }: { data: ItemData }) {
|
|||||||
{title}
|
{title}
|
||||||
</Text>
|
</Text>
|
||||||
<View flexDirection="row" alignItems="center" gap={3}>
|
<View flexDirection="row" alignItems="center" gap={3}>
|
||||||
<Text fontSize={12} color="gray">
|
<Text fontSize={12} color="$ash100">
|
||||||
{type === "tv" ? "Show" : "Movie"}
|
{type === "tv" ? "Show" : "Movie"}
|
||||||
</Text>
|
</Text>
|
||||||
<View height={1} width={1} borderRadius={24} backgroundColor="gray" />
|
<View
|
||||||
<Text fontSize={12} color="gray">
|
height={8}
|
||||||
{year}
|
width={8}
|
||||||
|
borderRadius={24}
|
||||||
|
backgroundColor="$ash100"
|
||||||
|
/>
|
||||||
|
<Text fontSize={12} color="$ash100">
|
||||||
|
{isReleased() ? year : "Unreleased"}
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
</View>
|
</View>
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
import { Input, styled } from "tamagui";
|
import { Input, styled } from "tamagui";
|
||||||
|
|
||||||
export const MWInput = styled(Input, {
|
export const MWInput = styled(Input, {
|
||||||
|
fontWeight: "$semibold",
|
||||||
|
|
||||||
variants: {
|
variants: {
|
||||||
type: {
|
type: {
|
||||||
default: {
|
default: {
|
||||||
|
Reference in New Issue
Block a user