Skip to content

Commit

Permalink
feat: v3.1.2 (#106)
Browse files Browse the repository at this point in the history
* fix: header on genre screens

* chore: upgrade version
  • Loading branch information
theo-mesnil authored Aug 7, 2024
1 parent ffdda39 commit 502d873
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 26 deletions.
4 changes: 2 additions & 2 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
"**/*"
Expand Down Expand Up @@ -44,7 +44,7 @@
],
"scheme": "whattowatch",
"slug": "WhatToWatch",
"version": "3.1.1",
"version": "3.1.2",
"splash": {
"image": "src/assets/splash.png",
"resizeMode": "contain",
Expand Down
10 changes: 6 additions & 4 deletions src/app/genre/[id]/movie.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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();
Expand All @@ -39,7 +41,7 @@ export default function Movie() {
};

return (
<GenreLayout>
<GenreLayout scrollYPosition={scrollYPosition}>
<VerticalList
renderItem={renderItem}
id="genre"
Expand Down
12 changes: 7 additions & 5 deletions src/app/genre/[id]/tv.tsx
Original file line number Diff line number Diff line change
@@ -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 { tvPath } from 'routes';

import type { UseGetDiscoverTvApiResponse } from 'api/discover';
Expand All @@ -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 Tv() {
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();
Expand All @@ -39,7 +41,7 @@ export default function Tv() {
};

return (
<GenreLayout>
<GenreLayout scrollYPosition={scrollYPosition}>
<VerticalList
renderItem={renderItem}
id="genre"
Expand All @@ -53,8 +55,8 @@ export default function Tv() {
/>
</ThumbLink>
}
isLoading={isLoading}
getScrollYPosition={getScrollYPosition}
isLoading={isLoading}
results={data?.pages?.map((page) => page.results).flat()}
onEndReached={loadMore}
contentContainerStyle={containerStyle}
Expand Down
22 changes: 7 additions & 15 deletions src/layouts/Genre/index.tsx
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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<Animated.Value>
>;

export type GenreLayoutProps = {
children: React.ReactNode;
scrollYPosition: Animated.Value;
};

export const ScrollYPositionContext =
React.createContext<ScrollYPositionContextType>(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();
Expand All @@ -53,9 +47,7 @@ export default function GenreLayout({ children }: GenreLayoutProps) {
colors={[...genresColor[genreID], theme.colors.behind]}
scrollY={scrollYPosition}
/>
<ScrollYPositionContext.Provider value={getScrollYPosition}>
{children}
</ScrollYPositionContext.Provider>
{children}
</BasicLayout>
);
}

0 comments on commit 502d873

Please sign in to comment.