Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.
TypeScript adeagent-ideai-agentsautomationbotclaude-codecodexghosttygrok-bothermes-agentmobile-appmuseopenclawopencodeorchestrationpiruntimeterminalworktreesyc-backed
import { useCallback, useEffect, useRef, useState, type ReactNode } from 'react'
import { FlatList, Pressable, StyleSheet, Text, View } from 'react-native'
import { Check } from 'lucide-react-native'
import { colors, spacing, typography } from '../theme/mobile-theme'
import { themedStyleSheet } from '../theme/themed-styles'
import { useMobileColorScheme } from '../theme/use-mobile-color-scheme'
import { BottomDrawer } from './BottomDrawer'
import { BOTTOM_DRAWER_HIDE_DURATION_MS } from './bottom-drawer-constants'
type PickerListItem = { id: string; label: string; detail?: string }
type Props<T extends PickerListItem> = {
visible: boolean
title: string
items: T[]
selectedId: string
onSelect: (item: T) => void
onClose: () => void
renderIcon?: (item: T) => ReactNode
}
export function PickerListDrawer<T extends PickerListItem>({
visible,
title,
items,
selectedId,
onSelect,
onClose,
renderIcon
}: Props<T>) {
const colorScheme = useMobileColorScheme()
const [closing, setClosing] = useState(false)
const closeTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null)
const drawerVisible = visible && !closing
useEffect(() => {
if (visible) {
setClosing(false)
}
return () => {
if (closeTimerRef.current) {
clearTimeout(closeTimerRef.current)
closeTimerRef.current = null
}
}
}, [visible])
const finishClose = useCallback(() => {
setClosing(false)
onClose()
}, [onClose])
const closeThenSelect = useCallback(
(item: T) => {
if (closeTimerRef.current) {
clearTimeout(closeTimerRef.current)
}
setClosing(true)
closeTimerRef.current = setTimeout(() => {
closeTimerRef.current = null
onClose()
onSelect(item)
}, BOTTOM_DRAWER_HIDE_DURATION_MS)
},
[onClose, onSelect]
)
return (
<BottomDrawer
visible={drawerVisible}
onClose={finishClose}
dragContentToDismiss={false}
contentScrollable={false}
>
<View style={styles.header}>
<Text style={styles.title}>{title}</Text>
</View>
<FlatList
data={items}
extraData={colorScheme}
keyExtractor={(item) => item.id}
style={styles.group}
contentContainerStyle={items.length === 0 ? styles.emptyContent : undefined}
keyboardShouldPersistTaps="handled"
nestedScrollEnabled
ItemSeparatorComponent={PickerSeparator}
renderItem={({ item }) => {
const selected = item.id === selectedId
return (
<Pressable
style={({ pressed }) => [styles.item, pressed && styles.itemPressed]}
onPress={() => closeThenSelect(item)}
>
{renderIcon?.(item)}
<View style={styles.itemCopy}>
<Text
style={[styles.itemText, selected && styles.itemTextSelected]}
numberOfLines={1}
>
{item.label}
</Text>
{item.detail ? (
<Text style={styles.itemDetail} numberOfLines={1}>
{item.detail}
</Text>
) : null}
</View>
{selected && <Check size={14} color={colors.textPrimary} />}
</Pressable>
)
}}
/>
</BottomDrawer>
)
}
function PickerSeparator() {
useMobileColorScheme()
return <View style={styles.separator} />
}
const styles = themedStyleSheet(() => ({
header: {
paddingHorizontal: spacing.xs,
paddingBottom: spacing.sm
},
title: {
fontSize: 13,
fontWeight: '500',
color: colors.textMuted
},
group: {
backgroundColor: colors.bgPanel,
borderRadius: 12,
overflow: 'hidden',
maxHeight: 420,
flexGrow: 0
},
emptyContent: {
minHeight: spacing.xl
},
separator: {
height: StyleSheet.hairlineWidth,
backgroundColor: colors.borderSubtle,
marginHorizontal: spacing.md
},
item: {
flexDirection: 'row',
alignItems: 'center',
gap: spacing.sm,
paddingVertical: spacing.md,
paddingHorizontal: spacing.md + 2
},
itemPressed: {
backgroundColor: colors.bgRaised
},
itemText: {
fontSize: typography.bodySize,
color: colors.textPrimary
},
itemCopy: {
flex: 1,
minWidth: 0
},
itemDetail: {
fontSize: typography.metaSize,
color: colors.textMuted,
marginTop: 1
},
itemTextSelected: {
fontWeight: '600'
}
}))