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 { strings } from '../../locales/i18n'
import { IconButton } from '../../ui/components'
@ -14,7 +14,6 @@ type Props = {
onClose: () => void
/** Window rect of the composer the sheet grows out of. */
anchor?: Rect
canAttachImages: boolean
attachmentPicking: boolean
takePhoto: () => Promise<void>
pickImages: () => Promise<void>
@ -29,16 +28,17 @@ type Props = {
permissionDisabled: boolean
permissionLabel: string | undefined
onReferenceChat?: () => void
onOpenPrompts?: () => void
onOpenWorkspace: () => void
onOpenMode: () => void
onOpenTools: () => void
onOpenPermissions: () => void
}
export function ChatActionMenu({ visible, onClose, anchor, canAttachImages, attachmentPicking,
export function ChatActionMenu({ visible, onClose, anchor, attachmentPicking,
takePhoto, pickImages, pickFiles, workspaceLabel, modeLabel, supportsModeSelection,
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 styles = useThemedStyles(createStyles)
const plusMenuListMaxHeight = usePickerListMaxHeight()
@ -51,32 +51,28 @@ export function ChatActionMenu({ visible, onClose, anchor, canAttachImages, atta
nestedScrollEnabled
>
<View style={styles.plusCardRow}>
{canAttachImages && (
<>
<Pressable
accessibilityRole="button"
accessibilityLabel={strings.chat.takePhoto}
accessibilityState={{ disabled: attachmentPicking }}
disabled={attachmentPicking}
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>
</Pressable>
<Pressable
accessibilityRole="button"
accessibilityLabel={strings.chat.photos}
accessibilityState={{ disabled: attachmentPicking }}
disabled={attachmentPicking}
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>
</Pressable>
</>
)}
<Pressable
accessibilityRole="button"
accessibilityLabel={strings.chat.takePhoto}
accessibilityState={{ disabled: attachmentPicking }}
disabled={attachmentPicking}
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>
</Pressable>
<Pressable
accessibilityRole="button"
accessibilityLabel={strings.chat.photos}
accessibilityState={{ disabled: attachmentPicking }}
disabled={attachmentPicking}
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>
</Pressable>
<Pressable
accessibilityRole="button"
accessibilityLabel={strings.chat.files}
@ -92,12 +88,24 @@ export function ChatActionMenu({ visible, onClose, anchor, canAttachImages, atta
{onReferenceChat !== undefined && (
<Pressable
accessibilityRole="button"
accessibilityLabel="引用对话"
accessibilityLabel={strings.chat.referenceChat}
onPress={() => { onClose(); onReferenceChat() }}
style={({ pressed }) => [styles.plusMenuOption, pressed && styles.plusMenuOptionPressed]}
>
<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} />
</Pressable>
)}