-
Notifications
You must be signed in to change notification settings - Fork 24
add MAUI support #85
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
add MAUI support #85
Changes from all commits
ee27626
42bbd80
2d16528
369d445
7e4e9d1
54c006d
019eb5a
c0d4ab9
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| using System.Linq; | ||
| using System.Threading.Tasks; | ||
| using Calendar = Plugin.Calendars.Abstractions.Calendar; | ||
| using Application = Android.App.Application; | ||
|
|
||
| #nullable enable | ||
|
|
||
|
|
@@ -34,9 +35,9 @@ public class CalendarsImplementation : ICalendars | |
| CalendarContract.Calendars.InterfaceConsts.CalendarAccessLevel, | ||
| CalendarContract.Calendars.InterfaceConsts.AccountType | ||
| }; | ||
|
|
||
| #endregion | ||
|
|
||
| #region Properties | ||
|
|
||
| /// <summary> | ||
|
|
@@ -113,7 +114,7 @@ public Task<IList<Calendar>> GetCalendarsAsync() => Task.Run(() => | |
| _calendarsProjection); | ||
|
|
||
| var calendar = SingleItemFromCursor(cursor, () => GetCalendar(cursor)); | ||
|
|
||
| return calendar; | ||
| }); | ||
| } | ||
|
|
@@ -157,7 +158,7 @@ public async Task<IList<CalendarEvent>> GetEventsAsync(Calendar calendar, DateTi | |
| ContentUris.AppendId(eventsUriBuilder, DateConversions.GetDateAsAndroidMS(end)); | ||
| var eventsUri = eventsUriBuilder?.Build(); | ||
|
|
||
| return await Task.Run(() => | ||
| return await Task.Run(() => | ||
| { | ||
| var cursor = Query(eventsUri, eventsProjection, | ||
| string.Format("{0} = {1}", CalendarContract.Events.InterfaceConsts.CalendarId, calendar.ExternalID), | ||
|
|
@@ -416,14 +417,14 @@ public async Task AddEventReminderAsync(CalendarEvent calendarEvent, CalendarEve | |
| throw new ArgumentException("Missing calendar event identifier", nameof(calendarEvent)); | ||
| } | ||
|
|
||
| // Verify calendar event exists | ||
| // Verify calendar event exists | ||
| var existingAppt = await GetEventByIdAsync(calendarEvent.ExternalID).ConfigureAwait(false); | ||
|
|
||
| if (existingAppt == null) | ||
| { | ||
| throw new ArgumentException("Specified calendar event not found on device"); | ||
| } | ||
|
|
||
| await Task.Run(() => | ||
| { | ||
| if (IsEventRecurring(calendarEvent.ExternalID)) | ||
|
|
@@ -456,7 +457,7 @@ public async Task<bool> DeleteCalendarAsync(Calendar calendar) | |
| throw new ArgumentException("Cannot delete calendar (probably because it's non-local)", nameof(calendar)); | ||
| } | ||
|
|
||
| return await Task.Run(() => Delete(_calendarsUri, long.Parse(calendar.ExternalID))).ConfigureAwait(false); | ||
| return await Task.Run(() => Delete(_calendarsUri, long.Parse(calendar.ExternalID ?? String.Empty))).ConfigureAwait(false); | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, possibly this should just return false if
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This was just a "dirty fix" for a more-or-less wrong nullable-detection, as it will never get to this place if the id would be null (except maybe some race-conditions). Because Maybe a check at the beginning of that method would make sense?
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A check at the beginning makes sense to me. And yeah I understand and agree with your reasoning but the "dirty fix" still looks a bit odd to me |
||
| } | ||
|
|
||
| /// <summary> | ||
|
|
@@ -742,7 +743,7 @@ private static Calendar GetCalendar(ICursor cursor) | |
| AccountName = cursor.GetString(CalendarContract.Calendars.InterfaceConsts.AccountName) | ||
| }; | ||
| } | ||
|
|
||
| private static ICursor Query(Android.Net.Uri? uri, string[] projection, string? selection = null, | ||
| string[]? selectionArgs = null, string? sortOrder = null) | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| <Project Sdk="Microsoft.NET.Sdk"> | ||
|
|
||
| <PropertyGroup> | ||
| <TargetFrameworks>net6.0;net6.0-android;net6.0-ios;net6.0-maccatalyst</TargetFrameworks> | ||
| <TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows')) and '$(MSBuildRuntimeType)' == 'Full'">$(TargetFrameworks);net6.0-windows10.0.19041</TargetFrameworks> | ||
| <UseMaui>true</UseMaui> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not needed (only adds unnecessary dependencies)
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What part is not needed?
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, AFAIK without that the UWP/WinSDK is missing? I will try...
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting, it compiled for me when I removed Maybe that's why current MAUI template also has this in it's project file: <ItemGroup Condition="$(TargetFramework.Contains('-windows'))">
<!-- Required - WinUI does not yet have buildTransitive for everything -->
<PackageReference Include="Microsoft.WindowsAppSDK" Version="1.0.0" />
<PackageReference Include="Microsoft.Graphics.Win2D" Version="1.0.0.30" />
</ItemGroup>
<PropertyGroup Condition="$(TargetFramework.Contains('-windows'))">
<OutputType>WinExe</OutputType>
<RuntimeIdentifier>win10-x64</RuntimeIdentifier>
</PropertyGroup>
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, interesting - will try again on my side (incl. iOS tests) and report back...
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, any news on that?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, sorry - had no time lately 😑 |
||
| <SingleProject>true</SingleProject> | ||
| <ImplicitUsings>enable</ImplicitUsings> | ||
| <GeneratePackageOnBuild>False</GeneratePackageOnBuild> | ||
| <GenerateDocumentationFile>True</GenerateDocumentationFile> | ||
|
|
||
| <SupportedOSPlatformVersion Condition="$(TargetFramework.Contains(-ios))">14.2</SupportedOSPlatformVersion> | ||
| <SupportedOSPlatformVersion Condition="$(TargetFramework.Contains(-maccatalyst))">14.0</SupportedOSPlatformVersion> | ||
| <SupportedOSPlatformVersion Condition="$(TargetFramework.Contains(-android))">21.0</SupportedOSPlatformVersion> | ||
| <SupportedOSPlatformVersion Condition="$(TargetFramework.Contains('-windows'))">10.0.17763.0</SupportedOSPlatformVersion> | ||
| <TargetPlatformMinVersion Condition="$(TargetFramework.Contains('-windows'))">10.0.17763.0</TargetPlatformMinVersion> | ||
| </PropertyGroup> | ||
|
|
||
| <ItemGroup> | ||
| <Compile Include="..\Calendars.Plugin.Abstractions\Calendar.cs" Link="Calendar.cs" /> | ||
| <Compile Include="..\Calendars.Plugin.Abstractions\CalendarEvent.cs" Link="CalendarEvent.cs" /> | ||
| <Compile Include="..\Calendars.Plugin.Abstractions\CalendarEventReminder.cs" Link="CalendarEventReminder.cs" /> | ||
| <Compile Include="..\Calendars.Plugin.Abstractions\ICalendars.cs" Link="ICalendars.cs" /> | ||
| <Compile Include="..\Calendars.Plugin.Abstractions\ICalendarsExtensions.cs" Link="ICalendarsExtensions.cs" /> | ||
| <Compile Include="..\Calendars.Plugin.Abstractions\PlatformException.cs" Link="PlatformException.cs" /> | ||
|
|
||
| <Compile Include="..\Calendars.Plugin\CrossCalendars.cs" Link="CrossCalendars.cs" /> | ||
| </ItemGroup> | ||
|
|
||
| <ItemGroup Condition="$(TargetFramework.Contains(-android))"> | ||
| <Compile Include="..\Calendars.Plugin.Android\CalendarEventReminderExtensions.cs" Link="Platforms\Android\CalendarEventReminderExtensions.cs" /> | ||
| <Compile Include="..\Calendars.Plugin.Android\CalendarsImplementation.cs" Link="Platforms\Android\CalendarsImplementation.cs" /> | ||
| <Compile Include="..\Calendars.Plugin.Android\CursorExtensions.cs" Link="Platforms\Android\CursorExtensions.cs" /> | ||
| <Compile Include="..\Calendars.Plugin.Android\DateConversions.cs" Link="Platforms\Android\DateConversions.cs" /> | ||
| <Compile Include="..\Calendars.Plugin.Android\ReminderMethodExtensions.cs" Link="Platforms\Android\ReminderMethodExtensions.cs" /> | ||
| </ItemGroup> | ||
| <ItemGroup Condition="$(TargetFramework.Contains(-ios))"> | ||
| <Compile Include="..\Calendars.Plugin.iOSUnified\CalendarEventReminderExtensions.cs" Link="Platforms\iOS\CalendarEventReminderExtensions.cs" /> | ||
| <Compile Include="..\Calendars.Plugin.iOSUnified\CalendarsImplementation.cs" Link="Platforms\iOS\CalendarsImplementation.cs" /> | ||
| <Compile Include="..\Calendars.Plugin.iOSUnified\ColorConversion.cs" Link="Platforms\iOS\ColorConversion.cs" /> | ||
| <Compile Include="..\Calendars.Plugin.iOSUnified\DateConversionExtensions.cs" Link="Platforms\iOS\DateConversionExtensions.cs" /> | ||
| <Compile Include="..\Calendars.Plugin.iOSUnified\EKAlarmExtensions.cs" Link="Platforms\iOS\EKAlarmExtensions.cs" /> | ||
| <Compile Include="..\Calendars.Plugin.iOSUnified\EKCalendarExtensions.cs" Link="Platforms\iOS\EKCalendarExtensions.cs" /> | ||
| <Compile Include="..\Calendars.Plugin.iOSUnified\EKEventExtensions.cs" Link="Platforms\iOS\EKEventExtensions.cs" /> | ||
| </ItemGroup> | ||
| <ItemGroup Condition="$(TargetFramework.Contains(-maccatalyst))"> | ||
| <Compile Include="..\Calendars.Plugin.iOSUnified\CalendarEventReminderExtensions.cs" Link="Platforms\MacCatalyst\CalendarEventReminderExtensions.cs" /> | ||
| <Compile Include="..\Calendars.Plugin.iOSUnified\CalendarsImplementation.cs" Link="Platforms\MacCatalyst\CalendarsImplementation.cs" /> | ||
| <Compile Include="..\Calendars.Plugin.iOSUnified\ColorConversion.cs" Link="Platforms\MacCatalyst\ColorConversion.cs" /> | ||
| <Compile Include="..\Calendars.Plugin.iOSUnified\DateConversionExtensions.cs" Link="Platforms\MacCatalyst\DateConversionExtensions.cs" /> | ||
| <Compile Include="..\Calendars.Plugin.iOSUnified\EKAlarmExtensions.cs" Link="Platforms\MacCatalyst\EKAlarmExtensions.cs" /> | ||
| <Compile Include="..\Calendars.Plugin.iOSUnified\EKCalendarExtensions.cs" Link="Platforms\MacCatalyst\EKCalendarExtensions.cs" /> | ||
| <Compile Include="..\Calendars.Plugin.iOSUnified\EKEventExtensions.cs" Link="Platforms\MacCatalyst\EKEventExtensions.cs" /> | ||
| </ItemGroup> | ||
| <ItemGroup Condition="$(TargetFramework.Contains('-windows'))"> | ||
| <Compile Include="..\Calendars.Plugin.UWP\AppointmentCalendarExtensions.cs" Link="Platforms\Windows\AppointmentCalendarExtensions.cs" /> | ||
| <Compile Include="..\Calendars.Plugin.UWP\AppointmentExtensions.cs" Link="Platforms\Windows\AppointmentExtensions.cs" /> | ||
| <Compile Include="..\Calendars.Plugin.UWP\CalendarsImplementation.cs" Link="Platforms\Windows\CalendarsImplementation.cs" /> | ||
| <Compile Include="..\Calendars.Plugin.UWP\IAsyncActionExtensions.cs" Link="Platforms\Windows\IAsyncActionExtensions.cs" /> | ||
| <Compile Include="..\Calendars.Plugin.UWP\IAsyncOperationExtensions.cs" Link="Platforms\Windows\IAsyncOperationExtensions.cs" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you would think it's that easy, but I think AppVeyor will overwrite this... I'll have to look into that again if going this route
(but why the 11?)- nevermind, I see the note about MAUI Preview 11, makes sense now