Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107import { View, Text, Image, Pressable, Alert } from "react-native";import { WeatherIcon } from "./WeatherIcon";import { RawRecordView } from "./RawRecordView";import { useWalksStore } from "@/stores/walks";import { useDevModeStore } from "@/stores/devmode";import { parseWalkMetadata } from "@/lib/types";import type { WalkEntry } from "@/lib/types";
interface WalkCardProps { walk: WalkEntry;}
export function WalkCard({ walk }: WalkCardProps) { const { deleteWalk } = useWalksStore(); const devMode = useDevModeStore((s) => s.enabled); const { value } = walk;
// Use CDN URL from hydrated feed view, or null const image = value.embed?.images?.[0]; const imageUrl = walk.imageUrl ?? null; const metadata = image?.alt ? parseWalkMetadata(image.alt) : null;
const emoji = value.text; const timestamp = metadata?.capturedAt ?? value.createdAt; const weather = metadata?.weather; const location = metadata?.location;
const time = new Date(timestamp).toLocaleTimeString([], { hour: "2-digit", minute: "2-digit", }); const date = new Date(timestamp).toLocaleDateString([], { month: "short", day: "numeric", });
const handleDelete = () => { Alert.alert("Delete Walk", "Are you sure?", [ { text: "Cancel", style: "cancel" }, { text: "Delete", style: "destructive", onPress: () => deleteWalk(walk.uri), }, ]); };
return ( <View className="mb-4"> <Pressable onLongPress={handleDelete}> <View className="rounded-2xl overflow-hidden bg-gray-100"> {imageUrl ? ( <Image source={{ uri: imageUrl }} className="w-full aspect-square" resizeMode="cover" /> ) : ( <View className="w-full aspect-square items-center justify-center"> <Text className="text-gray-400">No image</Text> </View> )}
{/* Time overlay - top left */} <View className="absolute top-3 left-3 bg-black/50 rounded-lg px-2 py-1"> <Text className="text-white text-xs"> {date} {time} </Text> </View>
{/* Weather overlay - top right */} {weather && weather.code >= 0 && ( <View className="absolute top-3 right-3 bg-black/50 rounded-lg px-2 py-1"> <WeatherIcon code={weather.code} temperature={weather.temperature} /> </View> )}
{/* Emoji overlay - bottom left */} {emoji && ( <View className="absolute bottom-3 left-3"> <Text className="text-4xl">{emoji}</Text> </View> )}
{/* Location overlay - bottom right */} {location && location.latitude !== 0 && location.longitude !== 0 && ( <View className="absolute bottom-3 right-3 bg-black/50 rounded-lg px-2 py-1"> <Text className="text-white text-xs"> {location.latitude.toFixed(2)}, {location.longitude.toFixed(2)} </Text> </View> )} </View> </Pressable> {devMode && ( <RawRecordView data={{ uri: walk.uri, record: value }} label={`app.bsky.feed.post — ${walk.uri.split("/").pop()}`} /> )} </View> );}