From 619247d5fd016cf05cf2b573ce6607de29903a95 Mon Sep 17 00:00:00 2001 From: Zoe Roux Date: Fri, 13 Feb 2026 19:02:22 +0100 Subject: [PATCH] Add dark overlay on transparent navbars --- front/src/ui/details/header.tsx | 3 +- front/src/ui/details/movie.tsx | 4 +- front/src/ui/details/serie.tsx | 10 ++-- front/src/ui/home/header.tsx | 2 +- front/src/ui/home/index.tsx | 4 +- front/src/ui/home/watchlist.tsx | 2 +- front/src/ui/navbar.tsx | 63 ++++++++++++++++++++------ front/src/ui/player/controls/touch.tsx | 5 +- 8 files changed, 64 insertions(+), 29 deletions(-) diff --git a/front/src/ui/details/header.tsx b/front/src/ui/details/header.tsx index 248ab9ba..8a1fe486 100644 --- a/front/src/ui/details/header.tsx +++ b/front/src/ui/details/header.tsx @@ -3,10 +3,9 @@ import MoreHoriz from "@material-symbols/svg-400/rounded/more_horiz.svg"; import MovieInfo from "@material-symbols/svg-400/rounded/movie_info.svg"; import PlayArrow from "@material-symbols/svg-400/rounded/play_arrow-fill.svg"; import Theaters from "@material-symbols/svg-400/rounded/theaters-fill.svg"; -import { Stack } from "expo-router"; import { Fragment } from "react"; import { useTranslation } from "react-i18next"; -import { View, ViewProps } from "react-native"; +import { View, type ViewProps } from "react-native"; import { WatchListInfo } from "~/components/items/watchlist-info"; import { Rating } from "~/components/rating"; import { diff --git a/front/src/ui/details/movie.tsx b/front/src/ui/details/movie.tsx index eb398ab7..578d775e 100644 --- a/front/src/ui/details/movie.tsx +++ b/front/src/ui/details/movie.tsx @@ -2,7 +2,7 @@ import { useState } from "react"; import Animated from "react-native-reanimated"; import { useSafeAreaInsets } from "react-native-safe-area-context"; import { useQueryState } from "~/utils"; -import { useScrollNavbar } from "../navbar"; +import { HeaderBackground, useScrollNavbar } from "../navbar"; import { Header } from "./header"; export const MovieDetails = () => { @@ -13,7 +13,7 @@ export const MovieDetails = () => { return ( <> - + ) => { // aspect-[width/height]: width/height of the svg @@ -94,7 +92,7 @@ export const SerieDetails = () => { return ( - + { return ( <> - + { diff --git a/front/src/ui/navbar.tsx b/front/src/ui/navbar.tsx index 889a09e7..7f41b5ab 100644 --- a/front/src/ui/navbar.tsx +++ b/front/src/ui/navbar.tsx @@ -4,6 +4,7 @@ import Login from "@material-symbols/svg-400/rounded/login.svg"; import Logout from "@material-symbols/svg-400/rounded/logout.svg"; import Search from "@material-symbols/svg-400/rounded/search-fill.svg"; import Settings from "@material-symbols/svg-400/rounded/settings.svg"; +import { useIsFocused } from "@react-navigation/native"; import { useGlobalSearchParams, useNavigation, @@ -15,10 +16,9 @@ import { type ComponentProps, type Ref, useEffect, + useLayoutEffect, useRef, useState, - useLayoutEffect, - useCallback, } from "react"; import { useTranslation } from "react-i18next"; import { @@ -27,8 +27,16 @@ import { type TextInput, type TextInputProps, View, - Animated, + type ViewProps, } from "react-native"; +import Animated, { + interpolate, + useAnimatedScrollHandler, + useAnimatedStyle, + useSharedValue, +} from "react-native-reanimated"; +import { useSafeAreaInsets } from "react-native-safe-area-context"; +import { useCSSVariable } from "uniwind"; import { A, Avatar, @@ -43,15 +51,6 @@ import { import { useAccount, useAccounts } from "~/providers/account-context"; import { logout } from "~/ui/login/logic"; import { cn } from "~/utils"; -import { - interpolate, - useAnimatedScrollHandler, - useAnimatedStyle, - useSharedValue, -} from "react-native-reanimated"; -import { useSafeAreaInsets } from "react-native-safe-area-context"; -import { useIsFocused } from "@react-navigation/native"; -import { useCSSVariable } from "uniwind"; export const NavbarTitle = ({ className, @@ -227,6 +226,12 @@ export const useScrollNavbar = ({ }), [imageHeight, height], ); + const reverse = useAnimatedStyle( + () => ({ + opacity: interpolate(scrollY.value, [0, imageHeight - height], [1, 0]), + }), + [imageHeight, height], + ); const nav = useNavigation(); const focused = useIsFocused(); @@ -249,9 +254,39 @@ export const useScrollNavbar = ({ return { scrollHandler, headerProps: { - className: cn("absolute z-10 w-full bg-accent"), - style: [{ height }, opacity], + opacity, + reverse, + height, }, headerHeight: height, }; }; + +export const HeaderBackground = ({ + children, + opacity, + reverse, + height, + className, + style, + ...props +}: ViewProps & ReturnType["headerProps"]) => { + return ( + <> + + + {children} + + ); +}; diff --git a/front/src/ui/player/controls/touch.tsx b/front/src/ui/player/controls/touch.tsx index f10a68e6..82f993e0 100644 --- a/front/src/ui/player/controls/touch.tsx +++ b/front/src/ui/player/controls/touch.tsx @@ -88,7 +88,10 @@ export const TouchControls = ({ // instantly hide the controls when mouse leaves the view if (e.nativeEvent.pointerType === "mouse") show(false); }} - className={cn("absolute inset-0 cursor-default", !shouldShow && "cursor-none")} + className={cn( + "absolute inset-0 cursor-default", + !shouldShow && "cursor-none", + )} /> {shouldShow && children}