diff --git a/app/(auth)/(tabs)/libraries/[libraryId].tsx b/app/(auth)/(tabs)/libraries/[libraryId].tsx index c374eabb..33340ce8 100644 --- a/app/(auth)/(tabs)/libraries/[libraryId].tsx +++ b/app/(auth)/(tabs)/libraries/[libraryId].tsx @@ -27,8 +27,9 @@ import { import { useInfiniteQuery, useQuery } from "@tanstack/react-query"; import { Stack, useLocalSearchParams, useNavigation } from "expo-router"; import { useAtom } from "jotai"; -import React, { useCallback, useEffect, useMemo } from "react"; +import React, { useCallback, useEffect, useMemo, useState } from "react"; import { NativeScrollEvent, ScrollView, View } from "react-native"; +import * as ScreenOrientation from "expo-screen-orientation"; const isCloseToBottom = ({ layoutMeasurement, @@ -56,6 +57,27 @@ const page: React.FC = () => { const [sortBy, setSortBy] = useAtom(sortByAtom); const [sortOrder, setSortOrder] = useAtom(sortOrderAtom); + const [orientation, setOrientation] = useState( + ScreenOrientation.Orientation.PORTRAIT_UP + ); + + useEffect(() => { + const subscription = ScreenOrientation.addOrientationChangeListener( + (event) => { + setOrientation(event.orientationInfo.orientation); + } + ); + + // Set the initial orientation + ScreenOrientation.getOrientationAsync().then((initialOrientation) => { + setOrientation(initialOrientation); + }); + + return () => { + ScreenOrientation.removeOrientationChangeListener(subscription); + }; + }, [ScreenOrientation]); + const { data: library } = useQuery({ queryKey: ["library", libraryId], queryFn: async () => { @@ -311,8 +333,14 @@ const page: React.FC = () => { { {flatData.length % 3 !== 0 && ( )}