SimformSolutionsPvtLtd / flutter_calendar_view

A Flutter package allows you to easily implement all calendar UI and calendar event functionality. 👌🔝🎉
https://pub.dev/packages/calendar_view
MIT License
411 stars 250 forks source link

Weekview shows multi day events incorrect #23

Open rickdijk opened 2 years ago

rickdijk commented 2 years ago

I have an event created for multiple days with for example starttime 1pm on Saturday and endtime 2pm on the Monday after.

Code:

(
          event: booking,
          title: StringExtensions.toInitials(
            booking.user!.firstName,
            booking.user!.lastName,
          ),
          date: booking.startDateTime,
          startTime: booking.startDateTime,
          endTime: booking.endDateTime,
          endDate: booking.endDateTime,
          color: Color.fromARGB(255, 227, 83, 76),
)

It shows up like this:

image image

What am I missing?

PRBaraiya commented 2 years ago

Hello @rickdijk, as for current implementation it is the expected behaviour. As of now in multiple day events, startTime and endTime is being considered as timespan over a single date.

So, In this case it will display event tile with 1 hr timespan (1pm - 2pm) from saturday to monday.

vradchuk commented 2 years ago

With version 0.0.4 it multiday events doesn't work (WeekView) Here is my code:

return CalendarEventData<Schedule>(
      color: AppColors.availabilityGreen.withOpacity(0.2),
      title: DateFormatter.formatTime(schedule.start).toLowerCase(),
      date: schedule.start,
      startTime: schedule.start,
      endTime: schedule.end,
      event: schedule,
    );

Here is an error:

Assertion fail for event: 
{date: 2022-04-05 13:00:00.000Z, startTime: 2022-04-05 13:00:00.000Z, endTime: 2022-04-06 12:00:00.000Z, event: Schedule(35736, ScheduleRepeat(438, 1264, [], 2022-04-05 14:25:23.787389, 2022-04-05 14:25:23.787389), false, 2022-04-05 13:00:00.000Z, 2022-04-06 12:00:00.000Z), title: 1:00 pm, description: , endDate: 2022-04-05 13:00:00.000Z}
startDate must be less than endDate.
This error occurs when you does not provide startDate or endDate in CalendarEventDate or provided endDate occurs before startDate.
'package:calendar_view[/src/event_arrangers/side_event_arranger.dart]()':
package:calendar_view/…/event_arrangers/side_event_arranger.dart:1
Failed assertion: line 130 pos 11: '!(endTime.getTotalMinutes <= startTime.getTotalMinutes)'

What I missed?

PRBaraiya commented 2 years ago

@vradchuk Here, you are providing startTime as 13:00 and endTime as 12:00. That's causing the problem.

Note that in startTime and endTime only time is being considered. so, In your case endTime(12:00) will occur before startTime(13:00) that's why it is throwing assertion.

vradchuk commented 2 years ago

@PRBaraiya Yes, the endTime is less than startTime. But endTime is tomorrow. How can I set the event that starts, for example, 2022-04-05 14:00 and ends 2022-04-06 10:00? Is it possible with the current WeekView implementation?

PRBaraiya commented 2 years ago

@vradchuk No, as of not it does not support that functionality by default. But if you want you can implement EventArranger in your code. and provide it as eventArranger argument.

EvenrArranger defines how an event will be displayed based on timespan in DayView and WeekView.

here you can find more about it

vradchuk commented 2 years ago

@PRBaraiya I thought about EventAranger, but it's not suitable in my case. So, I decided to split up multi-day events into single ones. Thanks for help.

edoliantesjr commented 2 years ago

how did you split the multiday event?

Saliim17 commented 1 year ago

image how can u select the day in the timeline? (sorry about asking this in a different issue)

ParthBaraiya commented 1 year ago

Similar issue #220

dkobia commented 9 months ago

The solution for the moment is to break events that span more than a day into multiple events.