-
Notifications
You must be signed in to change notification settings - Fork 126
docs-fix-links-and-lintings and part 1 of todo app tutorial creation #875
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
base: master
Are you sure you want to change the base?
Changes from 23 commits
7d151b5
a7696b5
a99cebe
1b3d19d
96dbbcf
7adeccb
ad39983
85cf6a7
69522c5
cc31042
487dc01
083d69c
81244f9
73654a9
1c7522f
1e92e1a
7610a9f
ebcb1ef
8000419
29113ca
bb86d48
b7aabe9
21c54e7
825de0e
f1e0fb6
6e91201
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| root = true | ||
|
|
||
| [*] | ||
| indent_style = space | ||
| indent_size = 4 | ||
| charset = utf-8 | ||
| trim_trailing_whitespace = false | ||
| insert_final_newline = false | ||
|
|
||
| [*.md] | ||
| indent_size = 2 | ||
| trim_trailing_whitespace = true | ||
| insert_final_newline = true |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| --- | ||
| uid: Uno.Workshops.ToDo-App.Overview | ||
| --- | ||
| # ToDo App Overview | ||
|
|
||
| <p align="center"> | ||
| <img src="doc/assets/ToDoApp_Banner.png" alt="Introducing centered Banner Image. On the left, there's a large checkmark icon inside a purple circle, set against a violet background. Next to it, bold white text reads 'To Do App.' On the right side, three stylized smartphone screens display different app views, including a welcome screen, a task list, and an 'Important' tasks section. The Uno Platform logo appears in the top-right corner. Colorful dots scattered in the background add a modern and vibrant touch"> | ||
| </p> | ||
|
|
||
| Uno ToDo App is a beautifully designed sample for [Uno Platform](https://platform.uno/) using the latest [Material Design 3 system](https://m3.material.io/). | ||
|
|
||
| The design template makes it easy to jump-start or learn Uno Platform-powered mobile, web, and desktop applications. The app provides common functions such as logging on, recording tasks, adding due dates, setting reminders, and more. | ||
|
|
||
| In addition, the sample code utilizes [Uno.Extensions](https://aka.platform.uno/uno-extensions) and establishes the best practices for cross-platform application design and development considering multiple screen sizes, accessibility, enforcing brand guidelines, and more. | ||
|
|
||
|  | ||
|
|
||
| ## Table of Contents <!--TODO: Transfer this to code-csharp Snippets on separate pages or even better create a real workshop--> | ||
|
|
||
| * [Defining Records loaded by Configuration as `IOptions`](xref:Uno.Workshops.ToDo-App.DefiningConfigurationLoadedRecord) | ||
| * [Accessing tokens with Authentication](xref:Uno.Workshops.ToDo-App.AccessingAuthTokens) | ||
| * [Common Navigation](xref:Uno.Workshops.ToDo-App.Common-Navigation) | ||
| * [Changing the language with Localization via the model](xref:Uno.Workshops.ToDo-App.LocalizeByModel). | ||
| * [Adapting the language in the Xaml with Localization via `x:Uid`](xref:Uno.Workshops.ToDo-App.LocalizeWithUid) | ||
| * [Theme switching with ThemeService](xref:Uno.Workshops.ToDo-App.Theme-Switching-by-ThemeService) | ||
| * [Reactive ListFeeds with FeedViews](xref:Uno.Workshops.ToDo-App.Reactive-ListFeeds-FeedViews) | ||
|
|
||
| ## What is the Uno Platform | ||
|
|
||
| [Uno Platform](https://platform.uno) is an open-source .NET platform for building single codebase native mobile, web, desktop, and embedded apps quickly. | ||
| For additional information about Uno Platform or if you have any feedback to share, please refer to the [README.md](xref:Uno.Samples.Readme) file in this Samples repository. |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| uid: Uno.Workshops.ToDo-App.AccessingAuthTokens | ||
| --- | ||
| # Accessing Tokens with Authentication | ||
|
|
||
| [!code-csharp[](../src/ToDo/Presentation/WelcomeViewModel.cs)] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| --- | ||
| uid: Uno.Workshops.ToDo-App.Common-Navigation | ||
| --- | ||
| # Common Navigation | ||
|
|
||
| ## The Task Page | ||
|
|
||
| [!code-xaml[](../src/ToDo/Views/TaskListPage.xaml)] | ||
|
|
||
| ## Code-Behind of List Page | ||
|
|
||
| [!code-csharp[](../src/ToDo/Views/TaskListPage.xaml.cs)] | ||
|
|
||
| ## View Model of Task Page | ||
|
|
||
| [!code-csharp[](../src/ToDo/Presentation/TaskListViewModel.cs)] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| --- | ||
| uid: Uno.Workshops.ToDo-App.DefiningConfigurationLoadedRecord | ||
| --- | ||
|
|
||
| # Authentication Options via `IOptions` and `appsettings.json` | ||
|
|
||
| This sample demonstrates how to define immutable authentication options as `record`, load them from `appsettings.json` using [Uno.Extensions.Configuration](xref:Uno.Extensions.Configuration.Overview) `UseConfiguration(...).Section<T>()` and consume them inside of an `AuthenticationService` which will be used in this Sample app. | ||
|
|
||
| ## 1. Defining the `Auth` record | ||
|
|
||
| Your JSON file(s) will consist of a serialized representation of multiple properties and their values. Hence, configuration sections allow you to programmatically read a specific subset of these properties from the instantiated class that represents them. | ||
|
|
||
| To ensure immutability while still allowing the configuration binder to populate values, the record must expose *init-only* properties. | ||
| A primary constructor **cannot** be used, because the configuration binder requires a parameterless constructor and settable properties. | ||
|
|
||
| Author a new class or record with related properties to be used for configuration: | ||
|
|
||
| ```csharp | ||
| public partial record Auth | ||
| { | ||
| public string? ApplicationId { get; init; } | ||
| public string[]? Scopes { get; init; } | ||
| public string? RedirectUri { get; init; } | ||
| public string? KeychainSecurityGroup { get; init; } | ||
| } | ||
| ``` | ||
|
|
||
| The following form **does not work** with `IOptions`, even if all parameters are nullable: | ||
|
|
||
| ```csharp | ||
| public partial record Auth(string? ApplicationId, string[]? Scopes, string? RedirectUri, string? KeychainSecurityGroup); | ||
| ``` | ||
|
|
||
| The binder cannot map configuration values into primary-constructor parameters. | ||
|
|
||
| > [!TIP] | ||
| > If you want to keep the Types non-nullable and depending on their implementation, you can apply default values like: | ||
| > ```csharp | ||
| > public partial record Auth | ||
| > { | ||
| > public string ApplicationId { get; init; } = string.Empty; | ||
| > public string[]? Scopes { get; init; } = []; | ||
| > public string RedirectUri { get; init; } = string.Empty; | ||
| > public string KeychainSecurityGroup { get; init; } = string.Empty; | ||
| > } | ||
| > ``` | ||
|
|
||
| ## 2. Add the configuration settings into your `appsettings.json` file | ||
|
|
||
| ```json | ||
| { | ||
| "Auth": { | ||
| "ApplicationId": "my-app-id", | ||
| "Scopes": [ "openid", "profile" ], | ||
| "RedirectUri": "myapp://auth", | ||
| "KeychainSecurityGroup": "com.company.myapp" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| > [!WARNING] | ||
| > Especially for Authentication related Data which includes sensitive credentials like Client ID or a Client Secret, make sure to use a Credential Handler like in Development Environment the `dotnet user-secrets` and **do not** check in any of them into Source Control! | ||
|
|
||
| ## 3. Registering the configuration section | ||
|
|
||
| You can now use the `.Section<T>()` extension method on `IConfigBuilder` to load configuration information for class or record of the type argument you specify: | ||
|
|
||
| ```csharp | ||
| protected override void OnLaunched(LaunchActivatedEventArgs args) | ||
| { | ||
| var appBuilder = this.CreateBuilder(args) | ||
| .Configure(host => { | ||
| host.UseConfiguration(configure: configBuilder => | ||
| configBuilder | ||
| .AddEmbeddedSource<App>() | ||
| .Section<Auth>("Auth") | ||
| ... | ||
| }); | ||
| } | ||
| ``` | ||
|
|
||
| This binds the `Auth` section to the `Auth` record and makes it available through `IOptions<Auth>` or `IOptionsSnapshot<Auth>`. | ||
|
|
||
| ## 4. Consuming the options in a service | ||
|
|
||
| To access the instantiated representation of the configuration section you registered above, complete with values populated from the `appsettings.json` file, you'll need to add a new constructor parameter for it to one of your application's services. | ||
|
|
||
| The configuration section will be injected as an object of type `IOptions<T>`, so add a corresponding parameter for it to the constructor of the service: | ||
|
|
||
| ```csharp | ||
| using Microsoft.Extensions.Options; | ||
|
|
||
| public class AuthenticationService : IAuthenticationService | ||
| { | ||
| public AuthenticationService(IOptions<Auth> settings) | ||
| { | ||
| var authSettings = settings.Value; | ||
| ... | ||
| } | ||
| ... | ||
| } | ||
| ``` | ||
|
|
||
| ## Learn more about Configuration in Uno Apps | ||
|
|
||
| * [How To: Uno.Extensions.Configuration](xref:Uno.Extensions.Configuration.Overview) |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| --- | ||
| uid: Uno.Workshops.ToDo-App.LocalizeByModel | ||
| --- | ||
|
|
||
| # Changing App Localization from Model | ||
|
|
||
| ## The Home Page | ||
|
|
||
| [!code-xaml[](../src/ToDo/Views/HomePage.xaml)] | ||
|
|
||
| ## Code-Behind of Home Page | ||
|
|
||
| [!code-csharp[](../src/ToDo/Views/HomePage.xaml.cs)] | ||
|
|
||
| ## View Model of Home Page | ||
|
|
||
| [!code-csharp[](../src/ToDo/Presentation/HomeViewModel.cs)] | ||
|
Comment on lines
+1
to
+17
Contributor
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. I don't think having docs pages here is particularly useful if we are just displaying application code and nothing else
Contributor
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. Same goes for most of the other new .md files in this directory
Author
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. @kazo0 you mentioned it to be a possible reference for custom Auth and as its using msal packages from what I saw in the Auth Service, but this sample only has this entry in the Uno Docs But if we dont want this, feel free to tell what of this you would like to keep, if some or I can also just close this PR and delete the branch. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| --- | ||
| uid: Uno.Workshops.ToDo-App.LocalizeWithUid | ||
| --- | ||
| # Localize with using x:Uid | ||
|
|
||
| ## The TaskList Page | ||
|
|
||
| [!code-xaml[](../src/ToDo/Views/TaskListPage.xaml)] | ||
|
|
||
| ## Code-Behind of TaskList Page | ||
|
|
||
| [!code-csharp[](../src/ToDo/Views/TaskListPage.xaml.cs)] | ||
|
|
||
| ## View Model of TaskList Page | ||
|
|
||
| [!code-csharp[](../src/ToDo/Presentation/TaskListViewModel.cs)] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| --- | ||
| uid: Uno.Workshops.ToDo-App.Reactive-ListFeeds-FeedViews | ||
| --- | ||
|
|
||
| # Reactive ListFeeds with FeedView | ||
|
|
||
| ## Task List Page | ||
|
|
||
| [!code-xaml[](../src/ToDo/Views/TaskListPage.xaml)] | ||
|
|
||
| ## Model of Task List Page | ||
|
|
||
| [!code-csharp[](../src/ToDo/Presentation/TaskListViewModel.cs)] |
Uh oh!
There was an error while loading. Please reload this page.