Proof Of Delivery
A delivered shipment receipt with photo retry, signature and missing-proof states, and a support action.
Install
First install? Set up the registry in your app.
npx --yes --package=https://native.uipkge.dev/cli/uipkge-native-0.1.1.tgz uipkge-native add proof-of-deliverySource files
Expand a file to read the source the installer copies into your app.
components/blocks/proof-of-delivery/ProofOfDelivery.tsx
import { useWindowDimensions, View, type ViewProps } from 'react-native'
import { Button } from '@/components/ui/button'
import {
Image,
ImageFallback,
ImageLoading,
ImageRetry,
ImageSource,
type ImageSourceValue,
} from '@/components/ui/image'
import { Text } from '@/components/ui/text'
import { cn } from '@/lib/utils'
export type DeliveryProof =
| { kind: 'photo'; source: ImageSourceValue; description: string; location?: string }
| { kind: 'signed'; recipient: string; location?: string }
| { kind: 'unavailable'; reason?: string }
export interface ProofOfDeliveryProps extends ViewProps {
className?: string
title?: string
deliveredAt?: string
proof?: DeliveryProof
onReportIssue?: () => void
}
const sampleProof: DeliveryProof = { kind: 'signed', recipient: 'Sam Rivera', location: 'Building reception' }
export function ProofOfDelivery({
className,
title = 'Proof of delivery',
deliveredAt = 'today, 1:46 PM',
proof = sampleProof,
onReportIssue,
...props
}: ProofOfDeliveryProps) {
const { fontScale } = useWindowDimensions()
return (
<View {...props} className={cn('gap-4', className)}>
<View className="gap-1">
<Text size="title" accessibilityRole="header">
{title}
</Text>
<Text size="sm" variant="muted">
Delivered {deliveredAt}
</Text>
</View>
<View className="gap-3 rounded-xl border border-border bg-card p-4">
{proof.kind === 'photo' ? (
<>
<Text className="font-semibold">Delivery photo</Text>
<Image source={proof.source} style={fontScale >= 1.5 ? { aspectRatio: 4 / 3 } : undefined}>
<ImageSource accessibilityLabel={proof.description} accessibilityRole="image" resizeMode="contain" />
<ImageLoading />
<ImageFallback accessibilityLiveRegion="polite">
<Text size="sm" className="text-center">
The photo couldn’t load.
</Text>
<ImageRetry>Retry photo</ImageRetry>
</ImageFallback>
</Image>
{proof.location ? (
<Text size="sm" variant="muted">
{proof.location}
</Text>
) : null}
</>
) : proof.kind === 'signed' ? (
<View className="gap-1">
<Text size="sm" variant="muted">
Signed for by
</Text>
<Text className="font-semibold">{proof.recipient}</Text>
{proof.location ? <Text size="sm">{proof.location}</Text> : null}
</View>
) : (
<View className="gap-1">
<Text className="font-semibold">No delivery proof available</Text>
<Text size="sm" variant="muted">
{proof.reason ?? 'The carrier marked this shipment delivered without a photo or signature.'}
</Text>
</View>
)}
</View>
{onReportIssue ? (
<Button variant="outline" onPress={onReportIssue}>
Report a delivery issue
</Button>
) : null}
</View>
)
}
components/blocks/proof-of-delivery/index.ts
export { ProofOfDelivery, type DeliveryProof, type ProofOfDeliveryProps } from './ProofOfDelivery'