Skip to content

Commit ee63bc0

Browse files
authored
.NET MAUI - Add Mac Catalyst platform (#49)
* Add maccatalyst platform support * mac-catalyst compatible UI * Add appropriate permissions * Update to Ditto `4.11.0-preview.2`. Use `DittoSyncPermissions` instead of the old helper. * update ditto to stable version
1 parent f8723cb commit ee63bc0

File tree

8 files changed

+117
-122
lines changed

8 files changed

+117
-122
lines changed

dotnet-maui/DittoMauiTasksApp/DittoMauiTasksApp.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFrameworks>net9.0-android;net9.0-ios;</TargetFrameworks>
4+
<TargetFrameworks>net9.0-android;net9.0-ios;net9.0-maccatalyst</TargetFrameworks>
55
<OutputType>Exe</OutputType>
66
<RootNamespace>DittoMauiTasksApp</RootNamespace>
77
<UseMaui>true</UseMaui>
@@ -36,7 +36,7 @@
3636
</ItemGroup>
3737
<ItemGroup>
3838
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.1" />
39-
<PackageReference Include="Ditto" Version="4.10.0" />
39+
<PackageReference Include="Ditto" Version="4.11.0" />
4040
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
4141
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)" />
4242
<PackageReference Include="Microsoft.Maui.Controls.Compatibility" Version="$(MauiVersion)" />
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using Foundation;
2+
3+
namespace DittoMauiTasksApp;
4+
5+
[Register("AppDelegate")]
6+
public class AppDelegate : MauiUIApplicationDelegate
7+
{
8+
protected override MauiApp CreateMauiApp() => MauiProgram.CreateMauiApp();
9+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3+
<plist version="1.0">
4+
<dict>
5+
<key>UIDeviceFamily</key>
6+
<array>
7+
<integer>1</integer>
8+
<integer>2</integer>
9+
</array>
10+
<key>UIRequiredDeviceCapabilities</key>
11+
<array>
12+
<string>arm64</string>
13+
</array>
14+
<key>UISupportedInterfaceOrientations</key>
15+
<array>
16+
<string>UIInterfaceOrientationPortrait</string>
17+
<string>UIInterfaceOrientationLandscapeLeft</string>
18+
<string>UIInterfaceOrientationLandscapeRight</string>
19+
</array>
20+
<key>UISupportedInterfaceOrientations~ipad</key>
21+
<array>
22+
<string>UIInterfaceOrientationPortrait</string>
23+
<string>UIInterfaceOrientationPortraitUpsideDown</string>
24+
<string>UIInterfaceOrientationLandscapeLeft</string>
25+
<string>UIInterfaceOrientationLandscapeRight</string>
26+
</array>
27+
<key>XSAppIconAssets</key>
28+
<string>Assets.xcassets/appicon.appiconset</string>
29+
<key>NSBluetoothAlwaysUsageDescription</key>
30+
<string>Uses Bluetooth to connect and sync with nearby devices</string>
31+
<key>NSBluetoothPeripheralUsageDescription</key>
32+
<string>Uses Bluetooth to connect and sync with nearby devices</string>
33+
<key>NSLocalNetworkUsageDescription</key>
34+
<string>Uses WiFi to connect and sync with nearby devices</string>
35+
<key>NSBonjourServices</key>
36+
<array>
37+
<string>_http-alt._tcp.</string>
38+
</array>
39+
</dict>
40+
</plist>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using ObjCRuntime;
2+
using UIKit;
3+
4+
namespace DittoMauiTasksApp;
5+
6+
public class Program
7+
{
8+
// This is the main entry point of the application.
9+
static void Main(string[] args)
10+
{
11+
// if you want to use a different Application Delegate class from "AppDelegate"
12+
// you can specify it here.
13+
UIApplication.Main(args, null, typeof(AppDelegate));
14+
}
15+
}

dotnet-maui/DittoMauiTasksApp/Utils/BluetoothPermissions.cs

Lines changed: 0 additions & 28 deletions
This file was deleted.

dotnet-maui/DittoMauiTasksApp/Utils/PermissionHelper.cs

Lines changed: 0 additions & 50 deletions
This file was deleted.

dotnet-maui/DittoMauiTasksApp/ViewModels/TasksPageviewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public TasksPageviewModel(
3434
this.popupService = popupService;
3535
this.logger = logger;
3636

37-
PermissionHelper.CheckPermissions().ContinueWith(async t =>
37+
DittoSyncPermissions.RequestPermissionsAsync().ContinueWith(async t =>
3838
{
3939
try
4040
{

dotnet-maui/DittoMauiTasksApp/Views/TasksPage.xaml

Lines changed: 50 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
Command="{Binding AddTaskCommand}"/>
1010
</ContentPage.ToolbarItems>
1111

12-
<StackLayout>
12+
<Grid
13+
RowDefinitions="Auto, *">
1314
<VerticalStackLayout
1415
Margin="16, 5">
1516
<HorizontalStackLayout
@@ -30,54 +31,62 @@
3031
FontSize="Micro"/>
3132
</VerticalStackLayout>
3233

33-
<ListView
34-
x:Name="listView"
34+
<CollectionView
35+
x:Name="collectionView"
36+
Grid.Row="1"
3537
ItemsSource="{Binding Tasks}"
36-
SelectionMode="None"
37-
CachingStrategy="RecycleElementAndDataTemplate">
38-
<ListView.ItemTemplate>
38+
SelectionMode="None">
39+
<CollectionView.ItemTemplate>
3940
<DataTemplate>
40-
<ViewCell>
41-
<ViewCell.ContextActions>
42-
<MenuItem
43-
Text="Delete"
44-
Command="{Binding Source={x:Reference listView}, Path=BindingContext.DeleteTaskCommand}"
45-
CommandParameter="{Binding}"
46-
IsDestructive="True"/>
47-
<MenuItem
48-
Text="Edit"
49-
Command="{Binding Source={x:Reference listView}, Path=BindingContext.EditTaskCommand}"
50-
CommandParameter="{Binding}"/>
51-
</ViewCell.ContextActions>
41+
<SwipeView>
42+
<SwipeView.RightItems>
43+
<SwipeItems>
44+
<SwipeItem
45+
Text="Delete"
46+
BackgroundColor="Red"
47+
Command="{Binding Source={x:Reference collectionView}, Path=BindingContext.DeleteTaskCommand}"
48+
CommandParameter="{Binding}" />
49+
<SwipeItem
50+
Text="Edit"
51+
BackgroundColor="Orange"
52+
Command="{Binding Source={x:Reference collectionView}, Path=BindingContext.EditTaskCommand}"
53+
CommandParameter="{Binding}" />
54+
</SwipeItems>
55+
</SwipeView.RightItems>
56+
5257
<Grid
53-
Margin="16, 5"
58+
Margin="16,5"
5459
ColumnDefinitions="*, Auto">
5560
<Label
5661
VerticalOptions="Center"
5762
Text="{Binding Title}">
58-
<Label.Triggers>
59-
<DataTrigger TargetType="Label"
60-
Binding="{Binding Done}"
61-
Value="True">
62-
<Setter Property="TextDecorations"
63-
Value="Strikethrough"/>
64-
</DataTrigger>
65-
<DataTrigger TargetType="Label"
66-
Binding="{Binding Done}"
67-
Value="False">
68-
<Setter Property="TextDecorations"
69-
Value="None"/>
70-
</DataTrigger>
71-
</Label.Triggers>
63+
<Label.Style>
64+
<Style TargetType="Label">
65+
<Setter Property="TextDecorations" Value="None" />
66+
<Style.Triggers>
67+
<DataTrigger TargetType="Label"
68+
Binding="{Binding Done}"
69+
Value="True">
70+
<Setter Property="TextDecorations" Value="Strikethrough" />
71+
</DataTrigger>
72+
</Style.Triggers>
73+
</Style>
74+
</Label.Style>
7275
</Label>
73-
<CheckBox
74-
HorizontalOptions="End"
75-
IsChecked="{Binding Done}"
76-
CheckedChanged="OnCheckBoxCheckedChanged"/>
76+
<Grid Grid.Column="1"
77+
Padding="8"
78+
HorizontalOptions="End"
79+
VerticalOptions="Center">
80+
<CheckBox
81+
WidthRequest="32"
82+
HeightRequest="32"
83+
IsChecked="{Binding Done}"
84+
CheckedChanged="OnCheckBoxCheckedChanged" />
85+
</Grid>
7786
</Grid>
78-
</ViewCell>
87+
</SwipeView>
7988
</DataTemplate>
80-
</ListView.ItemTemplate>
81-
</ListView>
82-
</StackLayout>
89+
</CollectionView.ItemTemplate>
90+
</CollectionView>
91+
</Grid>
8392
</ContentPage>

0 commit comments

Comments
 (0)