From 502d87353aaeeddf0381f03e07c2bd8c79a14f91 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Mesnil?= <50322149+theo-mesnil@users.noreply.github.com> Date: Wed, 7 Aug 2024 14:03:47 +0200 Subject: [PATCH] feat: v3.1.2 (#106) * fix: header on genre screens * chore: upgrade version --- app.json | 4 ++-- src/app/genre/[id]/movie.tsx | 10 ++++++---- src/app/genre/[id]/tv.tsx | 12 +++++++----- src/layouts/Genre/index.tsx | 22 +++++++--------------- 4 files changed, 22 insertions(+), 26 deletions(-) diff --git a/app.json b/app.json index 9c0a598..48b87ea 100644 --- a/app.json +++ b/app.json @@ -7,7 +7,7 @@ }, "package": "com.theomesnil.WhatToWatch", "playStoreUrl": "https://play.google.com/store/apps/details?id=com.theomesnil.WhatToWatch", - "versionCode": 8 + "versionCode": 9 }, "assetBundlePatterns": [ "**/*" @@ -44,7 +44,7 @@ ], "scheme": "whattowatch", "slug": "WhatToWatch", - "version": "3.1.1", + "version": "3.1.2", "splash": { "image": "src/assets/splash.png", "resizeMode": "contain", diff --git a/src/app/genre/[id]/movie.tsx b/src/app/genre/[id]/movie.tsx index 8c3b7b8..fb5f7d4 100644 --- a/src/app/genre/[id]/movie.tsx +++ b/src/app/genre/[id]/movie.tsx @@ -1,6 +1,6 @@ import { useLocalSearchParams } from 'expo-router'; import * as React from 'react'; -import type { ListRenderItemInfo } from 'react-native'; +import { Animated, type ListRenderItemInfo } from 'react-native'; import { moviePath } from 'routes'; import type { UseGetDiscoverMovieApiResponse } from 'api/discover'; @@ -10,10 +10,12 @@ import { Thumb } from 'components/Thumb'; import { ThumbLink } from 'components/ThumbLink'; import { VerticalList } from 'components/VerticalList'; import { useSafeHeights } from 'constants/useSafeHeights'; -import GenreLayout, { ScrollYPositionContext } from 'layouts/Genre'; +import GenreLayout from 'layouts/Genre'; export default function Movie() { - const getScrollYPosition = React.useContext(ScrollYPositionContext); + const [scrollYPosition, getScrollYPosition] = React.useState( + new Animated.Value(0) + ); const params = useLocalSearchParams<{ id: string }>(); const genreID = Number(params?.id); const { containerStyle } = useSafeHeights(); @@ -39,7 +41,7 @@ export default function Movie() { }; return ( - + (); const genreID = Number(params?.id); const { containerStyle } = useSafeHeights(); @@ -39,7 +41,7 @@ export default function Tv() { }; return ( - + } - isLoading={isLoading} getScrollYPosition={getScrollYPosition} + isLoading={isLoading} results={data?.pages?.map((page) => page.results).flat()} onEndReached={loadMore} contentContainerStyle={containerStyle} diff --git a/src/layouts/Genre/index.tsx b/src/layouts/Genre/index.tsx index 44de566..4a9578b 100644 --- a/src/layouts/Genre/index.tsx +++ b/src/layouts/Genre/index.tsx @@ -1,6 +1,6 @@ import { useLocalSearchParams, useNavigation } from 'expo-router'; import * as React from 'react'; -import { Animated } from 'react-native'; +import type { Animated } from 'react-native'; import { theme } from 'theme'; import { useGetGenreMovieList, useGetGenreTvList } from 'api/genres'; @@ -9,24 +9,18 @@ import { Header } from 'components/Header'; import { BasicLayout } from 'layouts/Basic'; import { genresColor } from 'utils/genres'; -type ScrollYPositionContextType = React.Dispatch< - React.SetStateAction ->; - export type GenreLayoutProps = { children: React.ReactNode; + scrollYPosition: Animated.Value; }; -export const ScrollYPositionContext = - React.createContext(null); - -export default function GenreLayout({ children }: GenreLayoutProps) { +export default function GenreLayout({ + children, + scrollYPosition +}: GenreLayoutProps) { const params = useLocalSearchParams<{ id: string }>(); const genreID = Number(params?.id) as keyof typeof genresColor; const navigation = useNavigation(); - const [scrollYPosition, getScrollYPosition] = React.useState( - new Animated.Value(0) - ); const { data: genreTv } = useGetGenreTvList(); const { data: genreMovie } = useGetGenreMovieList(); @@ -53,9 +47,7 @@ export default function GenreLayout({ children }: GenreLayoutProps) { colors={[...genresColor[genreID], theme.colors.behind]} scrollY={scrollYPosition} /> - - {children} - + {children} ); }