import React from "react"; import { View, Text, StyleProp, ViewStyle, Pressable, StyleSheet } from "react-native"; import { cn } from "@/utils/cn"; import Animated, { useSharedValue, useAnimatedStyle, withSpring } from "react-native-reanimated"; import { Shadow } from "react-native-shadow-2"; import { ChevronLeft, SlidersHorizontal, CirclePower, LucideIcon } from "lucide-react-native"; interface NavbarProps { title?: string; titleIcon?: LucideIcon; showBack?: boolean; onBack?: () => void; onClose?: () => void; className?: string; style?: StyleProp; } const AnimatedView = Animated.View; export default function Navbar({ title, titleIcon, showBack = true, onBack, onClose, className, style, }: NavbarProps) { const TitleIcon = titleIcon; // 返回按钮 const scale = useSharedValue(1); const backAnimatedStyle = useAnimatedStyle(() => ({ transform: [{ scale: scale.value }], })); // 右侧按钮动画 const leftScale = useSharedValue(1); const rightScale = useSharedValue(1); const leftStyle = useAnimatedStyle(() => ({ transform: [{ scale: leftScale.value }], opacity: leftScale.value === 1 ? 1 : 0.7, })); const rightStyle = useAnimatedStyle(() => ({ transform: [{ scale: rightScale.value }], opacity: rightScale.value === 1 ? 1 : 0.7, })); return ( {showBack && ( { scale.value = withSpring(0.8); }} onPressOut={() => { scale.value = withSpring(1); }} > )} {title && ( {TitleIcon && } {title} )} { leftScale.value = withSpring(0.8); }} onPressOut={() => { leftScale.value = withSpring(1); }} > { rightScale.value = withSpring(0.8); }} onPressOut={() => { rightScale.value = withSpring(1); }} > ); } const styles = StyleSheet.create({ iconButtonShadow: { borderRadius: 999, width: 36, height: 36, alignItems: "center", justifyContent: "center", borderWidth: 0.5, borderColor: "rgba(255,255,255,0.6)", backgroundColor: "#fff", }, groupShadow: { borderRadius: 999, height: 36, flexDirection: "row", alignItems: "center", justifyContent: "center", borderWidth: 0.5, borderColor: "rgba(255,255,255,0.6)", backgroundColor: "#fff", }, titleShadown: { borderRadius: 999, height: 36, flexDirection: "row", alignItems: "center", justifyContent: "flex-start", borderWidth: 0.5, borderColor: "rgba(255,255,255,0.6)", paddingHorizontal: 16, backgroundColor: "#fff", }, });