Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

Merge [Readonly] Calendar API #1384

Closed
wants to merge 17 commits into from
Closed

Merge [Readonly] Calendar API #1384

wants to merge 17 commits into from

Conversation

mattleibow
Copy link
Contributor

@mattleibow mattleibow commented Sep 17, 2020

Description of Change

Final tweaks for #1010 so we can merge it into the next version.

Calendars API for reading calendar/event information seamlessly across uwp, iOS and Android
(Issue #996)

API

API

public static class Calendars
{
    // Retrieve all calendars for device
    public static Task<IEnumerable<Calendar>> GetCalendarsAsync();

    // Retrieve the calendar for a specific ID
    public static Task<Calendar> GetCalendarAsync(string calendarId);

    // Retrieve all events for a specified range/calendar
    // Null values for parameters will result in default values being used: 
    //     calendarId will return events from all calendars
    //     startDate will default to the Now
    //     endDate will default to startDate+14 days
    public static Task<IEnumerable<CalendarEvent>> GetEventsAsync(string calendarId = null, DateTimeOffset? startDate = null, DateTimeOffset? endDate = null);

    // Gets more detailed information about a specific event by the event ID
    public static Task<CalendarEvent> GetEventAsync(string eventId);
}

Types

public class Calendar
{
    public Calendar();
    public Calendar(string id, string name);

    public string Id { get; set; }
    public string Name { get; set; }
}

public class CalendarEvent
{
    public CalendarEvent();
    public CalendarEvent(string id, string calendarId, string title);

    public string Id { get; set; }
    public string CalendarId { get; set; }
    public string Title { get; set; }
    public string Description { get; set; }
    public string Location { get; set; }
    public bool AllDay { get; set; }
    public DateTimeOffset StartDate { get; set; }
    public DateTimeOffset EndDate { get; set; }
    public TimeSpan Duration { get; } // if this is AllDay, then the Duration will be 1 day
    public IEnumerable<CalendarEventAttendee> Attendees { get; set; }
}

public class CalendarEventAttendee
{
    public CalendarEventAttendee();
    public CalendarEventAttendee(string name, string email);

    public string Name { get; set; }
    public string Email { get; set; }
}

Scenarios

  • User wants to see upcoming events.
  • User wants to see who is attending an upcoming event.
  • User wants to know when they will be free.

Platform Compatibility

  • Target Frameworks:
    • iOS: Support on iOS for the API
    • macOS: Support on iOS for the API
    • Android: Support on Android for the API
    • UWP: Support on UWP for the API
    • Tizen: Pending a PR from @rookiejava

Backward Compatibility

Contributors

@ScottBTR
@mkieres
@nickrandolph

ScottBTR and others added 4 commits December 25, 2019 08:46
* Calendar Read-Only API

* Return exceptions that match test case System.NotImplementedException --> Xamarin.Essentials.NotImplementedInReferenceAssemblyException (#45)
@mattleibow mattleibow added this to the 1.7.0 milestone Sep 17, 2020
@mattleibow mattleibow marked this pull request as draft September 17, 2020 14:35
@mattleibow mattleibow marked this pull request as ready for review September 18, 2020 21:13
@mattleibow mattleibow changed the title Merge Calendar API Merge [Readonly] Calendar API Sep 18, 2020
@mattleibow mattleibow marked this pull request as draft September 18, 2020 22:46
@mattleibow
Copy link
Contributor Author

Still in DRAFT to wait for Tizen implementation.

Copy link
Contributor

@Mrnikbobjeff Mrnikbobjeff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor things I noticed

var events = await Calendars.GetEventsAsync(
SelectedCalendar?.Id,
StartDateTime,
EndDateTime);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ConfigureAwait(false) could be added here

return Task.FromResult(ToEvent(calendarEvent));
}

static IEnumerable<Calendar> ToCalendars(IEnumerable<EKCalendar> native)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used only, a simple select could replace this method

Name = calendar.Title
};

static IEnumerable<CalendarEvent> ToEvents(IEnumerable<EKEvent> native)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also used once and could also be a select

: new List<CalendarEventAttendee>()
};

static IEnumerable<CalendarEventAttendee> ToAttendees(IEnumerable<EKParticipant> inviteList)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above but this is more optional here as we do not delegate construction further down the line

public TimeSpan Duration =>
AllDay ? TimeSpan.FromDays(1) : EndDate - StartDate;

public IEnumerable<CalendarEventAttendee> Attendees { get; set; }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be a list as well, all platforms return lists.

@jamesmontemagno jamesmontemagno modified the milestones: 1.7.0, .NET MAUI Jun 9, 2021
@jfversluis
Copy link
Member

@mattleibow seems like this is more something for .NET MAUI at this point? Should we close it here and make sure to get it on the list for .NET MAUI?

@jfversluis
Copy link
Member

Alright closing this here. If anyone is still interested in this, please open an issue on the .NET MAUI repo, thanks!

@jfversluis jfversluis closed this Apr 5, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants