diff --git a/apps/android/src/screens/chat/pickers.tsx b/apps/android/src/screens/chat/pickers.tsx new file mode 100644 index 0000000..8010ddb --- /dev/null +++ b/apps/android/src/screens/chat/pickers.tsx @@ -0,0 +1,543 @@ +import { Check, ChevronLeft, ChevronRight, Folder, Pencil, Plus, Terminal, Trash2, X } from 'lucide-react-native' +import { useEffect, useState } from 'react' +import { ActivityIndicator, Pressable, ScrollView, Text, TextInput, View } from 'react-native' +import { strings as zhCN } from '../../locales/i18n' +import type { CustomPrompt } from '../../services/storage' +import type { + AgentPresetOption, + ModelCatalogModel, + ModelProviderGroup, + PermissionSelect, + WorkspaceView, +} from '../../types' +import { Button, IconButton } from '../../ui/components' +import { useTheme } from '../../ui/theme-context' +import { useThemedStyles } from '../../ui/use-themed-styles' +import { usePickerListMaxHeight } from './modal' +import { SheetModal } from '../../ui/sheet' +import { createStyles } from './styles' + +export function ModePicker({ visible, options, current, loading, selecting, onClose, onPick }: { + visible: boolean + options?: AgentPresetOption[] + current?: string + loading?: boolean + selecting?: boolean + onClose: () => void + onPick: (preset: string) => void +}) { + const { colors } = useTheme() + const styles = useThemedStyles(createStyles) + const listMaxHeight = usePickerListMaxHeight() + return ( + + {zhCN.chat.selectMode} + + {options === undefined || options.length === 0 ? ( + loading + ? + : {zhCN.chat.modeLoadFailed} + ) : options.map(option => { + const isCurrent = option.id === current + const broken = option.broken !== undefined + const description = agentPresetDescription(option) + return ( + onPick(option.id)} + style={[styles.permissionOption, isCurrent && styles.modelOptionCurrent, (selecting || broken) && styles.plusMenuOptionDisabled]} + > + + {agentPresetName(option)} + {description !== undefined && {description}} + + {isCurrent && } + + ) + })} + + + ) +} + +export function PermissionPicker({ visible, permissions, onClose, onPick, loading, error, onRetry }: { + loading: boolean + error?: string + onRetry: () => void + visible: boolean + permissions?: PermissionSelect + onClose: () => void + onPick: (preset: string) => void +}) { + const { colors } = useTheme() + const styles = useThemedStyles(createStyles) + const listMaxHeight = usePickerListMaxHeight() + if (permissions === undefined) return null + return ( + + {zhCN.chat.approvalMode} + + {loading && } + {error && {error}