From 0014aebd4e84b9ae440f8b9b2af838ccf7ad951d Mon Sep 17 00:00:00 2001 From: Innei Date: Mon, 20 Jan 2025 16:33:04 +0800 Subject: [PATCH] feat(settings): enhance settings screen with animated header and blur effect - Introduced a new `SettingHeader` component that animates based on scroll position. - Added a `BlurEffect` to the header for improved visual aesthetics. - Refactored the `Settings` component to include the new header and maintain scroll functionality. - Updated imports to include necessary components for animation and styling. This update improves the user experience by providing a dynamic header that responds to scrolling. Signed-off-by: Innei --- .../src/modules/settings/routes/Privacy.tsx | 12 ++-- .../src/screens/(stack)/(tabs)/settings.tsx | 56 +++++++++++++------ 2 files changed, 48 insertions(+), 20 deletions(-) diff --git a/apps/mobile/src/modules/settings/routes/Privacy.tsx b/apps/mobile/src/modules/settings/routes/Privacy.tsx index 047e8b2b0..52c8cdad7 100644 --- a/apps/mobile/src/modules/settings/routes/Privacy.tsx +++ b/apps/mobile/src/modules/settings/routes/Privacy.tsx @@ -1,9 +1,13 @@ -import { Text, View } from "react-native" +import { ScrollView } from "react-native" + +import { GroupedInsetListCard, GroupedInsetListItem } from "@/src/components/ui/grouped/GroupedList" export const PrivacyScreen = () => { return ( - - Privacy Settings - + + + + + ) } diff --git a/apps/mobile/src/screens/(stack)/(tabs)/settings.tsx b/apps/mobile/src/screens/(stack)/(tabs)/settings.tsx index d4554f330..736279b1f 100644 --- a/apps/mobile/src/screens/(stack)/(tabs)/settings.tsx +++ b/apps/mobile/src/screens/(stack)/(tabs)/settings.tsx @@ -3,12 +3,14 @@ import { useIsFocused } from "@react-navigation/native" import { createNativeStackNavigator } from "@react-navigation/native-stack" import { createContext, useCallback, useContext, useEffect, useRef, useState } from "react" import type { NativeScrollEvent, NativeSyntheticEvent, ScrollView } from "react-native" -import { findNodeHandle, UIManager } from "react-native" -import { useSharedValue, withTiming } from "react-native-reanimated" +import { findNodeHandle, Text, UIManager } from "react-native" +import type { SharedValue } from "react-native-reanimated" +import Animated, { useAnimatedStyle, useSharedValue, withTiming } from "react-native-reanimated" import { useSafeAreaInsets } from "react-native-safe-area-context" import { useEventCallback } from "usehooks-ts" import { ReAnimatedScrollView } from "@/src/components/common/AnimatedComponents" +import { BlurEffect } from "@/src/components/common/HeaderBlur" import { BottomTabBarBackgroundContext } from "@/src/contexts/BottomTabBarBackgroundContext" import { SetBottomTabBarVisibleContext } from "@/src/contexts/BottomTabBarVisibleContext" import { SettingRoutes } from "@/src/modules/settings/routes" @@ -92,20 +94,42 @@ function Settings() { const scrollRef = useRef(null) return ( - { - setContentSize({ height: h, width: w }) - }} - style={{ paddingTop: insets.top }} - className="bg-system-grouped-background flex-1" - scrollIndicatorInsets={{ bottom: tabBarHeight - insets.bottom }} - > - + <> + { + setContentSize({ height: h, width: w }) + }} + style={{ paddingTop: insets.top }} + className="bg-system-grouped-background flex-1" + scrollIndicatorInsets={{ bottom: tabBarHeight - insets.bottom }} + > + - - + + + + + ) +} + +const SettingHeader = ({ scrollY }: { scrollY: SharedValue }) => { + const styles = useAnimatedStyle(() => { + return { + opacity: scrollY.value / 100, + } + }) + return ( + + + + Settings + ) }