import { useTranslation } from "react-i18next"; import { View, Text, Pressable, FlatList, Alert } from "react-native"; import { useNavigation } from "@react-navigation/native"; import type { NativeStackNavigationProp } from "@react-navigation/native-stack"; import type { WorkoutStackParamList } from "@navigation/types"; import { useTemplates } from "../hooks/useTemplates"; export function TemplatesScreen() { const { t } = useTranslation("common"); const navigation = useNavigation>(); const { templates, remove, toggleFavorite } = useTemplates(); const handleDelete = (id: string, name: string) => { Alert.alert(t("alert.deleteTemplate"), t("alert.deleteConfirm", { name }), [ { text: t("cancel"), style: "cancel" }, { text: t("delete"), style: "destructive", onPress: () => remove(id) }, ]); }; return ( item.id} contentContainerClassName="p-4" ListEmptyComponent={ {t("alert.deleteTemplate")} {t("noTemplatesYet")} } renderItem={({ item }) => ( navigation.navigate("Builder", { templateId: item.id })} className="bg-slate-50 rounded-2xl p-4 mb-3 border border-slate-200" > {item.name} {t("pool", { length: item.poolLength })} toggleFavorite(item.id, item.isFavorite)} className="p-1" > {item.isFavorite ? "★" : "☆"} handleDelete(item.id, item.name)} className="p-1" > × )} /> ); }