Skip to content

.NET MAUI - Add Mac Catalyst platform #49

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

Merged
merged 6 commits into from
Jun 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dotnet-maui/DittoMauiTasksApp/DittoMauiTasksApp.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net9.0-android;net9.0-ios;</TargetFrameworks>
<TargetFrameworks>net9.0-android;net9.0-ios;net9.0-maccatalyst</TargetFrameworks>
<OutputType>Exe</OutputType>
<RootNamespace>DittoMauiTasksApp</RootNamespace>
<UseMaui>true</UseMaui>
Expand Down Expand Up @@ -36,7 +36,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.1" />
<PackageReference Include="Ditto" Version="4.10.0" />
<PackageReference Include="Ditto" Version="4.11.0" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using Foundation;

namespace DittoMauiTasksApp;

[Register("AppDelegate")]
public class AppDelegate : MauiUIApplicationDelegate
{
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
}
40 changes: 40 additions & 0 deletions dotnet-maui/DittoMauiTasksApp/Platforms/MacCatalyst/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>UIDeviceFamily</key>
<array>
<integer>1</integer>
<integer>2</integer>
</array>
<key>UIRequiredDeviceCapabilities</key>
<array>
<string>arm64</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
<string>UIInterfaceOrientationPortrait</string>
<string>UIInterfaceOrientationPortraitUpsideDown</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/appicon.appiconset</string>
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Uses Bluetooth to connect and sync with nearby devices</string>
<key>NSBluetoothPeripheralUsageDescription</key>
<string>Uses Bluetooth to connect and sync with nearby devices</string>
<key>NSLocalNetworkUsageDescription</key>
<string>Uses WiFi to connect and sync with nearby devices</string>
<key>NSBonjourServices</key>
<array>
<string>_http-alt._tcp.</string>
</array>
</dict>
</plist>
15 changes: 15 additions & 0 deletions dotnet-maui/DittoMauiTasksApp/Platforms/MacCatalyst/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using ObjCRuntime;
using UIKit;

namespace DittoMauiTasksApp;

public class Program
{
// This is the main entry point of the application.
static void Main(string[] args)
{
// if you want to use a different Application Delegate class from "AppDelegate"
// you can specify it here.
UIApplication.Main(args, null, typeof(AppDelegate));
}
}
28 changes: 0 additions & 28 deletions dotnet-maui/DittoMauiTasksApp/Utils/BluetoothPermissions.cs

This file was deleted.

50 changes: 0 additions & 50 deletions dotnet-maui/DittoMauiTasksApp/Utils/PermissionHelper.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public TasksPageviewModel(
this.popupService = popupService;
this.logger = logger;

PermissionHelper.CheckPermissions().ContinueWith(async t =>
DittoSyncPermissions.RequestPermissionsAsync().ContinueWith(async t =>
{
try
{
Expand Down
91 changes: 50 additions & 41 deletions dotnet-maui/DittoMauiTasksApp/Views/TasksPage.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
Command="{Binding AddTaskCommand}"/>
</ContentPage.ToolbarItems>

<StackLayout>
<Grid
RowDefinitions="Auto, *">
<VerticalStackLayout
Margin="16, 5">
<HorizontalStackLayout
Expand All @@ -30,54 +31,62 @@
FontSize="Micro"/>
</VerticalStackLayout>

<ListView
x:Name="listView"
<CollectionView
x:Name="collectionView"
Grid.Row="1"
ItemsSource="{Binding Tasks}"
SelectionMode="None"
CachingStrategy="RecycleElementAndDataTemplate">
<ListView.ItemTemplate>
SelectionMode="None">
<CollectionView.ItemTemplate>
<DataTemplate>
<ViewCell>
<ViewCell.ContextActions>
<MenuItem
Text="Delete"
Command="{Binding Source={x:Reference listView}, Path=BindingContext.DeleteTaskCommand}"
CommandParameter="{Binding}"
IsDestructive="True"/>
<MenuItem
Text="Edit"
Command="{Binding Source={x:Reference listView}, Path=BindingContext.EditTaskCommand}"
CommandParameter="{Binding}"/>
</ViewCell.ContextActions>
<SwipeView>
<SwipeView.RightItems>
<SwipeItems>
<SwipeItem
Text="Delete"
BackgroundColor="Red"
Command="{Binding Source={x:Reference collectionView}, Path=BindingContext.DeleteTaskCommand}"
CommandParameter="{Binding}" />
<SwipeItem
Text="Edit"
BackgroundColor="Orange"
Command="{Binding Source={x:Reference collectionView}, Path=BindingContext.EditTaskCommand}"
CommandParameter="{Binding}" />
</SwipeItems>
</SwipeView.RightItems>

<Grid
Margin="16, 5"
Margin="16,5"
ColumnDefinitions="*, Auto">
<Label
VerticalOptions="Center"
Text="{Binding Title}">
<Label.Triggers>
<DataTrigger TargetType="Label"
Binding="{Binding Done}"
Value="True">
<Setter Property="TextDecorations"
Value="Strikethrough"/>
</DataTrigger>
<DataTrigger TargetType="Label"
Binding="{Binding Done}"
Value="False">
<Setter Property="TextDecorations"
Value="None"/>
</DataTrigger>
</Label.Triggers>
<Label.Style>
<Style TargetType="Label">
<Setter Property="TextDecorations" Value="None" />
<Style.Triggers>
<DataTrigger TargetType="Label"
Binding="{Binding Done}"
Value="True">
<Setter Property="TextDecorations" Value="Strikethrough" />
</DataTrigger>
</Style.Triggers>
</Style>
</Label.Style>
</Label>
<CheckBox
HorizontalOptions="End"
IsChecked="{Binding Done}"
CheckedChanged="OnCheckBoxCheckedChanged"/>
<Grid Grid.Column="1"
Padding="8"
HorizontalOptions="End"
VerticalOptions="Center">
<CheckBox
WidthRequest="32"
HeightRequest="32"
IsChecked="{Binding Done}"
CheckedChanged="OnCheckBoxCheckedChanged" />
</Grid>
</Grid>
</ViewCell>
</SwipeView>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</StackLayout>
</CollectionView.ItemTemplate>
</CollectionView>
</Grid>
</ContentPage>
Loading