From 641a3f8250cd2694ee8a902cf96e63eec657b2c1 Mon Sep 17 00:00:00 2001 From: Niels Laute Date: Mon, 27 Nov 2023 19:32:34 +0100 Subject: [PATCH 1/6] Switchpresenter loader --- .../SwitchPresenterLoaderSample.xaml | 56 +++++++++++++++++++ .../SwitchPresenterLoaderSample.xaml.cs | 15 +++++ 2 files changed, 71 insertions(+) create mode 100644 components/Primitives/samples/SwitchPresenter/SwitchPresenterLoaderSample.xaml create mode 100644 components/Primitives/samples/SwitchPresenter/SwitchPresenterLoaderSample.xaml.cs diff --git a/components/Primitives/samples/SwitchPresenter/SwitchPresenterLoaderSample.xaml b/components/Primitives/samples/SwitchPresenter/SwitchPresenterLoaderSample.xaml new file mode 100644 index 00000000..79dcf295 --- /dev/null +++ b/components/Primitives/samples/SwitchPresenter/SwitchPresenterLoaderSample.xaml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/Primitives/samples/SwitchPresenter/SwitchPresenterLoaderSample.xaml.cs b/components/Primitives/samples/SwitchPresenter/SwitchPresenterLoaderSample.xaml.cs new file mode 100644 index 00000000..4cafd4ea --- /dev/null +++ b/components/Primitives/samples/SwitchPresenter/SwitchPresenterLoaderSample.xaml.cs @@ -0,0 +1,15 @@ +// Licensed to the .NET Foundation under one or more agreements. +// The .NET Foundation licenses this file to you under the MIT license. +// See the LICENSE file in the project root for more information. + +namespace PrimitivesExperiment.Samples.SwitchPresenter; + +[ToolkitSampleBoolOption("LoadingState", true, Title = "IsLoading")] +[ToolkitSample(id: nameof(SwitchPresenterLoaderSample), "SwitchPresenter Loader", description: $"A sample for showing how to use a {nameof(SwitchPresenter)} for state changes from an enum.")] +public sealed partial class SwitchPresenterLoaderSample : Page +{ + public SwitchPresenterLoaderSample() + { + this.InitializeComponent(); + } +} From 2ad6303b7f885e082996c256c668b7690fa611a9 Mon Sep 17 00:00:00 2001 From: Niels Laute Date: Mon, 4 Dec 2023 16:38:12 +0100 Subject: [PATCH 2/6] Update SwitchPresenter.md --- components/Primitives/samples/SwitchPresenter.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/components/Primitives/samples/SwitchPresenter.md b/components/Primitives/samples/SwitchPresenter.md index e7ec2938..a9780c4f 100644 --- a/components/Primitives/samples/SwitchPresenter.md +++ b/components/Primitives/samples/SwitchPresenter.md @@ -12,6 +12,8 @@ issue-id: 0 icon: Assets/SwitchPresenter.png --- +> [!SAMPLE SwitchPresenterLoaderSample] + The `SwitchPresenter` control acts like a switch statement for XAML. It allows a developer to display certain content based on the condition of another value as an alternative to managing multiple Visibility values or complex visual states. Unlike traditional approaches of showing/hiding components within a page, the `SwitchPresenter` will only load and attach the matching Case's content to the Visual Tree. From 038307272604f6f308cf3f581a4004f0e8c88759 Mon Sep 17 00:00:00 2001 From: Niels Laute Date: Mon, 4 Dec 2023 17:28:41 +0100 Subject: [PATCH 3/6] Fixing bugs, adding animation and content --- .../samples/Primitives.Samples.csproj | 1 + .../Primitives/samples/SwitchPresenter.md | 8 +++--- .../SwitchPresenterLoaderSample.xaml | 25 ++++++++++++++++--- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/components/Primitives/samples/Primitives.Samples.csproj b/components/Primitives/samples/Primitives.Samples.csproj index 86904b1d..339c7f6d 100644 --- a/components/Primitives/samples/Primitives.Samples.csproj +++ b/components/Primitives/samples/Primitives.Samples.csproj @@ -9,6 +9,7 @@ + diff --git a/components/Primitives/samples/SwitchPresenter.md b/components/Primitives/samples/SwitchPresenter.md index a9780c4f..d1fa7db2 100644 --- a/components/Primitives/samples/SwitchPresenter.md +++ b/components/Primitives/samples/SwitchPresenter.md @@ -12,9 +12,7 @@ issue-id: 0 icon: Assets/SwitchPresenter.png --- -> [!SAMPLE SwitchPresenterLoaderSample] - -The `SwitchPresenter` control acts like a switch statement for XAML. It allows a developer to display certain content based on the condition of another value as an alternative to managing multiple Visibility values or complex visual states. +The `SwitchPresenter` control acts like a switch statement for XAML. It allows a developer to display certain content based on the condition of another value as an alternative to managing multiple `Visibility` values or complex visual states. Unlike traditional approaches of showing/hiding components within a page, the `SwitchPresenter` will only load and attach the matching Case's content to the Visual Tree. @@ -27,3 +25,7 @@ SwitchPresenter can make it easier to follow complex layout changes or layouts w Or it can simply be used to clearly display different outcomes based on some state which can be useful for a `NavigationView` or with a simple enum as in the following example: > [!SAMPLE SwitchPresenterValueSample] + +`SwitchPresenter` can also be used as a replacement for the deprecated `Loading` control: + +> [!SAMPLE SwitchPresenterLoaderSample] diff --git a/components/Primitives/samples/SwitchPresenter/SwitchPresenterLoaderSample.xaml b/components/Primitives/samples/SwitchPresenter/SwitchPresenterLoaderSample.xaml index 79dcf295..5a70c3f1 100644 --- a/components/Primitives/samples/SwitchPresenter/SwitchPresenterLoaderSample.xaml +++ b/components/Primitives/samples/SwitchPresenter/SwitchPresenterLoaderSample.xaml @@ -36,21 +36,38 @@ Duration="0:0:0.1" /> - + - + - + + + + + + + From eeda6f94cd8c9601172343a623048c6e3945d8a5 Mon Sep 17 00:00:00 2001 From: Niels Laute Date: Mon, 4 Dec 2023 17:29:03 +0100 Subject: [PATCH 4/6] XAML styling --- .../SwitchPresenterLoaderSample.xaml | 100 ++++++++---------- 1 file changed, 46 insertions(+), 54 deletions(-) diff --git a/components/Primitives/samples/SwitchPresenter/SwitchPresenterLoaderSample.xaml b/components/Primitives/samples/SwitchPresenter/SwitchPresenterLoaderSample.xaml index 5a70c3f1..54a8f50d 100644 --- a/components/Primitives/samples/SwitchPresenter/SwitchPresenterLoaderSample.xaml +++ b/components/Primitives/samples/SwitchPresenter/SwitchPresenterLoaderSample.xaml @@ -1,69 +1,61 @@ - + - - + + - - + + - + - + - + - - + + From a036090179d553338e2a6e89c29980585e442df0 Mon Sep 17 00:00:00 2001 From: Niels Laute Date: Mon, 4 Dec 2023 17:33:53 +0100 Subject: [PATCH 5/6] Update description --- .../samples/SwitchPresenter/SwitchPresenterLoaderSample.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/Primitives/samples/SwitchPresenter/SwitchPresenterLoaderSample.xaml.cs b/components/Primitives/samples/SwitchPresenter/SwitchPresenterLoaderSample.xaml.cs index 4cafd4ea..3619303f 100644 --- a/components/Primitives/samples/SwitchPresenter/SwitchPresenterLoaderSample.xaml.cs +++ b/components/Primitives/samples/SwitchPresenter/SwitchPresenterLoaderSample.xaml.cs @@ -5,7 +5,7 @@ namespace PrimitivesExperiment.Samples.SwitchPresenter; [ToolkitSampleBoolOption("LoadingState", true, Title = "IsLoading")] -[ToolkitSample(id: nameof(SwitchPresenterLoaderSample), "SwitchPresenter Loader", description: $"A sample for showing how to use a {nameof(SwitchPresenter)} for state changes from an enum.")] +[ToolkitSample(id: nameof(SwitchPresenterLoaderSample), "SwitchPresenter Loader", description: $"A sample for showing how to use a {nameof(SwitchPresenter)} to show a loading UI when data is loading.")] public sealed partial class SwitchPresenterLoaderSample : Page { public SwitchPresenterLoaderSample() From dcf5529a9d0640e89db75f3dc3244f7deaaca92c Mon Sep 17 00:00:00 2001 From: Niels Laute Date: Thu, 8 Feb 2024 17:56:44 +0100 Subject: [PATCH 6/6] Adding additional line --- components/Primitives/samples/SwitchPresenter.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/Primitives/samples/SwitchPresenter.md b/components/Primitives/samples/SwitchPresenter.md index d1fa7db2..471de5a6 100644 --- a/components/Primitives/samples/SwitchPresenter.md +++ b/components/Primitives/samples/SwitchPresenter.md @@ -26,6 +26,6 @@ Or it can simply be used to clearly display different outcomes based on some sta > [!SAMPLE SwitchPresenterValueSample] -`SwitchPresenter` can also be used as a replacement for the deprecated `Loading` control: +`SwitchPresenter` can also be used as a replacement for the deprecated `Loading` control. This provides more fine-grained control over animations and content within each state: > [!SAMPLE SwitchPresenterLoaderSample]