howljs / react-native-calendar-kit

React Native Calendar Kit is a powerful and flexible calendar component for React Native applications. It provides a customizable and feature-rich calendar view with support for various functionalities
https://howljs.github.io/react-native-calendar-kit/docs/intro/
MIT License
429 stars 73 forks source link

有关文档中提到的Drag to create #127

Closed JiuMengDz closed 1 week ago

JiuMengDz commented 2 weeks ago

我使用文档中给的示例程序来执行,但是我拖动的时候没有任何彩色框显示,请问是有什么问题吗?还是这样的表现是正常的?

image 实际上我已经拖拽了,但是没有任何表现。 renderDraggingEvent回调有执行 我打印了props的内容 image

howljs commented 1 week ago

请提供您正在使用的代码。我会检查原因。

JiuMengDz commented 1 week ago

请提供您正在使用的代码。我会检查原因。


import { config } from '@ant-design/react-native/lib/toast/methods';
import { CalendarBody, CalendarContainer, CalendarHeader, DraggingEventProps, DraggingEvent } from '@howljs/calendar-kit';
import React, { useCallback } from 'react';
import { Text, View } from 'react-native';

export default function APP() { const renderDraggingEvent = useCallback((props: DraggingEventProps) => { return ( <DraggingEvent {...props} TopEdgeComponent={ <View style={{ height: 100, width: '100%', backgroundColor: 'red', position: 'absolute', }} /> } BottomEdgeComponent={ <View style={{ height: 100, width: '100%', backgroundColor: 'red', bottom: 0, position: 'absolute', }} /> } /> ); }, []);

return ( <CalendarContainer allowPinchToZoom={true} allowDragToCreate={true} events={[ { id: '1', title: 'Meeting with Team', start: { dateTime: '2024-10-14T10:00:00Z' }, end: { dateTime: '2024-10-14T11:00:00Z' }, color: '#4285F4', }, ]}

); }

howljs commented 1 week ago

您需要通过 onDragCreateEventEnd 属性来更新事件列表。如果您想在创建完成后继续编辑,请使用 selectedEvent。

https://github.com/user-attachments/assets/822d7557-99c2-4642-ad5c-c5f0760797c4

https://github.com/user-attachments/assets/4a8c9168-59aa-4562-8863-7fe43ee9d826

JiuMengDz commented 1 week ago

原来如此,明白了 谢谢!

JiuMengDz commented 1 week ago

你好 我测试后发现依然无法出现这个拖动选中效果 image

但是,拖动完成后会创建最新的event 只是这个过程没有

JiuMengDz commented 1 week ago

找到原因了 是我的模拟器问题

我使用的是 Pixel_3a_XL_API_23(AVD) - 6.0

然后我更换为真机 Redmi K20 Pro Premium Edition - 11 来运行后就正常了

SwikarBhattarai commented 1 week ago

Right now, if we hold and start dragging then only onDragCreateEventEnd function is getting called. But if i want to create an event by just long press and removing my finger from the screen , then that function is not getting called.