Skip to content

Commit

Permalink
Amend changes set by PR for Issues - #1 #2 #3
Browse files Browse the repository at this point in the history
  • Loading branch information
ScottBTR committed Jan 22, 2020
1 parent 15160dc commit 63389dd
Show file tree
Hide file tree
Showing 8 changed files with 20 additions and 49 deletions.
20 changes: 10 additions & 10 deletions Xamarin.Essentials/Calendar/Calendar.android.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ namespace Xamarin.Essentials
{
public static partial class Calendar
{
public static bool PlatformIsSupported => true;
static bool PlatformIsSupported => true;

public static async Task<IReadOnlyList<ICalendar>> PlatformGetCalendarsAsync()
static async Task<IReadOnlyList<ICalendar>> PlatformGetCalendarsAsync()
{
await Permissions.RequireAsync(PermissionType.CalendarRead);

Expand All @@ -28,29 +28,29 @@ public static async Task<IReadOnlyList<ICalendar>> PlatformGetCalendarsAsync()
{
Id = cur.GetString(calendarsProjection.IndexOf(CalendarContract.Calendars.InterfaceConsts.Id)),
Name = cur.GetString(calendarsProjection.IndexOf(CalendarContract.Calendars.InterfaceConsts.CalendarDisplayName)),
IsReadOnly = IsCalendarReadOnly(cur.GetInt(calendarsProjection.IndexOf(CalendarContract.Calendars.InterfaceConsts.CalendarAccessLevel)))
IsReadOnly = IsCalendarReadOnly((CalendarAccess)cur.GetInt(calendarsProjection.IndexOf(CalendarContract.Calendars.InterfaceConsts.CalendarAccessLevel)))
});
}

return calendars.AsReadOnly();
}

static bool IsCalendarReadOnly(int accessLevel)
static bool IsCalendarReadOnly(CalendarAccess accessLevel)
{
switch (accessLevel)
{
case (int)CalendarAccess.AccessContributor:
case (int)CalendarAccess.AccessRoot:
case (int)CalendarAccess.AccessOwner:
case (int)CalendarAccess.AccessEditor:
case CalendarAccess.AccessContributor:
case CalendarAccess.AccessRoot:
case CalendarAccess.AccessOwner:
case CalendarAccess.AccessEditor:
return false;
default:
return true;
}
}

public static async Task PlatformRequestCalendarReadAccess() => await Permissions.RequireAsync(PermissionType.CalendarRead);
static async Task PlatformRequestCalendarReadAccess() => await Permissions.RequireAsync(PermissionType.CalendarRead);

public static async Task PlatformRequestCalendarWriteAccess() => await Permissions.RequireAsync(PermissionType.CalendarWrite);
static async Task PlatformRequestCalendarWriteAccess() => await Permissions.RequireAsync(PermissionType.CalendarWrite);
}
}
17 changes: 4 additions & 13 deletions Xamarin.Essentials/Calendar/Calendar.ios.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
using System.Collections.Generic;
using System.Threading.Tasks;
using EventKit;
using Foundation;
using UIKit;

namespace Xamarin.Essentials
{
public static partial class Calendar
{
public static bool PlatformIsSupported => true;
static bool PlatformIsSupported => true;

public static async Task<IReadOnlyList<ICalendar>> PlatformGetCalendarsAsync()
static async Task<IReadOnlyList<ICalendar>> PlatformGetCalendarsAsync()
{
await Permissions.RequireAsync(PermissionType.CalendarRead);

Expand All @@ -25,23 +22,17 @@ public static async Task<IReadOnlyList<ICalendar>> PlatformGetCalendarsAsync()
Name = t.Title,
IsReadOnly = !t.AllowsContentModifications
});
/*
To get Events:
var mySavedEvent = CalendarRequest.Instance.EventFromIdentifier(t.CalendarIdentifier);
*/
}
return calendarList.AsReadOnly();
}

public static async Task PlatformRequestCalendarReadAccess()
static async Task PlatformRequestCalendarReadAccess()
{
await Permissions.RequireAsync(PermissionType.CalendarRead);
await Permissions.RequireAsync(PermissionType.CalendarWrite);
}

public static async Task PlatformRequestCalendarWriteAccess()
static async Task PlatformRequestCalendarWriteAccess()
{
await Permissions.RequireAsync(PermissionType.CalendarRead);
await Permissions.RequireAsync(PermissionType.CalendarWrite);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ namespace Xamarin.Essentials
{
public static partial class Calendar
{
public static bool PlatformIsSupported => false;
static bool PlatformIsSupported => false;

public static Task<IReadOnlyList<ICalendar>> PlatformGetCalendarsAsync() => throw new NotImplementedException();
static Task<IReadOnlyList<ICalendar>> PlatformGetCalendarsAsync() => throw new NotImplementedException();

public static Task PlatformRequestCalendarReadAccess() => throw new NotImplementedException();
static Task PlatformRequestCalendarReadAccess() => throw new NotImplementedException();

public static Task PlatformRequestCalendarWriteAccess() => throw new NotImplementedException();
static Task PlatformRequestCalendarWriteAccess() => throw new NotImplementedException();
}
}
6 changes: 2 additions & 4 deletions Xamarin.Essentials/Calendar/Calendar.shared.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
using System;
using System.Collections.Generic;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Xamarin.Essentials
{
public static partial class Calendar
{
// public static List<Calendar> CalendarList { get; set; }
public static bool IsSupported()
public static bool IsSupported
=> PlatformIsSupported;

public static Task<IReadOnlyList<ICalendar>> GetCalendarsAsync()
Expand Down
2 changes: 0 additions & 2 deletions Xamarin.Essentials/Calendar/CalendarRequest.ios.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;
using EventKit;

namespace Xamarin.Essentials
Expand Down
6 changes: 0 additions & 6 deletions Xamarin.Essentials/GlobalSuppressions.cs

This file was deleted.

6 changes: 0 additions & 6 deletions Xamarin.Essentials/GlobalSuppressions2.cs

This file was deleted.

4 changes: 0 additions & 4 deletions Xamarin.Essentials/Types/DeviceCalendar.shared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ public class DeviceCalendar : ICalendar
public string Name { get; set; }

public bool IsReadOnly { get; set; }

// public List<Event> EventList { get; set; }
}

public interface ICalendar
Expand Down Expand Up @@ -84,8 +82,6 @@ public class Attendee
public string Name { get; set; }

public string Email { get; set; }

// public IAttendeeDetails AttendeeDetails => DeviceSpecificAttendeeDetails;
}

public interface IAttendeeDetails
Expand Down

0 comments on commit 63389dd

Please sign in to comment.