-
Notifications
You must be signed in to change notification settings - Fork 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
docs: single project changes #2325
Draft
Kunal22shah
wants to merge
6
commits into
main
Choose a base branch
from
dev/ks/MauiCommunityToolkitApp-docs
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
a5df19f
docs: single project changes
Kunal22shah e5bdeaf
docs: resolving PR comments
Kunal22shah 1191acd
docs: resolving PR comments
Kunal22shah 8fb9007
Merge branch 'main' into dev/ks/MauiCommunityToolkitApp-docs
Kunal22shah 03b2acc
docs: resolving PR comments
Kunal22shah 6849b08
docs: resolving PR comments
Kunal22shah File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,22 +9,64 @@ The controls from MauiCommunityToolkit can be used in an Uno Platform applicatio | |
|
||
An existing sample app that showcases the controls is available [here](https://github.com/unoplatform/Uno.Samples/tree/master/UI/MauiEmbedding/MauiCommunityToolkitApp). | ||
|
||
> [!NOTE] | ||
> MauiCommunityToolkitApp SDK for .NET is currently only compatible with Windows, Android, iOS, and Mac Catalyst when used with Uno Platform. | ||
|
||
## Getting Started | ||
|
||
1. Create a new application using the `unoapp` template, enabling .NET MAUI Embedding. In this case, we're going to use the Blank template (`-preset blank`) and include .NET MAUI Embedding support (`-maui`). | ||
|
||
```dotnetcli | ||
dotnet new unoapp -preset blank -maui -o MauiEmbeddingApp | ||
dotnet new unoapp -preset blank -maui -o MauiCommunityToolkitApp | ||
``` | ||
### [Visual Studio](#tab/vs) | ||
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. @Kunal22shah @agneszitte same comment as #2322 (comment) |
||
> [!NOTE] | ||
> If you don't have the **Uno Platform Extension for Visual Studio** installed, follow [these instructions](xref:Uno.GetStarted.vs2022). | ||
|
||
- Launch **Visual Studio** and click on **Create new project** on the Start Window. Alternatively, if you're already in Visual Studio, click **New, Project** from the **File** menu. | ||
|
||
- Type `Uno Platform` in the search box | ||
|
||
- Click **Uno Platform App**, then **Next** | ||
|
||
- Name the project `MauiCommunityToolkitApp` and click **Create** | ||
|
||
At this point you'll enter the **Uno Platform Template Wizard**, giving you options to customize the generated application. | ||
|
||
- Select **Blank** in **Presets** selection | ||
|
||
- Select the **Platforms** tab and unselect **Desktop** and **Web Assembly** platforms | ||
|
||
- Select the **Features** tab and click on **.NET MAUI Embedding** | ||
|
||
Click **Create** to complete the wizard | ||
|
||
1. Add a reference to the [CommunityToolkit.Maui NuGet package](https://www.nuget.org/packages/CommunityToolkit.Maui) to the MauiEmbeddingApp.MauiControls project. | ||
The template will create a solution with a single cross-platform project, named `MauiCommunityToolkitApp`, ready to run. | ||
|
||
1. In the `AppBuilderExtensions` class, on `MauiEmbeddingApp.MauiControls` project, update the `UseMauiControls` extension method to call the `UseMauiCommunityToolkit` method. | ||
For more information on all the template options, see [Using the Uno Platform Template](xref:Uno.GettingStarted.UsingWizard). | ||
|
||
### [Command Line](#tab/cli) | ||
|
||
> [!NOTE] | ||
> If you don't have the **Uno Platform dotnet new templates** installed, follow [dotnet new templates for Uno Platform](xref:Uno.GetStarted.dotnet-new). | ||
Kunal22shah marked this conversation as resolved.
Show resolved
Hide resolved
|
||
Create a new application using the `unoapp` template, enabling .NET MAUI Embedding. In this case, we're going to use the Blank template (`-preset blank`) and include .NET MAUI Embedding support (`-maui`). | ||
|
||
```bash | ||
dotnet new unoapp -preset blank -maui -platforms "android" -platforms "ios" -platforms "maccatalyst" -platforms "windows" -o MauiCommunityToolkitApp | ||
``` | ||
|
||
This will create a new folder called **MauiCommunityToolkitApp** containing the new application. | ||
|
||
--- | ||
|
||
1. Add a reference to the [CommunityToolkitApp.Maui NuGet package](https://www.nuget.org/packages/CommunityToolkit.Maui) to the MauiCommunityToolkitApp.MauiControls project. | ||
|
||
1. In the `AppBuilderExtensions` class, on `MauiCommunityToolkitApp.MauiControls` project, update the `UseMauiControls` extension method to call the `UseMauiCommunityToolkit` method. | ||
|
||
```cs | ||
using CommunityToolkit.Maui; | ||
|
||
namespace MauiEmbeddingApp; | ||
namespace MauiCommunityToolkitApp; | ||
|
||
public static class AppBuilderExtensions | ||
{ | ||
|
@@ -33,22 +75,22 @@ An existing sample app that showcases the controls is available [here](https://g | |
.UseMauiCommunityToolkit() | ||
.ConfigureFonts(fonts => | ||
{ | ||
fonts.AddFont("MauiEmbeddingApp/Assets/Fonts/OpenSansRegular.ttf", "OpenSansRegular"); | ||
fonts.AddFont("MauiEmbeddingApp/Assets/Fonts/OpenSansSemibold.ttf", "OpenSansSemibold"); | ||
fonts.AddFont("Assets/Fonts/OpenSansRegular.ttf", "OpenSansRegular"); | ||
fonts.AddFont("Assets/Fonts/OpenSansSemibold.ttf", "OpenSansSemibold"); | ||
}); | ||
} | ||
``` | ||
Kunal22shah marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
## Adding DrawingView | ||
|
||
1. Update the EmbeddedControl.xaml in the `MauiEmbedding.MauiControls` project with the following XAML that includes the `DrawingView` control | ||
1. Update the EmbeddedControl.xaml in the `MauiCommunityToolkitApp.MauiControls` project with the following XAML that includes the `DrawingView` control | ||
|
||
```xml | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<ContentView xmlns="http://schemas.microsoft.com/dotnet/2021/maui" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit" | ||
x:Class="MauiEmbeddingApp.MauiControls.EmbeddedControl" | ||
x:Class="MauiCommunityToolkitApp.MauiControls.EmbeddedControl" | ||
HorizontalOptions="Fill" | ||
VerticalOptions="Fill"> | ||
<toolkit:DrawingView IsMultiLineModeEnabled="{Binding IsMultiLineModeEnabled}" | ||
|
@@ -64,7 +106,7 @@ An existing sample app that showcases the controls is available [here](https://g | |
1. Update the EmbeddedControl.xaml.cs with the following code. | ||
|
||
```cs | ||
namespace MauiEmbeddingApp.MauiControls; | ||
namespace MauiCommunityToolkitApp.MauiControls; | ||
|
||
public partial class EmbeddedControl : ContentView | ||
{ | ||
|
@@ -75,10 +117,10 @@ An existing sample app that showcases the controls is available [here](https://g | |
} | ||
``` | ||
|
||
1. Now let's create the controls that will control the `DrawingView.IsMultiLineModeEnabled` and `DrawingView.ShouldClearOnFinish` properties. Update the MainPage.xaml in the `MauiEmbeddingApp` project with the following xaml: | ||
1. Now let's create the controls that will control the `DrawingView.IsMultiLineModeEnabled` and `DrawingView.ShouldClearOnFinish` properties. Update the MainPage.xaml in the `MauiCommunityToolkitApp` project with the following xaml: | ||
|
||
```xml | ||
<Page x:Class="MauiEmbeddingApp.MainPage" | ||
<Page x:Class="MauiCommunityToolkitApp.MainPage" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
|
@@ -99,18 +141,18 @@ An existing sample app that showcases the controls is available [here](https://g | |
IsOn="{Binding IsMultiLineModeEnabled, Mode=TwoWay}" /> | ||
</StackPanel> | ||
|
||
<embed:MauiHost xmlns:controls="using:MauiEmbeddingApp.MauiControls" | ||
<embed:MauiHost xmlns:controls="using:MauiCommunityToolkitApp.MauiControls" | ||
xmlns:embed="using:Uno.Extensions.Maui" | ||
Grid.Row="1" | ||
Source="controls:EmbeddedControl" /> | ||
</Grid> | ||
</Page> | ||
``` | ||
|
||
1. It's time to create the ViewModel that will hold the properties that will be data bound to the `DrawingView` control. On `MauiEmbeddingApp` project, create a new folder called `ViewModels` and add a new class called `MainViewModel`. This class will have the following code: | ||
1. It's time to create the ViewModel that will hold the properties that will be data bound to the `DrawingView` control. On `MauiCommunityToolkitApp` project, create a new folder called `ViewModels` and add a new class called `MainViewModel`. This class will have the following code: | ||
|
||
```cs | ||
namespace MauiEmbeddingApp.ViewModels; | ||
```cs | ||
namespace MauiCommunityToolkitApp.ViewModels; | ||
|
||
partial class MainViewModel : ObservableObject | ||
{ | ||
|
@@ -122,15 +164,15 @@ An existing sample app that showcases the controls is available [here](https://g | |
} | ||
``` | ||
|
||
1. The `MainViewModel` uses the `ObservableObject` base class that comes from the `CommunityToolkit.MVVM` NuGet package. This significantly reduces the amount of boilerplate code required. Add a reference to the [CommunityToolkit.Mvvm NuGet package](https://www.nuget.org/packages/CommunityToolkit.Mvvm) to the MauiEmbeddingApp project. | ||
1. The `MainViewModel` uses the `ObservableObject` base class that comes from the `CommunityToolkit.MVVM` NuGet package. This significantly reduces the amount of boilerplate code required. Add a reference to the [CommunityToolkit.Mvvm NuGet package](https://www.nuget.org/packages/CommunityToolkit.Mvvm) to the MauiCommunityToolkitApp project. | ||
|
||
1. The final step is to add the `MainViewModel` as the `DataContext` of the `Page` in the `MainPage.xaml` file. Here's how the final xaml should look. | ||
|
||
```xml | ||
<Page x:Class="MauiEmbeddingApp.MainPage" | ||
<Page x:Class="MauiCommunityToolkitApp.MainPage" | ||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
xmlns:local="using:MauiEmbeddingApp.ViewModels" | ||
xmlns:local="using:MauiCommunityToolkitApp.ViewModels" | ||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
mc:Ignorable="d" | ||
|
@@ -152,7 +194,7 @@ An existing sample app that showcases the controls is available [here](https://g | |
IsOn="{Binding IsMultiLineModeEnabled, Mode=TwoWay}" /> | ||
</StackPanel> | ||
|
||
<embed:MauiHost xmlns:controls="using:MauiEmbeddingApp.MauiControls" | ||
<embed:MauiHost xmlns:controls="using:MauiCommunityToolkitApp.MauiControls" | ||
xmlns:embed="using:Uno.Extensions.Maui" | ||
Grid.Row="1" | ||
Source="controls:EmbeddedControl" /> | ||
|
@@ -162,7 +204,9 @@ An existing sample app that showcases the controls is available [here](https://g | |
|
||
1. Now the project is good to go! Press F5 and you should see the `DrawingView` control working as expected. And tweaking the `ToggleSwitch` controls should change the `DrawingView` behavior. | ||
|
||
## App Render Output | ||
For more detailed instructions specific to each platform, refer to the [Debug the App](xref:Uno.GettingStarted.CreateAnApp.VS2022#debug-the-app) documentation. | ||
|
||
**App Render Output** | ||
|
||
- **Android:** | ||
- ![Android CommunityToolkit](Assets/Screenshots/Android/CommunityToolkit.png) | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.