syncfusion / flutter-widgets

Syncfusion Flutter widgets libraries include high quality UI widgets and file-format packages to help you create rich, high-quality applications for iOS, Android, and web from a single code base.
1.44k stars 672 forks source link

Get the coordinates in CalendarTapDetails and CalendarLongPressDetails #1833

Open x-ji opened 2 weeks ago

x-ji commented 2 weeks ago

Use case

I would like to trigger different actions based on where exactly the user tapped on the calendar cell. For example, tapping on the left half of the cell should create a different type of event by default compared with tapping on the right half.

Proposal

With JS events I can get the exact coordinates where the click happened and e.g. compare it to the width of the whole calendar component to understand whether the click happened on the left part of the cell or the right part. I see that CalendarTapDetails's properties only contain the targetElement but not the

PreethikaSelvam commented 2 weeks ago

Hi @x-ji,

We have analyzed your query and would like to inform you, that in SfCalendar, the onTap callback triggers whenever the calendar elements are tapped on view. You can get the tapped date, appointments, and element details when the tapped action is performed on the element available in the CalendarTapDetails, and the onLongPress callback triggers whenever the calendar elements are long-pressed on view. You can get the long-pressed date, appointments, and element details when the tapped action is performed on the element available in the CalendarLongPressDetails. So, you can use this callback to differentiate the tap and create a different event. We have shared a UG documentation for your reference below.

UG Links:

https://help.syncfusion.com/flutter/calendar/callbacks#calendar-tap-callback

https://help.syncfusion.com/flutter/calendar/callbacks#long-press-callback

Please let us know if you need any further assistance.

Regards,

Preethika Selvam.

x-ji commented 2 weeks ago

Hi @PreethikaSelvam thanks for the response. I see that CalendarTapDetails has the following properties:

appointmentsList? The collection of appointments that return from the date.

dateDateTime? The date that return from the view.

hashCodeint The hash code for this object.

resourceCalendarResource? The resource associated with the calendar cell in timeline views.

runtimeTypeType A representation of the runtime type of the object.

targetElementCalendarElement The element that return from the view.

None of which gives me the precise coordinates within the targetElement this tap or long press took place, which is what I would like to make use of (so that I can distinguish whether the tap took place on the left half or right half of the element). On the web with HTML and Javascript, this is usually available for example within the onClick event.

Does this make sense?

PreethikaSelvam commented 1 week ago

Hi @x-ji,

Your requirement can only be achieved by wrapping two GestureDetector widgets in Expanded within the Row in the monthCellBuilder. However, due to the interaction not being passed to the builders, we are unable to achieve it at this time. We have already logged feature request for it in our feedback portal. We will prioritize the features of every release based on demand and priority. So, this feature will be available in any of our upcoming releases. You can also track the status of the feature with the feedback below.

FR Link: https://www.syncfusion.com/feedback/46931/providing-a-gesture-detector-support-for-builders-in-the-flutter-calendar

If you have any additional specifications or suggestions for this feature request, please feel free to leave them in the comments section of the feedback link. This will help us to understand how you would like to use it and how we can improve it.

Regards,

Preethika Selvam.

x-ji commented 1 week ago

Thanks for the update @PreethikaSelvam . I'll keep an eye on it.