Skip to content
This repository was archived by the owner on May 27, 2025. It is now read-only.
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
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,11 @@ Android/app/*.aab
Android/app/*.apk
Android/*.jks
Android/*.keystore
Android/app/google-services.json
Android/app/google-services.json

# Dotnet

Dotnet/.idea
Dotnet/.vscode
Dotnet/bin
Dotnet/obj
38 changes: 38 additions & 0 deletions Dotnet/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version = "1.0" encoding = "UTF-8" ?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:Guides"
xmlns:converters="clr-namespace:Guides.Converters"
x:Class="Guides.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>

<!-- Add converters here -->
<converters:ListToStringConverter x:Key="ListToStringConverter" />
<converters:NotNullConverter x:Key="NotNullConverter" />
<converters:IsZeroConverter x:Key="IsZeroConverter" />
<converters:NotZeroConverter x:Key="NotZeroConverter" />

<Style x:Key="FilledTonalButton" TargetType="Button">
<Setter Property="BackgroundColor" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource PrimaryDark}}" />
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Secondary}, Dark={StaticResource SecondaryDark}}" />
<Setter Property="Padding" Value="16,8" />
<Setter Property="CornerRadius" Value="20" />
</Style>

<Style x:Key="CircleButton" TargetType="Button">
<Setter Property="BackgroundColor" Value="{AppThemeBinding Light={StaticResource Primary}, Dark={StaticResource PrimaryDark}}" />
<Setter Property="TextColor" Value="{AppThemeBinding Light={StaticResource Secondary}, Dark={StaticResource SecondaryDark}}" />
<Setter Property="WidthRequest" Value="56" />
<Setter Property="HeightRequest" Value="56" />
<Setter Property="CornerRadius" Value="28" />
<Setter Property="Padding" Value="0" />
<Setter Property="FontSize" Value="24" />
</Style>
</ResourceDictionary>
</Application.Resources>
</Application>
14 changes: 14 additions & 0 deletions Dotnet/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace Guides;

public partial class App : Application
{
public App()
{
InitializeComponent();
}

protected override Window CreateWindow(IActivationState? activationState)
{
return new Window(new AppShell());
}
}
14 changes: 14 additions & 0 deletions Dotnet/AppShell.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="Guides.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:views="clr-namespace:Guides.Views"
Title="Guides">

<ShellContent
Title="Planets"
ContentTemplate="{DataTemplate views:MainPage}"
Route="MainPage" />

</Shell>
9 changes: 9 additions & 0 deletions Dotnet/AppShell.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Guides;

public partial class AppShell : Shell
{
public AppShell()
{
InitializeComponent();
}
}
20 changes: 20 additions & 0 deletions Dotnet/Converters/IsZeroConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Globalization;

namespace Guides.Converters;

public class IsZeroConverter : IValueConverter
{
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is int count)
{
return count == 0;
}
return false;
}

public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
20 changes: 20 additions & 0 deletions Dotnet/Converters/ListToStringConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Globalization;

namespace Guides.Converters;

public class ListToStringConverter : IValueConverter
{
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is List<string> list)
{
return string.Join(", ", list);
}
return string.Empty;
}

public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
16 changes: 16 additions & 0 deletions Dotnet/Converters/NotNullConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using System.Globalization;

namespace Guides.Converters;

public class NotNullConverter : IValueConverter
{
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
return value != null;
}

public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
20 changes: 20 additions & 0 deletions Dotnet/Converters/NotZeroConverter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Globalization;

namespace Guides.Converters;

public class NotZeroConverter : IValueConverter
{
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is int count)
{
return count > 0;
}
return true;
}

public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
99 changes: 99 additions & 0 deletions Dotnet/Guides.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>

<!-- MacCatalyst and Windows is not supported yet with the Ditto SDK, so remove it for now
<TargetFrameworks>net9.0-android;net9.0-ios;net9.0-maccatalyst</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net9.0-windows10.0.19041.0</TargetFrameworks>

Docs:
https://docs.ditto.live/sdk/latest/compatibility/c-sharp

-->
<TargetFrameworks>net9.0-android;net9.0-ios;</TargetFrameworks>

<!-- Note for MacCatalyst:
The default runtime is maccatalyst-x64, except in Release config, in which case the default is maccatalyst-x64;maccatalyst-arm64.
When specifying both architectures, use the plural <RuntimeIdentifiers> instead of the singular <RuntimeIdentifier>.
The Mac App Store will NOT accept apps with ONLY maccatalyst-arm64 indicated;
either BOTH runtimes must be indicated or ONLY macatalyst-x64. -->
<!-- For example: <RuntimeIdentifiers>maccatalyst-x64;maccatalyst-arm64</RuntimeIdentifiers> -->

<OutputType>Exe</OutputType>
<RootNamespace>Guides</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<!-- Display name -->
<ApplicationTitle>Guides</ApplicationTitle>

<!-- App Identifier -->
<ApplicationId>com.companyname.guides</ApplicationId>

<!-- Versions -->
<ApplicationDisplayVersion>1.0</ApplicationDisplayVersion>
<ApplicationVersion>1</ApplicationVersion>

<!-- To develop, package, and publish an app to the Microsoft Store, see: https://aka.ms/MauiTemplateUnpackaged -->
<WindowsPackageType>None</WindowsPackageType>

<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">15.0</SupportedOSPlatformVersion>

<!-- Mac Catalyst and windows aren't supported yet with the Ditto SDK, so remove it for now
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">15.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
-->
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">26.0</SupportedOSPlatformVersion>

</PropertyGroup>

<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4"/>

<!-- Splash Screen -->
<MauiSplashScreen Include="Resources\Splash\splash.svg" Color="#512BD4" BaseSize="128,128"/>

<!-- Images -->
<MauiImage Include="Resources\Images\*"/>
<MauiImage Update="Resources\Images\dotnet_bot.png" Resize="True" BaseSize="300,185"/>

<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*"/>

<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)"/>
</ItemGroup>

<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
<PackageReference Include="Ditto" Version="4.9.3" />
<PackageReference Include="Microsoft.Maui.Controls" Version="$(MauiVersion)"/>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="9.0.0"/>
<PackageReference Include="Syncfusion.Maui.Toolkit" Version="1.0.3" />
</ItemGroup>

<ItemGroup>
<MauiXaml Update="Views\MainPage.xaml">
<SubType>Designer</SubType>
</MauiXaml>
</ItemGroup>

<ItemGroup>
<Compile Update="Views\MainPage.xaml.cs">
<DependentUpon>MainPage.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
</ItemGroup>

<ItemGroup>
<MauiAsset Include="dittoConfig.json">
<LogicalName>dittoConfig.json</LogicalName>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</MauiAsset>
</ItemGroup>

</Project>
16 changes: 16 additions & 0 deletions Dotnet/Guides.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Guides", "Guides.csproj", "{897A2B3F-166A-46B9-884D-BDAAC7A6A2EE}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{897A2B3F-166A-46B9-884D-BDAAC7A6A2EE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{897A2B3F-166A-46B9-884D-BDAAC7A6A2EE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{897A2B3F-166A-46B9-884D-BDAAC7A6A2EE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{897A2B3F-166A-46B9-884D-BDAAC7A6A2EE}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
2 changes: 2 additions & 0 deletions Dotnet/Guides.sln.DotSettings.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AIServiceProvider_002Ecs_002Fl_003A_002E_002E_003F_002E_002E_003F_002E_002E_003F_002E_002E_003FLibrary_003FApplication_0020Support_003FJetBrains_003FRider2024_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fa1ddc3cc56a944c2a2b82810dc5d62dd1600_003Fc3_003F8e998e75_003FIServiceProvider_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>
52 changes: 52 additions & 0 deletions Dotnet/MauiProgram.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using System.Text.Json;
using Guides.Models;
using Guides.Services;
using Guides.ViewModels;
using Guides.Views;
using Microsoft.Extensions.Logging;
using Syncfusion.Maui.Toolkit.Hosting;

namespace Guides;

public static class MauiProgram
{
private static readonly JsonSerializerOptions JsonSerializerOptions = new JsonSerializerOptions
{ PropertyNameCaseInsensitive = true };

public static MauiApp CreateMauiApp()
{
var builder = MauiApp.CreateBuilder();
builder
.UseMauiApp<App>()
// Initialize the Syncfusion .NET MAUI Toolkit by adding the below line of code
.ConfigureSyncfusionToolkit()
// Initialize the Fonts
.ConfigureFonts(fonts =>
{
fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
});

// Register services
builder.Services.AddSingleton<AppConfig>(serviceProvider =>
{
// Load config synchronously
using var stream = FileSystem.Current.OpenAppPackageFileAsync("dittoConfig.json").Result;
using var reader = new StreamReader(stream);
var fileContent = reader.ReadToEndAsync().Result;
var config = JsonSerializer.Deserialize<AppConfig>(fileContent, JsonSerializerOptions);
return config ?? new AppConfig("", "", "");
});

//register Services and ViewModels
builder.Services.AddSingleton<ErrorService>();
builder.Services.AddSingleton<IDataService, DittoService>();
builder.Services.AddTransient<MainPageViewModel>();

#if DEBUG
builder.Logging.AddDebug();
#endif

return builder.Build();
}
}
8 changes: 8 additions & 0 deletions Dotnet/Models/AppConfig.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using System.Text.Json.Serialization;

namespace Guides.Models;

public record AppConfig(
[property: JsonPropertyName("appId")] string AppId,
[property: JsonPropertyName("authToken")] string AuthToken,
[property: JsonPropertyName("endpointUrl")] string EndpointUrl);
Loading