Event Pass
Event timing, location, admission code availability and check-in instructions in one mobile pass.
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 event-passSource files
Expand a file to read the source the installer copies into your app.
components/blocks/event-pass/EventPass.tsx
import type { ReactElement } from 'react'
import { View, type ViewProps } from 'react-native'
import { Text } from '@/components/ui/text'
import { useAnnouncement } from '@/lib/accessibility'
import { cn } from '@/lib/utils'
export type EventPassCodeStatus = 'ready' | 'unavailable'
export interface EventPassProps extends Omit<ViewProps, 'children'> {
className?: string
title: string
/** Date and time already formatted in the venue's time zone. */
dateTime: string
venue: string
venueDetail?: string
seat?: string
instructions?: string
codeStatus: EventPassCodeStatus
code?: string
/** Optional caller-provided visual credentials. Only mounted when the code is ready. */
verification?: ReactElement
unavailableDetail?: string
labels?: Partial<Record<'code' | 'unavailable' | 'checkIn', string>>
}
export function EventPass({
className,
title,
dateTime,
venue,
venueDetail,
seat,
instructions,
codeStatus,
code,
verification,
unavailableDetail,
labels,
...props
}: EventPassProps) {
const admissionCode = code?.trim()
const showCode = codeStatus === 'ready' && Boolean(admissionCode || verification)
const unavailable = labels?.unavailable ?? 'Admission code unavailable'
useAnnouncement(showCode ? undefined : unavailable)
return (
<View {...props} className={cn('gap-[16px] rounded-lg border border-border bg-card p-[16px]', className)}>
<View className="gap-[4px]">
<Text size="title" accessibilityRole="header" className="text-card-foreground">
{title}
</Text>
<Text className="font-medium text-card-foreground">{dateTime}</Text>
</View>
<View className="gap-[4px]">
<Text className="font-medium text-card-foreground">{venue}</Text>
{venueDetail ? <Text variant="muted">{venueDetail}</Text> : null}
{seat ? <Text variant="muted">{seat}</Text> : null}
</View>
<View className="gap-[8px] border-t border-border pt-[16px]">
{showCode ? (
<View className="items-center gap-[4px]">
{verification}
{admissionCode ? (
<>
<Text size="sm" variant="muted" className="text-center">
{labels?.code ?? 'Admission code'}
</Text>
<Text selectable size="xl" className="max-w-full text-center text-card-foreground">
{admissionCode}
</Text>
</>
) : null}
</View>
) : (
<View className="gap-[4px]">
<Text className="font-medium text-card-foreground">{unavailable}</Text>
{unavailableDetail ? <Text variant="muted">{unavailableDetail}</Text> : null}
</View>
)}
</View>
{instructions ? (
<View className="gap-[4px] border-t border-border pt-[16px]">
<Text size="sm" className="font-semibold text-card-foreground">
{labels?.checkIn ?? 'Check-in'}
</Text>
<Text variant="muted">{instructions}</Text>
</View>
) : null}
</View>
)
}
components/blocks/event-pass/index.ts
export { EventPass, type EventPassCodeStatus, type EventPassProps } from './EventPass'