From f0271cd395f7eed16cbfe91a20ee77f0403f9028 Mon Sep 17 00:00:00 2001 From: tapframe Date: Tue, 21 Oct 2025 23:14:51 +0530 Subject: [PATCH] orientation fix --- .../home/ContinueWatchingSection.tsx | 14 +++++++-- src/navigation/AppNavigator.tsx | 29 +++++++++++++++---- src/screens/StreamsScreen.tsx | 25 +++++++++------- 3 files changed, 50 insertions(+), 18 deletions(-) diff --git a/src/components/home/ContinueWatchingSection.tsx b/src/components/home/ContinueWatchingSection.tsx index 0a0beaa..436409c 100644 --- a/src/components/home/ContinueWatchingSection.tsx +++ b/src/components/home/ContinueWatchingSection.tsx @@ -109,8 +109,18 @@ const ContinueWatchingSection = React.forwardRef((props, re const longPressTimeoutRef = useRef(null); // Enhanced responsive sizing for tablets and TV screens - const deviceWidth = Dimensions.get('window').width; - const deviceHeight = Dimensions.get('window').height; + const [dimensions, setDimensions] = useState(Dimensions.get('window')); + const deviceWidth = dimensions.width; + const deviceHeight = dimensions.height; + + // Listen for dimension changes (orientation changes) + useEffect(() => { + const subscription = Dimensions.addEventListener('change', ({ window }) => { + setDimensions(window); + }); + + return () => subscription?.remove(); + }, []); // Determine device type based on width const getDeviceType = useCallback(() => { diff --git a/src/navigation/AppNavigator.tsx b/src/navigation/AppNavigator.tsx index 1655700..318d6db 100644 --- a/src/navigation/AppNavigator.tsx +++ b/src/navigation/AppNavigator.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useRef, useMemo } from 'react'; +import React, { useEffect, useRef, useMemo, useState } from 'react'; import { NavigationContainer, DefaultTheme as NavigationDefaultTheme, DarkTheme as NavigationDarkTheme, Theme, NavigationProp } from '@react-navigation/native'; import { createNativeStackNavigator, NativeStackNavigationOptions, NativeStackNavigationProp } from '@react-navigation/native-stack'; import { createBottomTabNavigator, BottomTabNavigationProp } from '@react-navigation/bottom-tabs'; @@ -428,11 +428,21 @@ const TabIcon = React.memo(({ focused, color, iconName, iconLibrary = 'material' // Update the TabScreenWrapper component with fixed layout dimensions const TabScreenWrapper: React.FC<{children: React.ReactNode}> = ({ children }) => { + const [dimensions, setDimensions] = useState(Dimensions.get('window')); + + useEffect(() => { + const subscription = Dimensions.addEventListener('change', ({ window }) => { + setDimensions(window); + }); + + return () => subscription?.remove(); + }, []); + const isTablet = useMemo(() => { - const { width, height } = Dimensions.get('window'); + const { width, height } = dimensions; const smallestDimension = Math.min(width, height); return (Platform.OS === 'ios' ? (Platform as any).isPad === true : smallestDimension >= 768); - }, []); + }, [dimensions]); const insets = useSafeAreaInsets(); // Force consistent status bar settings useEffect(() => { @@ -498,6 +508,15 @@ const MainTabs = () => { const { useSettings: useSettingsHook } = require('../hooks/useSettings'); const { settings: appSettings } = useSettingsHook(); const [hasUpdateBadge, setHasUpdateBadge] = React.useState(false); + const [dimensions, setDimensions] = useState(Dimensions.get('window')); + + useEffect(() => { + const subscription = Dimensions.addEventListener('change', ({ window }) => { + setDimensions(window); + }); + + return () => subscription?.remove(); + }, []); React.useEffect(() => { if (Platform.OS !== 'android') return; let mounted = true; @@ -531,10 +550,10 @@ const MainTabs = () => { }, []); const { isHomeLoading } = useLoading(); const isTablet = useMemo(() => { - const { width, height } = Dimensions.get('window'); + const { width, height } = dimensions; const smallestDimension = Math.min(width, height); return (Platform.OS === 'ios' ? (Platform as any).isPad === true : smallestDimension >= 768); - }, []); + }, [dimensions]); const insets = useSafeAreaInsets(); const isIosTablet = Platform.OS === 'ios' && isTablet; const [hidden, setHidden] = React.useState(HeaderVisibility.isHidden()); diff --git a/src/screens/StreamsScreen.tsx b/src/screens/StreamsScreen.tsx index b76c1a5..e525753 100644 --- a/src/screens/StreamsScreen.tsx +++ b/src/screens/StreamsScreen.tsx @@ -708,10 +708,18 @@ export const StreamsScreen = () => { const nextLoading = { ...prevLoading }; let changed = false; expectedProviders.forEach(providerId => { - const hasStreams = currentStreamsData[providerId] && + const providerExists = currentStreamsData[providerId]; + const hasStreams = providerExists && currentStreamsData[providerId].streams && currentStreamsData[providerId].streams.length > 0; - const value = (loadingStreams || loadingEpisodeStreams) && !hasStreams; + + // Stop loading if: + // 1. Provider exists (completed) and has streams, OR + // 2. Provider exists (completed) but has 0 streams, OR + // 3. Overall loading is false + const shouldStopLoading = providerExists || !(loadingStreams || loadingEpisodeStreams); + const value = !shouldStopLoading; + if (nextLoading[providerId] !== value) { nextLoading[providerId] = value; changed = true; @@ -1489,13 +1497,7 @@ export const StreamsScreen = () => { return false; } - // For addons, show them even if they have no streams (they might be loading) - const isInstalledAddon = installedAddons.some(addon => addon.id === key); - if (isInstalledAddon) { - return true; - } - - // For plugins, only show if they have actual streams + // Only show providers (addons or plugins) if they have actual streams return providerData.streams.length > 0; }); @@ -1938,7 +1940,8 @@ export const StreamsScreen = () => { const streams = metadata?.videos && metadata.videos.length > 1 && selectedEpisode ? episodeStreams : groupedStreams; // Determine extended loading phases - const streamsEmpty = Object.keys(streams).length === 0; + const streamsEmpty = Object.keys(streams).length === 0 || + Object.values(streams).every(provider => !provider.streams || provider.streams.length === 0); const loadElapsed = streamsLoadStart ? Date.now() - streamsLoadStart : 0; const showInitialLoading = streamsEmpty && (streamsLoadStart === null || loadElapsed < 10000); const showStillFetching = streamsEmpty && loadElapsed >= 10000; @@ -2117,7 +2120,7 @@ export const StreamsScreen = () => { type === 'movie' && styles.streamsMainContentMovie ]}> - {Object.keys(streams).length > 0 && ( + {!streamsEmpty && (