builttoroam / device_calendar

A cross platform plugin for modifying calendars on the user's device
https://pub.dev/packages/device_calendar
BSD 3-Clause "New" or "Revised" License
259 stars 258 forks source link

Spanning all day events can't be saved properly in iOS #451

Closed SuperKrallan closed 1 year ago

SuperKrallan commented 1 year ago

Saving an event with allDay = true and where end date are some days after start date works fine for android, but the same flutter code run on iOS results in change in the end date to the same as the start date.

in the file SwiftDeviceCalendarPlugin.swift line 818-820 you see this:

if (isAllDay) { ekEvent!.endDate = startDate } else { ekEvent!.endDate = endDate_

...and that if statement makes very little sense to me. If I remove the first part it works as it should...

To Reproduce Save any "all day" event spanning more than one day will result in this error in iOS, but not on Android.

Expected behavior Same as on android and in all other calendar apps I have seen, that the all day event is present on all days in the time span.

Device(s) tested

Flutter doctor flutter doctor Doctor summary (to see all details, run flutter doctor -v): [✓] Flutter (Channel beta, 3.4.0-34.1.pre, on macOS 12.6 21G115 darwin-arm64, locale sv-SE) [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3) [✓] Xcode - develop for iOS and macOS (Xcode 14.0.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.3) [✓] Connected device (4 available) [✓] HTTP Host Availability

• No issues found!

Additional context Thanks for a great plug in!!

IVLIVS-III commented 1 year ago

This should be fixed by https://github.com/builttoroam/device_calendar/pull/450.

In case I misunderstood something here, could you please elaborate where it goes wrong?

SuperKrallan commented 1 year ago

Is the event correctly saved to the calendar, but importing it again results in the issue? (this should be fixed by the PR above) Or is such an event not even saved correctly to the calendar?

It is the saving in iOS, saving in android is ok. Importing an all day event spanning multiple days works just fine.

It is in the file SwiftDeviceCalendarPlugin.swift where it seems to go wrong in the method...

private func createOrUpdateEvent( call: FlutterMethodCall, result: @escaping FlutterResult) {

where the lines...

_if (isAllDay) { ekEvent!.endDate = startDate } else { ekEvent!.endDate = endDate__

are setting the end date to the start date.

IVLIVS-III commented 1 year ago

Have you looked at the changes made in this PR?

I just double checked and as far as I can tell, exactly the lines you pointed out are changed. And pretty much in the way you suggested.

SuperKrallan commented 1 year ago

_Have you looked at the changes made in https://github.com/builttoroam/device_calendar/pull/450?_

No, I did not go into the code, but I have done now, and I agree - it looks good! I am a total newbee when it comes to using github, I don't even know what a PR is... So please apologise if I confuse things or ask stupid questions.

Will this then come in the next release of device_calendar? Or can I get a beta (pre release = PR??) somewhere?

IVLIVS-III commented 1 year ago

Ohh right, sry for using acronyms. PR stands for pull request, which is a collection of commits that some developer wants to merge into (i.e. add to) the main codebase.

This will most likely come in the next release of device_calendar. This release will most likely be preceded by an official pre-release published to pub.dev two weeks earlier.

You can also specify a specific Github repository in your pubspec.yaml file as dependency. That way you could use the changes starting now. See the flutter docs on how this would be done. You would probably want to use the develop branch from OleksandraFedotova. This is linked at the very top of #450.

If you have any trouble, just reply here and I can try to help.

SuperKrallan commented 1 year ago

Ah, thanks. Great with the link on how to add specific repositories. Didn't know that. Thanks a lot!

tovidd commented 1 year ago

I faced version solving failed because depends on timezone ^0.9.0, when are you planning to update the version ?

IVLIVS-III commented 1 year ago

@tovidd the version has already been updated on the develop branch (see https://github.com/builttoroam/device_calendar/pull/440).

https://github.com/builttoroam/device_calendar/pull/445 tracks the status of the new version to be released to pub.dev.

IVLIVS-III commented 1 year ago

this should be fixed since version 4.3.0. @SuperKrallan could you test if the issue still exists on your side?

SuperKrallan commented 1 year ago

With the 4.3.0 (and the required timezone: ^0.9.0) it now works great! Tested on both iPhone simulator and my real iPhone. Thanks a lot! Much appreciated!