From 58298c9187374f3cf06efdff71ee302199ee4cbe Mon Sep 17 00:00:00 2001 From: Nick Randolph Date: Tue, 1 Nov 2022 16:50:16 +1100 Subject: [PATCH] feat: Adding reactive flag --- .../.template.config/dotnetcli.host.json | 4 ++ .../.template.config/ide.host.json | 12 +++++ .../.template.config/template.json | 6 +++ .../unoapp-extensions/Directory.Build.props | 1 + .../Directory.Packages.props | 1 + .../MyExtensionsApp.UI/App.xaml.host.cs | 11 ++-- .../MyExtensionsApp.UI/Views/MainPage.xaml | 18 ++++--- .../MyExtensionsApp.UI/Views/SecondPage.xaml | 5 ++ .../MyExtensionsApp/Business/Models/Entity.cs | 5 ++ .../MyExtensionsApp/MyExtensionsApp.csproj | 38 +++++++------ .../Presentation/MainViewModel.cs | 53 +++++++++++++++++-- .../Presentation/SecondViewModel.cs | 6 +-- 12 files changed, 125 insertions(+), 35 deletions(-) create mode 100644 src/Uno.Extensions.Templates/content/unoapp-extensions/MyExtensionsApp/Business/Models/Entity.cs diff --git a/src/Uno.Extensions.Templates/content/unoapp-extensions/.template.config/dotnetcli.host.json b/src/Uno.Extensions.Templates/content/unoapp-extensions/.template.config/dotnetcli.host.json index a61b636854..8bc7cfdf8b 100644 --- a/src/Uno.Extensions.Templates/content/unoapp-extensions/.template.config/dotnetcli.host.json +++ b/src/Uno.Extensions.Templates/content/unoapp-extensions/.template.config/dotnetcli.host.json @@ -41,6 +41,10 @@ "longName": "tests", "shortName": "tests" }, + "reactive": { + "longName": "reactive", + "shortName": "reactive" + }, "wasm-pwa-manifest": { "longName": "wasm-pwa-manifest", "shortName": "pwa" diff --git a/src/Uno.Extensions.Templates/content/unoapp-extensions/.template.config/ide.host.json b/src/Uno.Extensions.Templates/content/unoapp-extensions/.template.config/ide.host.json index 42c6aaa91f..3a17188114 100644 --- a/src/Uno.Extensions.Templates/content/unoapp-extensions/.template.config/ide.host.json +++ b/src/Uno.Extensions.Templates/content/unoapp-extensions/.template.config/ide.host.json @@ -129,6 +129,18 @@ }, "defaultValue": "true", "isVisible":true + }, + { + "id": "Reactive", + "name": { + "text": "Data - Reactive Extensions" + }, + "description": + { + "text": "Uses Reactive extensions" + }, + "defaultValue": "true", + "isVisible":true } ] } diff --git a/src/Uno.Extensions.Templates/content/unoapp-extensions/.template.config/template.json b/src/Uno.Extensions.Templates/content/unoapp-extensions/.template.config/template.json index 7629c833a8..5f2e935f1d 100644 --- a/src/Uno.Extensions.Templates/content/unoapp-extensions/.template.config/template.json +++ b/src/Uno.Extensions.Templates/content/unoapp-extensions/.template.config/template.json @@ -106,6 +106,12 @@ "defaultValue": "true", "description": "Includes unit and UI test projects" }, + "reactive": { + "type": "parameter", + "dataType": "bool", + "defaultValue": "true", + "description": "Whether or not to use Reactive extensions" + }, "mobile": { "type": "computed", "dataType": "bool", diff --git a/src/Uno.Extensions.Templates/content/unoapp-extensions/Directory.Build.props b/src/Uno.Extensions.Templates/content/unoapp-extensions/Directory.Build.props index 8b16110a09..ae49deea27 100644 --- a/src/Uno.Extensions.Templates/content/unoapp-extensions/Directory.Build.props +++ b/src/Uno.Extensions.Templates/content/unoapp-extensions/Directory.Build.props @@ -14,6 +14,7 @@ True $(NoWarn);Uno0001;CS1998;CA1416;NU1507 + $(DefineConstants);REACTIVE diff --git a/src/Uno.Extensions.Templates/content/unoapp-extensions/Directory.Packages.props b/src/Uno.Extensions.Templates/content/unoapp-extensions/Directory.Packages.props index 7ba4c8fbbd..ade7c1c555 100644 --- a/src/Uno.Extensions.Templates/content/unoapp-extensions/Directory.Packages.props +++ b/src/Uno.Extensions.Templates/content/unoapp-extensions/Directory.Packages.props @@ -1,5 +1,6 @@ + diff --git a/src/Uno.Extensions.Templates/content/unoapp-extensions/MyExtensionsApp.UI/App.xaml.host.cs b/src/Uno.Extensions.Templates/content/unoapp-extensions/MyExtensionsApp.UI/App.xaml.host.cs index 0544b1a514..86c2783680 100644 --- a/src/Uno.Extensions.Templates/content/unoapp-extensions/MyExtensionsApp.UI/App.xaml.host.cs +++ b/src/Uno.Extensions.Templates/content/unoapp-extensions/MyExtensionsApp.UI/App.xaml.host.cs @@ -1,5 +1,4 @@ //-:cnd:noEmit - namespace MyExtensionsApp; public sealed partial class App : Application @@ -46,7 +45,13 @@ private static IHost BuildAppHost() // Enable navigation, including registering views and viewmodels - .UseNavigation(ReactiveViewModelMappings.ViewModelMappings, RegisterRoutes) + .UseNavigation( +//+:cnd:noEmit +#if(reactive) + ReactiveViewModelMappings.ViewModelMappings, +#endif +//-:cnd:noEmit + RegisterRoutes) // Add navigation support for toolkit controls such as TabBar and NavigationView .UseToolkitNavigation() @@ -59,7 +64,7 @@ private static void RegisterRoutes(IViewRegistry views, IRouteRegistry routes) views.Register( new ViewMap(ViewModel: typeof(ShellViewModel)), new ViewMap(), - new ViewMap() + new DataViewMap() ); routes diff --git a/src/Uno.Extensions.Templates/content/unoapp-extensions/MyExtensionsApp.UI/Views/MainPage.xaml b/src/Uno.Extensions.Templates/content/unoapp-extensions/MyExtensionsApp.UI/Views/MainPage.xaml index c55c72c705..1950cc9859 100644 --- a/src/Uno.Extensions.Templates/content/unoapp-extensions/MyExtensionsApp.UI/Views/MainPage.xaml +++ b/src/Uno.Extensions.Templates/content/unoapp-extensions/MyExtensionsApp.UI/Views/MainPage.xaml @@ -8,6 +8,7 @@ xmlns:uen="using:Uno.Extensions.Navigation.UI" xmlns:utu="using:Uno.Toolkit.UI" xmlns:not_skia="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + NavigationCacheMode="Required" Background="{ThemeResource BackgroundBrush}"> @@ -16,11 +17,16 @@ -