Amba-Agent-App/components/ui/backButton.tsx
2026-01-16 00:22:35 +03:00

43 lines
1013 B
TypeScript

import React from "react";
import { View } from "react-native";
import { Button } from "~/components/ui/button";
import { ArrowLeft } from "lucide-react-native";
import { router, useNavigation } from "expo-router";
import { useTabStore } from "~/lib/stores";
interface BackButtonProps {
onPress?: () => void;
className?: string;
iconSize?: number;
iconColor?: string;
}
export default function BackButton({
onPress,
className = "flex flex-row justify-start w-full pr-4",
iconSize = 24,
iconColor = "text-primary",
}: BackButtonProps) {
const { lastVisitedTab } = useTabStore();
const navigation = useNavigation();
const handlePress = () => {
if (onPress) {
onPress();
} else {
router.back();
}
};
return (
<View className={className}>
<Button
className="bg-transparent border border-black m-4 rounded-[8px]"
onPress={handlePress}
>
<ArrowLeft className={iconColor} size={iconSize} />
</Button>
</View>
);
}