Skip to content
Draft
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
19 changes: 12 additions & 7 deletions dotnet-maui/DittoMauiTasksApp/DittoMauiTasksApp.csproj
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('OSX'))">net9.0-android;net9.0-ios;net9.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('Windows'))">net9.0-windows10.0.19041.0;net9.0-android;net9.0-ios;net9.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('Linux'))">net9.0-android</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('OSX'))">net10.0-android;net10.0-ios;net10.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('Windows'))">net10.0-windows10.0.19041.0;net10.0-android;net10.0-ios</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('Linux'))">net10.0-android</TargetFrameworks>
<OutputType>Exe</OutputType>
<RootNamespace>DittoMauiTasksApp</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>

<!-- Display name -->
<ApplicationTitle>QS Tasks</ApplicationTitle>
<!-- App bundle name (matches project name) -->
<ApplicationTitle>DittoMauiTasksApp</ApplicationTitle>

<!-- App Identifier -->
<ApplicationId>live.ditto.quickstart.mauitasksapp</ApplicationId>
Expand All @@ -21,11 +21,16 @@
<ApplicationVersion>1</ApplicationVersion>

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">15.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">23.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">24.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">15.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
</PropertyGroup>

<!-- Platform-specific display names -->
<PropertyGroup Condition="$(TargetFramework.Contains('ios')) or $(TargetFramework.Contains('maccatalyst'))">
<CFBundleDisplayName>QS Tasks</CFBundleDisplayName>
</PropertyGroup>

<!-- Reduce iOS optimization for faster builds -->
<PropertyGroup Condition="$(TargetFramework.Contains('ios')) and '$(Configuration)' == 'Release'">
<TrimMode>partial</TrimMode>
Expand All @@ -47,7 +52,7 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.1" />
<PackageReference Include="Ditto" Version="4.13.1" />
<PackageReference Include="Ditto" Version="5.0.0-preview.4" />
<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
51 changes: 30 additions & 21 deletions dotnet-maui/DittoMauiTasksApp/MauiProgram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using DittoMauiTasksApp.Utils;
using DittoMauiTasksApp.ViewModels;
using DittoSDK;
using DittoSDK.Auth;

namespace DittoMauiTasksApp;

Expand Down Expand Up @@ -42,30 +43,38 @@ private static Ditto SetupDitto()
AppId = envVars["DITTO_APP_ID"];
PlaygroundToken = envVars["DITTO_PLAYGROUND_TOKEN"];
var authUrl = envVars["DITTO_AUTH_URL"];
var websocketUrl = envVars["DITTO_WEBSOCKET_URL"];

var ditto = new Ditto(DittoIdentity
.OnlinePlayground(

// New Initialization code - https://docs.ditto.live/sdk/latest/ditto-config
var dittoConfig = new DittoConfig(
AppId,
PlaygroundToken,
false, // This is required to be set to false to use the correct URLs
authUrl), Path.Combine(FileSystem.Current.AppDataDirectory, "ditto"));
new DittoConfigConnect.Server(
new Uri(authUrl)
),
Path.Combine(FileSystem.Current.AppDataDirectory, "ditto")
);

// Set the transport configuration
// https://docs.ditto.live/sdk/latest/sync/customizing-transport-configurations#enabling-and-disabling-transports
ditto.UpdateTransportConfig(config =>
var ditto = Ditto.Open(dittoConfig);

// Set up authentication expiration handler (required for server connections)
ditto.Auth.ExpirationHandler = async (dittoAuth, secondsRemaining) =>
{
// Add the websocket URL to the transport configuration.
config.Connect.WebsocketUrls.Add(websocketUrl);
});

// disable sync with v3 peers, required for DQL
ditto.DisableSyncWithV3();

// Disable DQL strict mode
// https://docs.ditto.live/dql/strict-mode
ditto.Store.ExecuteAsync("ALTER SYSTEM SET DQL_STRICT_MODE = false").Wait();

// Authenticate when token is expiring
try
{
await dittoAuth.Auth.LoginAsync(
// Your development token, replace with your actual token
PlaygroundToken,
// Use DittoAuthenticationProvider.Development for playground, or your actual provider
DittoAuthenticationProvider.Development
);
Console.WriteLine("Authentication successful");
}
catch (Exception error)
{
Console.WriteLine($"Authentication failed: {error}");
}
};

return ditto;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="live.ditto.quickstart.mauitasksapp" android:versionCode="1" android:versionName="1.0">
<application android:allowBackup="true" android:icon="@mipmap/appicon" android:supportsRtl="true" android:label="QS Tasks"></application>
<application android:allowBackup="true"
android:icon="@mipmap/appicon"
android:supportsRtl="true"
android:label="QS Tasks"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
Expand All @@ -18,11 +21,14 @@
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.NEARBY_WIFI_DEVICES" android:usesPermissionFlags="neverForLocation" />
<uses-permission android:name="android.permission.NEARBY_WIFI_DEVICES"
android:usesPermissionFlags="neverForLocation" />

<uses-feature android:name="android.hardware.bluetooth" android:required="false"/>
<uses-feature android:name="android.hardware.bluetooth_le" android:required="true"/>

<uses-sdk android:minSdkVersion="23" android:targetSdkVersion="35" android:compileSdkVersion="35"/>
<uses-sdk android:minSdkVersion="24"
android:targetSdkVersion="36"
android:compileSdkVersion="36"/>
</manifest>

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@

namespace DittoMauiTasksApp;

[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
[Activity(Theme = "@style/Maui.SplashTheme",
MainLauncher = true,
ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
public class MainActivity : MauiAppCompatActivity
{
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@
using CommunityToolkit.Mvvm.Input;
using DittoMauiTasksApp.Utils;
using DittoSDK;
using DittoSDK.Sync;
using Microsoft.Extensions.Logging;

namespace DittoMauiTasksApp.ViewModels
{
public partial class TasksPageviewModel : ObservableObject
{
private const string SelectQuery = "SELECT * FROM tasks WHERE NOT deleted ORDER BY title ASC";
private const string SelectQuery = "SELECT * FROM tasks WHERE NOT deleted";

private readonly Ditto ditto;
private readonly IPopupService popupService;
Expand Down Expand Up @@ -329,7 +330,7 @@ private void StartSync()
{
try
{
ditto.StartSync();
ditto.Sync.Start();

// Register a subscription, which determines what data syncs to this peer
// https://docs.ditto.live/sdk/latest/sync/syncing-data#creating-subscriptions
Expand Down Expand Up @@ -358,7 +359,7 @@ private void StopSync()

try
{
ditto.StopSync();
ditto.Sync.Stop();
}
catch (Exception e)
{
Expand Down
8 changes: 4 additions & 4 deletions dotnet-maui/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,27 +26,27 @@ dotnet restore
These commands will build and run the app on the default iOS target:

```sh
dotnet build -t:Run -f net9.0-ios
dotnet build -t:Run -f net10.0-ios
```

### Building and Running the App on Android

These commands will build and run the app on the default Android target:

```sh
dotnet build -t:Run -f net9.0-android
dotnet build -t:Run -f net10.0-android
```

### Building and Running the App on MacOS

```sh
dotnet build -t:Run -f net9.0-maccatalyst
dotnet build -t:Run -f net10.0-maccatalyst
```

### Building and Running the App on Windows

```sh
dotnet build -t:Run -f net9.0-windows10.0.19041.0
dotnet build -t:Run -f net10.0-windows10.0.19041.0
```

### Other MAUI Platforms
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.12.0" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" />
<PackageReference Include="Ditto" Version="4.13.1" />
<PackageReference Include="Ditto" Version="5.0.0-preview.4" />
<PackageReference Include="Terminal.Gui" Version="1.17.1" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net9.0</TargetFramework>
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>disable</ImplicitUsings>
<Nullable>disable</Nullable>
<LangVersion>14</LangVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Ditto" Version="4.13.1" />
<PackageReference Include="Ditto" Version="5.0.0-preview.4" />
<PackageReference Include="Terminal.Gui" Version="1.17.1" />
</ItemGroup>

Expand Down
3 changes: 2 additions & 1 deletion dotnet-tui/DittoDotNetTasksConsole/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Threading.Tasks;

using DittoSDK;
using DittoSDK.Logging;
using Terminal.Gui;

public static class Program
Expand All @@ -24,7 +25,7 @@ public static async Task Main(string[] args)

// Disable Ditto's standard-error logging, which would interfere
// with the the Terminal.Gui UI.
DittoLogger.SetLoggingEnabled(false);
DittoLogger.IsEnabled = false;
RunTerminalGui(peer);
}
catch (Exception ex)
Expand Down
Loading
Loading