feat: 选中优化
This commit is contained in:
parent
56b0cff7ec
commit
8969e45d6b
@ -85,6 +85,7 @@ const MessageItem = ({ t, insets, item, sessionId, setModalVisible, modalVisible
|
|||||||
{
|
{
|
||||||
((item.content.video_material_infos?.length || 0) + (item.content.image_material_infos?.length || 0)) > 3
|
((item.content.video_material_infos?.length || 0) + (item.content.image_material_infos?.length || 0)) > 3
|
||||||
&& <TouchableOpacity className="absolute top-1/2 -translate-y-1/2 -right-4 translate-x-1/2 bg-bgPrimary flex flex-row items-center gap-2 p-1 pl-2 rounded-full" onPress={() => {
|
&& <TouchableOpacity className="absolute top-1/2 -translate-y-1/2 -right-4 translate-x-1/2 bg-bgPrimary flex flex-row items-center gap-2 p-1 pl-2 rounded-full" onPress={() => {
|
||||||
|
setSelectedImages([])
|
||||||
setModalDetailsVisible({ visible: true, content: item.content });
|
setModalDetailsVisible({ visible: true, content: item.content });
|
||||||
}}>
|
}}>
|
||||||
<ThemedText className="!text-white font-semibold">{((item.content.video_material_infos?.length || 0) + (item.content.image_material_infos?.length || 0))}</ThemedText>
|
<ThemedText className="!text-white font-semibold">{((item.content.video_material_infos?.length || 0) + (item.content.image_material_infos?.length || 0))}</ThemedText>
|
||||||
|
|||||||
@ -48,6 +48,16 @@ const SelectModel = ({ modalDetailsVisible, setModalDetailsVisible, insets, setS
|
|||||||
windowSize={10}
|
windowSize={10}
|
||||||
removeClippedSubviews={true}
|
removeClippedSubviews={true}
|
||||||
renderItem={({ item }) => {
|
renderItem={({ item }) => {
|
||||||
|
const itemId = item?.id || item?.video?.id;
|
||||||
|
const isSelected = selectedImages.includes(itemId);
|
||||||
|
|
||||||
|
const toggleSelection = () => {
|
||||||
|
setSelectedImages(prev =>
|
||||||
|
isSelected
|
||||||
|
? prev.filter(id => id !== itemId)
|
||||||
|
: [...prev, itemId]
|
||||||
|
);
|
||||||
|
};
|
||||||
return (
|
return (
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={detailsStyles.gridItemContainer}
|
style={detailsStyles.gridItemContainer}
|
||||||
@ -69,18 +79,14 @@ const SelectModel = ({ modalDetailsVisible, setModalDetailsVisible, insets, setS
|
|||||||
loadingIndicatorSource={require('@/assets/images/png/placeholder.png')}
|
loadingIndicatorSource={require('@/assets/images/png/placeholder.png')}
|
||||||
/>
|
/>
|
||||||
<TouchableOpacity
|
<TouchableOpacity
|
||||||
style={[detailsStyles.circleMarker, selectedImages.includes(item?.id || item?.video?.id) ? detailsStyles.circleMarkerSelected : ""]}
|
style={[
|
||||||
onPress={() => {
|
detailsStyles.circleMarker,
|
||||||
setSelectedImages((prev) => {
|
isSelected && detailsStyles.circleMarkerSelected
|
||||||
if (prev.includes(item?.id || item?.video?.id)) {
|
]}
|
||||||
return prev.filter((id) => id !== (item.id || item?.video?.id));
|
onPress={toggleSelection}
|
||||||
} else {
|
activeOpacity={0.8}
|
||||||
return [...prev, item.id || item.video?.id];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{selectedImages.includes(item?.id || item?.video?.id) ? <YesSvg width={16} height={16} /> : ""}
|
{isSelected && <YesSvg width={16} height={16} />}
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
</View>
|
</View>
|
||||||
</TouchableOpacity>
|
</TouchableOpacity>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user