From ece40534ac3b62661a7d22e72abd8b3d17c33350 Mon Sep 17 00:00:00 2001 From: Fredrik Burmester Date: Fri, 7 Nov 2025 08:46:10 +0100 Subject: [PATCH] Fix carousel behavior and settings option --- components/AppleTVCarousel.tsx | 12 ++--- components/ParallaxPage.tsx | 71 ++++++++++++++++++++++----- components/settings/HomeIndex.tsx | 56 +++++++++++++-------- components/settings/OtherSettings.tsx | 14 ++++++ translations/en.json | 1 + utils/atoms/settings.ts | 2 + 6 files changed, 117 insertions(+), 39 deletions(-) diff --git a/components/AppleTVCarousel.tsx b/components/AppleTVCarousel.tsx index c439069d..7742af3f 100644 --- a/components/AppleTVCarousel.tsx +++ b/components/AppleTVCarousel.tsx @@ -39,7 +39,7 @@ interface AppleTVCarouselProps { const { width: screenWidth, height: screenHeight } = Dimensions.get("window"); // Layout Constants -const CAROUSEL_HEIGHT = screenHeight / 1.45; +export const APPLE_TV_CAROUSEL_HEIGHT = screenHeight / 1.45; const GRADIENT_HEIGHT_TOP = 150; const GRADIENT_HEIGHT_BOTTOM = 150; const LOGO_HEIGHT = 80; @@ -381,7 +381,7 @@ export const AppleTVCarousel: React.FC = ({ @@ -549,7 +549,7 @@ export const AppleTVCarousel: React.FC = ({ key={item.Id} style={{ width: screenWidth, - height: CAROUSEL_HEIGHT, + height: APPLE_TV_CAROUSEL_HEIGHT, position: "relative", }} > @@ -731,7 +731,7 @@ export const AppleTVCarousel: React.FC = ({ return ( = ({ return ( = ({ void) | null | undefined; + scrollViewProps?: Animated.AnimatedProps; + contentContainerStyle?: StyleProp; + scrollViewRef?: Ref; } export const ParallaxScrollView: React.FC> = ({ @@ -23,10 +39,33 @@ export const ParallaxScrollView: React.FC> = ({ headerHeight = 400, logo, onEndReached, + contentContainerStyle, + scrollViewProps, + scrollViewRef, ...props }: Props) => { - const scrollRef = useAnimatedRef(); - const scrollOffset = useScrollViewOffset(scrollRef); + const animatedScrollRef = useAnimatedRef(); + const scrollOffset = useScrollViewOffset(animatedScrollRef); + + const { + onScroll: externalOnScroll, + style: scrollStyle, + scrollEventThrottle: externalScrollEventThrottle, + ...restScrollViewProps + } = scrollViewProps ?? {}; + + useEffect(() => { + if (!scrollViewRef) return; + const node = animatedScrollRef.current; + + if (typeof scrollViewRef === "function") { + scrollViewRef(node); + return () => scrollViewRef(null); + } + + (scrollViewRef as MutableRefObject).current = + node; + }, [animatedScrollRef, scrollViewRef]); const headerAnimatedStyle = useAnimatedStyle(() => { return { @@ -62,12 +101,17 @@ export const ParallaxScrollView: React.FC> = ({ return ( { + externalOnScroll?.(e); if (isCloseToBottom(e.nativeEvent)) onEndReached?.(); }} > @@ -96,9 +140,12 @@ export const ParallaxScrollView: React.FC> = ({ { const [loading, setLoading] = useState(false); const { settings, refreshStreamyfinPluginSettings } = useSettings(); + const showCarousel = settings?.showHomeCarousel ?? true; const navigation = useNavigation(); const insets = useSafeAreaInsets(); - const scrollViewRef = useRef(null); + const scrollViewRef = useRef(null); const { getDownloadedItems, cleanCacheDirectory } = useDownload(); const prevIsConnected = useRef(false); @@ -128,7 +131,7 @@ export const HomeIndex = () => { const unsubscribe = eventBus.on("scrollToTop", () => { if ((segments as string[])[2] === "(home)") scrollViewRef.current?.scrollTo({ - y: Platform.isTV ? -152 : -100, + y: 0, animated: true, }); }); @@ -455,25 +458,36 @@ export const HomeIndex = () => { ); + const headerHeight = showCarousel ? APPLE_TV_CAROUSEL_HEIGHT : 120; + const refreshProgressOffset = showCarousel ? 200 : 80; + return ( - + + ) : ( + + ) } - style={{ marginTop: Platform.isTV ? 0 : -100 }} - contentContainerStyle={{ paddingTop: Platform.isTV ? 0 : 100 }} + contentContainerStyle={showCarousel ? undefined : { top: 0 }} + scrollViewProps={{ + refreshControl: ( + + ), + contentInsetAdjustmentBehavior: "never", + nestedScrollEnabled: true, + scrollToOverflowEnabled: true, + }} > - { - + ); }; diff --git a/components/settings/OtherSettings.tsx b/components/settings/OtherSettings.tsx index d4d7e598..c511b784 100644 --- a/components/settings/OtherSettings.tsx +++ b/components/settings/OtherSettings.tsx @@ -62,6 +62,7 @@ export const OtherSettings: React.FC = () => { pluginSettings?.followDeviceOrientation?.locked === true && pluginSettings?.defaultVideoOrientation?.locked === true && pluginSettings?.safeAreaInControlsEnabled?.locked === true && + pluginSettings?.showHomeCarousel?.locked === true && pluginSettings?.showCustomMenuLinks?.locked === true && pluginSettings?.hiddenLibraries?.locked === true && pluginSettings?.disableHapticFeedback?.locked === true, @@ -158,6 +159,19 @@ export const OtherSettings: React.FC = () => { /> + + + updateSettings({ showHomeCarousel: value }) + } + /> + + {/* {(Platform.OS === "ios" || Platform.isTVOS)&& (