Import apps/android/src/screens/chat/action-menu.tsx

This commit is contained in:
QQ 2026-11-17 08:28:36 +08:00
parent 85ec7d27a6
commit b43172793f
1 changed files with 40 additions and 32 deletions

View File

@ -1,4 +1,4 @@
import { Camera, ChevronRight, FileText, Folder, Images, Layers, MessageSquare, ShieldAlert, Terminal, X } from 'lucide-react-native' import { Camera, ChevronRight, FileText, Folder, Images, Layers, MessageSquare, ShieldAlert, Terminal, X, Zap } from 'lucide-react-native'
import { ActivityIndicator, Pressable, ScrollView, Text, View } from 'react-native' import { ActivityIndicator, Pressable, ScrollView, Text, View } from 'react-native'
import { strings } from '../../locales/i18n' import { strings } from '../../locales/i18n'
import { IconButton } from '../../ui/components' import { IconButton } from '../../ui/components'
@ -14,7 +14,6 @@ type Props = {
onClose: () => void onClose: () => void
/** Window rect of the composer the sheet grows out of. */ /** Window rect of the composer the sheet grows out of. */
anchor?: Rect anchor?: Rect
canAttachImages: boolean
attachmentPicking: boolean attachmentPicking: boolean
takePhoto: () => Promise<void> takePhoto: () => Promise<void>
pickImages: () => Promise<void> pickImages: () => Promise<void>
@ -29,16 +28,17 @@ type Props = {
permissionDisabled: boolean permissionDisabled: boolean
permissionLabel: string | undefined permissionLabel: string | undefined
onReferenceChat?: () => void onReferenceChat?: () => void
onOpenPrompts?: () => void
onOpenWorkspace: () => void onOpenWorkspace: () => void
onOpenMode: () => void onOpenMode: () => void
onOpenTools: () => void onOpenTools: () => void
onOpenPermissions: () => void onOpenPermissions: () => void
} }
export function ChatActionMenu({ visible, onClose, anchor, canAttachImages, attachmentPicking, export function ChatActionMenu({ visible, onClose, anchor, attachmentPicking,
takePhoto, pickImages, pickFiles, workspaceLabel, modeLabel, supportsModeSelection, takePhoto, pickImages, pickFiles, workspaceLabel, modeLabel, supportsModeSelection,
agentPresetSelecting, toolsAvailable, permissionsAvailable, permissionSelecting, agentPresetSelecting, toolsAvailable, permissionsAvailable, permissionSelecting,
permissionDisabled, permissionLabel, onReferenceChat, onOpenWorkspace, onOpenMode, onOpenTools, onOpenPermissions }: Props) { permissionDisabled, permissionLabel, onReferenceChat, onOpenPrompts, onOpenWorkspace, onOpenMode, onOpenTools, onOpenPermissions }: Props) {
const { colors } = useTheme() const { colors } = useTheme()
const styles = useThemedStyles(createStyles) const styles = useThemedStyles(createStyles)
const plusMenuListMaxHeight = usePickerListMaxHeight() const plusMenuListMaxHeight = usePickerListMaxHeight()
@ -51,32 +51,28 @@ export function ChatActionMenu({ visible, onClose, anchor, canAttachImages, atta
nestedScrollEnabled nestedScrollEnabled
> >
<View style={styles.plusCardRow}> <View style={styles.plusCardRow}>
{canAttachImages && ( <Pressable
<> accessibilityRole="button"
<Pressable accessibilityLabel={strings.chat.takePhoto}
accessibilityRole="button" accessibilityState={{ disabled: attachmentPicking }}
accessibilityLabel={strings.chat.takePhoto} disabled={attachmentPicking}
accessibilityState={{ disabled: attachmentPicking }} onPress={() => { onClose(); void takePhoto() }}
disabled={attachmentPicking} style={({ pressed }) => [styles.plusCard, pressed && styles.plusMenuOptionPressed, attachmentPicking && styles.plusMenuOptionDisabled]}
onPress={() => { onClose(); void takePhoto() }} >
style={({ pressed }) => [styles.plusCard, pressed && styles.plusMenuOptionPressed, attachmentPicking && styles.plusMenuOptionDisabled]} <Camera size={22} color={colors.primary} />
> <Text style={styles.plusCardText}>{strings.chat.takePhoto}</Text>
<Camera size={22} color={colors.primary} /> </Pressable>
<Text style={styles.plusCardText}>{strings.chat.takePhoto}</Text> <Pressable
</Pressable> accessibilityRole="button"
<Pressable accessibilityLabel={strings.chat.photos}
accessibilityRole="button" accessibilityState={{ disabled: attachmentPicking }}
accessibilityLabel={strings.chat.photos} disabled={attachmentPicking}
accessibilityState={{ disabled: attachmentPicking }} onPress={() => { onClose(); void pickImages() }}
disabled={attachmentPicking} style={({ pressed }) => [styles.plusCard, pressed && styles.plusMenuOptionPressed, attachmentPicking && styles.plusMenuOptionDisabled]}
onPress={() => { onClose(); void pickImages() }} >
style={({ pressed }) => [styles.plusCard, pressed && styles.plusMenuOptionPressed, attachmentPicking && styles.plusMenuOptionDisabled]} <Images size={22} color={colors.primary} />
> <Text style={styles.plusCardText}>{strings.chat.photos}</Text>
<Images size={22} color={colors.primary} /> </Pressable>
<Text style={styles.plusCardText}>{strings.chat.photos}</Text>
</Pressable>
</>
)}
<Pressable <Pressable
accessibilityRole="button" accessibilityRole="button"
accessibilityLabel={strings.chat.files} accessibilityLabel={strings.chat.files}
@ -92,12 +88,24 @@ export function ChatActionMenu({ visible, onClose, anchor, canAttachImages, atta
{onReferenceChat !== undefined && ( {onReferenceChat !== undefined && (
<Pressable <Pressable
accessibilityRole="button" accessibilityRole="button"
accessibilityLabel="引用对话" accessibilityLabel={strings.chat.referenceChat}
onPress={() => { onClose(); onReferenceChat() }} onPress={() => { onClose(); onReferenceChat() }}
style={({ pressed }) => [styles.plusMenuOption, pressed && styles.plusMenuOptionPressed]} style={({ pressed }) => [styles.plusMenuOption, pressed && styles.plusMenuOptionPressed]}
> >
<MessageSquare size={20} color={colors.primary} /> <MessageSquare size={20} color={colors.primary} />
<Text style={styles.plusMenuOptionText}>引用对话</Text> <Text style={styles.plusMenuOptionText}>{strings.chat.referenceChat}</Text>
<ChevronRight size={16} color={colors.muted} />
</Pressable>
)}
{onOpenPrompts !== undefined && (
<Pressable
accessibilityRole="button"
accessibilityLabel={strings.chat.quickPrompts}
onPress={() => { onClose(); onOpenPrompts() }}
style={({ pressed }) => [styles.plusMenuOption, pressed && styles.plusMenuOptionPressed]}
>
<Zap size={20} color={colors.primary} />
<Text style={styles.plusMenuOptionText}>{strings.chat.quickPrompts}</Text>
<ChevronRight size={16} color={colors.muted} /> <ChevronRight size={16} color={colors.muted} />
</Pressable> </Pressable>
)} )}