From cd3129b0f778113802606d4d6e23abbb717d8035 Mon Sep 17 00:00:00 2001 From: DevTKSS Date: Wed, 20 Aug 2025 21:21:34 +0200 Subject: [PATCH 01/24] feat(MvuxListViewSample): Add Sampleapp from Mvux ListView Tutorial --- .vscode/launch.json | 20 +++ .vscode/tasks.json | 26 ++++ src/DevTKSS.Uno.SampleApps-Tutorials.slnf | 3 +- src/MvuxListApp/App.xaml | 29 ++++ src/MvuxListApp/App.xaml.cs | 98 +++++++++++++ src/MvuxListApp/Assets/Icons/icon.svg | 42 ++++++ .../Assets/Icons/icon_foreground.svg | 137 ++++++++++++++++++ src/MvuxListApp/Assets/SharedAssets.md | 32 ++++ .../Assets/Splash/splash_screen.svg | 137 ++++++++++++++++++ src/MvuxListApp/GlobalUsings.cs | 9 ++ src/MvuxListApp/Models/AppConfig.cs | 6 + src/MvuxListApp/Models/Entity.cs | 3 + src/MvuxListApp/MvuxListApp.csproj | 36 +++++ src/MvuxListApp/Package.appxmanifest | 31 ++++ src/MvuxListApp/Platforms/Desktop/Program.cs | 20 +++ src/MvuxListApp/Presentation/MainModel.cs | 65 +++++++++ src/MvuxListApp/Presentation/MainPage.xaml | 38 +++++ src/MvuxListApp/Presentation/MainPage.xaml.cs | 9 ++ src/MvuxListApp/Presentation/SecondModel.cs | 5 + src/MvuxListApp/Presentation/SecondPage.xaml | 28 ++++ .../Presentation/SecondPage.xaml.cs | 10 ++ src/MvuxListApp/Presentation/Shell.xaml | 36 +++++ src/MvuxListApp/Presentation/Shell.xaml.cs | 10 ++ src/MvuxListApp/Presentation/ShellModel.cs | 13 ++ .../PublishProfiles/win-arm64.pubxml | 18 +++ .../Properties/PublishProfiles/win-x64.pubxml | 18 +++ .../Properties/PublishProfiles/win-x86.pubxml | 23 +++ .../Properties/launchSettings.json | 22 +++ src/MvuxListApp/ReadMe.md | 7 + src/MvuxListApp/Strings/en/Resources.resw | 123 ++++++++++++++++ .../Styles/ColorPaletteOverride.xaml | 64 ++++++++ src/MvuxListApp/app.manifest | 25 ++++ src/MvuxListApp/appsettings.development.json | 5 + src/MvuxListApp/appsettings.json | 5 + 34 files changed, 1152 insertions(+), 1 deletion(-) create mode 100644 src/MvuxListApp/App.xaml create mode 100644 src/MvuxListApp/App.xaml.cs create mode 100644 src/MvuxListApp/Assets/Icons/icon.svg create mode 100644 src/MvuxListApp/Assets/Icons/icon_foreground.svg create mode 100644 src/MvuxListApp/Assets/SharedAssets.md create mode 100644 src/MvuxListApp/Assets/Splash/splash_screen.svg create mode 100644 src/MvuxListApp/GlobalUsings.cs create mode 100644 src/MvuxListApp/Models/AppConfig.cs create mode 100644 src/MvuxListApp/Models/Entity.cs create mode 100644 src/MvuxListApp/MvuxListApp.csproj create mode 100644 src/MvuxListApp/Package.appxmanifest create mode 100644 src/MvuxListApp/Platforms/Desktop/Program.cs create mode 100644 src/MvuxListApp/Presentation/MainModel.cs create mode 100644 src/MvuxListApp/Presentation/MainPage.xaml create mode 100644 src/MvuxListApp/Presentation/MainPage.xaml.cs create mode 100644 src/MvuxListApp/Presentation/SecondModel.cs create mode 100644 src/MvuxListApp/Presentation/SecondPage.xaml create mode 100644 src/MvuxListApp/Presentation/SecondPage.xaml.cs create mode 100644 src/MvuxListApp/Presentation/Shell.xaml create mode 100644 src/MvuxListApp/Presentation/Shell.xaml.cs create mode 100644 src/MvuxListApp/Presentation/ShellModel.cs create mode 100644 src/MvuxListApp/Properties/PublishProfiles/win-arm64.pubxml create mode 100644 src/MvuxListApp/Properties/PublishProfiles/win-x64.pubxml create mode 100644 src/MvuxListApp/Properties/PublishProfiles/win-x86.pubxml create mode 100644 src/MvuxListApp/Properties/launchSettings.json create mode 100644 src/MvuxListApp/ReadMe.md create mode 100644 src/MvuxListApp/Strings/en/Resources.resw create mode 100644 src/MvuxListApp/Styles/ColorPaletteOverride.xaml create mode 100644 src/MvuxListApp/app.manifest create mode 100644 src/MvuxListApp/appsettings.development.json create mode 100644 src/MvuxListApp/appsettings.json diff --git a/.vscode/launch.json b/.vscode/launch.json index 209ee0f..bf0bbdc 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -40,6 +40,26 @@ // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console "console": "internalConsole", "stopAtEntry": false + }, + { + // Use IntelliSense to find out which attributes exist for C# debugging + // Use hover for the description of the existing attributes + // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md + "name": "Uno Platform Desktop Debug (MvuxListApp)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build-desktop", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/MvuxListApp/bin/Debug/net9.0-desktop/MvuxListApp.dll", + "args": [], + "launchSettingsProfile": "MvuxListApp (Desktop)", + "env": { + "DOTNET_MODIFIABLE_ASSEMBLIES": "debug" + }, + "cwd": "${workspaceFolder}/MvuxListApp", + // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console + "console": "internalConsole", + "stopAtEntry": false }, { "name": "Uno Platform Desktop Debug (SimpleMemberSelectionApp)", diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 9230005..8d48eb4 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -78,6 +78,32 @@ "/consoleloggerparameters:NoSummary" ], "problemMatcher": "$msCompile" + }, + { + "label": "build-desktop MvuxListApp", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/MvuxListApp/MvuxListApp.csproj", + "/property:GenerateFullPaths=true", + "/property:TargetFramework=net9.0-desktop", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish-desktop MvuxListApp", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/MvuxListApp/MvuxListApp.csproj", + "/property:GenerateFullPaths=true", + "/property:TargetFramework=net9.0-desktop", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" } ] } \ No newline at end of file diff --git a/src/DevTKSS.Uno.SampleApps-Tutorials.slnf b/src/DevTKSS.Uno.SampleApps-Tutorials.slnf index 0278fab..7faffe5 100644 --- a/src/DevTKSS.Uno.SampleApps-Tutorials.slnf +++ b/src/DevTKSS.Uno.SampleApps-Tutorials.slnf @@ -2,7 +2,8 @@ "solution": { "path": "..\\DevTKSS.Uno.SampleApps.slnx", "projects": [ - "DevTKSS.Uno.XamlNavigationApp\\DevTKSS.Uno.XamlNavigationApp.csproj" + "DevTKSS.Uno.XamlNavigationApp\\DevTKSS.Uno.XamlNavigationApp.csproj", + "MvuxListApp\\MvuxListApp.csproj" ] } } \ No newline at end of file diff --git a/src/MvuxListApp/App.xaml b/src/MvuxListApp/App.xaml new file mode 100644 index 0000000..3ba6f8b --- /dev/null +++ b/src/MvuxListApp/App.xaml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + + + + diff --git a/src/MvuxListApp/App.xaml.cs b/src/MvuxListApp/App.xaml.cs new file mode 100644 index 0000000..a6c29fc --- /dev/null +++ b/src/MvuxListApp/App.xaml.cs @@ -0,0 +1,98 @@ +using Uno.Resizetizer; + +namespace MvuxListApp; +public partial class App : Application +{ + /// + /// Initializes the singleton application object. This is the first line of authored code + /// executed, and as such is the logical equivalent of main() or WinMain(). + /// + public App() + { + this.InitializeComponent(); + } + + protected Window? MainWindow { get; private set; } + protected IHost? Host { get; private set; } + + protected async override void OnLaunched(LaunchActivatedEventArgs args) + { + var builder = this.CreateBuilder(args) + // Add navigation support for toolkit controls such as TabBar and NavigationView + .UseToolkitNavigation() + .Configure(host => host +#if DEBUG + // Switch to Development environment when running in DEBUG + .UseEnvironment(Environments.Development) +#endif + .UseLogging(configure: (context, logBuilder) => + { + // Configure log levels for different categories of logging + logBuilder + .SetMinimumLevel( + context.HostingEnvironment.IsDevelopment() ? + LogLevel.Information : + LogLevel.Warning) + + // Default filters for core Uno Platform namespaces + .CoreLogLevel(LogLevel.Warning); + + // Uno Platform namespace filter groups + // Uncomment individual methods to see more detailed logging + //// Generic Xaml events + //logBuilder.XamlLogLevel(LogLevel.Debug); + //// Layout specific messages + //logBuilder.XamlLayoutLogLevel(LogLevel.Debug); + //// Storage messages + //logBuilder.StorageLogLevel(LogLevel.Debug); + //// Binding related messages + //logBuilder.XamlBindingLogLevel(LogLevel.Debug); + //// Binder memory references tracking + //logBuilder.BinderMemoryReferenceLogLevel(LogLevel.Debug); + //// DevServer and HotReload related + //logBuilder.HotReloadCoreLogLevel(LogLevel.Information); + //// Debug JS interop + //logBuilder.WebAssemblyLogLevel(LogLevel.Debug); + + }, enableUnoLogging: true) + .UseConfiguration(configure: configBuilder => + configBuilder + .EmbeddedSource() + .Section() + ) + .ConfigureServices((context, services) => + { + // TODO: Register your services + //services.AddSingleton(); + }) + .UseNavigation(ReactiveViewModelMappings.ViewModelMappings, RegisterRoutes) + ); + MainWindow = builder.Window; + +#if DEBUG + MainWindow.UseStudio(); +#endif + MainWindow.SetWindowIcon(); + + Host = await builder.NavigateAsync(); + } + + private static void RegisterRoutes(IViewRegistry views, IRouteRegistry routes) + { + views.Register( + new ViewMap(ViewModel: typeof(ShellModel)), + new ViewMap(), + new DataViewMap() + ); + + routes.Register( + new RouteMap("", View: views.FindByViewModel(), + Nested: + [ + new ("Main", View: views.FindByViewModel(), IsDefault:true), + new ("Second", View: views.FindByViewModel()), + ] + ) + ); + } +} diff --git a/src/MvuxListApp/Assets/Icons/icon.svg b/src/MvuxListApp/Assets/Icons/icon.svg new file mode 100644 index 0000000..a15af53 --- /dev/null +++ b/src/MvuxListApp/Assets/Icons/icon.svg @@ -0,0 +1,42 @@ + + + + + + diff --git a/src/MvuxListApp/Assets/Icons/icon_foreground.svg b/src/MvuxListApp/Assets/Icons/icon_foreground.svg new file mode 100644 index 0000000..8ffc41a --- /dev/null +++ b/src/MvuxListApp/Assets/Icons/icon_foreground.svg @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/MvuxListApp/Assets/SharedAssets.md b/src/MvuxListApp/Assets/SharedAssets.md new file mode 100644 index 0000000..b1cc4e7 --- /dev/null +++ b/src/MvuxListApp/Assets/SharedAssets.md @@ -0,0 +1,32 @@ +# Shared Assets + +See documentation about assets here: https://github.com/unoplatform/uno/blob/master/doc/articles/features/working-with-assets.md + +## Here is a cheat sheet + +1. Add the image file to the `Assets` directory of a shared project. +2. Set the build action to `Content`. +3. (Recommended) Provide an asset for various scales/dpi + +### Examples + +```text +\Assets\Images\logo.scale-100.png +\Assets\Images\logo.scale-200.png +\Assets\Images\logo.scale-400.png + +\Assets\Images\scale-100\logo.png +\Assets\Images\scale-200\logo.png +\Assets\Images\scale-400\logo.png +``` + +### Table of scales + +| Scale | WinUI | iOS | Android | +|-------|:-----------:|:---------------:|:-------:| +| `100` | scale-100 | @1x | mdpi | +| `125` | scale-125 | N/A | N/A | +| `150` | scale-150 | N/A | hdpi | +| `200` | scale-200 | @2x | xhdpi | +| `300` | scale-300 | @3x | xxhdpi | +| `400` | scale-400 | N/A | xxxhdpi | diff --git a/src/MvuxListApp/Assets/Splash/splash_screen.svg b/src/MvuxListApp/Assets/Splash/splash_screen.svg new file mode 100644 index 0000000..8ffc41a --- /dev/null +++ b/src/MvuxListApp/Assets/Splash/splash_screen.svg @@ -0,0 +1,137 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/MvuxListApp/GlobalUsings.cs b/src/MvuxListApp/GlobalUsings.cs new file mode 100644 index 0000000..9b249ca --- /dev/null +++ b/src/MvuxListApp/GlobalUsings.cs @@ -0,0 +1,9 @@ +global using System.Collections.Immutable; +global using Microsoft.Extensions.DependencyInjection; +global using Microsoft.Extensions.Hosting; +global using Microsoft.Extensions.Logging; +global using Microsoft.Extensions.Options; +global using MvuxListApp.Models; +global using MvuxListApp.Presentation; +global using ApplicationExecutionState = Windows.ApplicationModel.Activation.ApplicationExecutionState; +[assembly: Uno.Extensions.Reactive.Config.BindableGenerationTool(3)] diff --git a/src/MvuxListApp/Models/AppConfig.cs b/src/MvuxListApp/Models/AppConfig.cs new file mode 100644 index 0000000..3357157 --- /dev/null +++ b/src/MvuxListApp/Models/AppConfig.cs @@ -0,0 +1,6 @@ +namespace MvuxListApp.Models; + +public record AppConfig +{ + public string? Environment { get; init; } +} diff --git a/src/MvuxListApp/Models/Entity.cs b/src/MvuxListApp/Models/Entity.cs new file mode 100644 index 0000000..4a2873b --- /dev/null +++ b/src/MvuxListApp/Models/Entity.cs @@ -0,0 +1,3 @@ +namespace MvuxListApp.Models; + +public record Entity(string Name); diff --git a/src/MvuxListApp/MvuxListApp.csproj b/src/MvuxListApp/MvuxListApp.csproj new file mode 100644 index 0000000..24f7f6a --- /dev/null +++ b/src/MvuxListApp/MvuxListApp.csproj @@ -0,0 +1,36 @@ + + + net9.0-desktop + + Exe + true + + + MvuxListApp + + com.companyname.MvuxListApp + + 1.0 + 1 + + Sonja + + MvuxListApp powered by Uno Platform. + + + + Material; + Hosting; + Toolkit; + Logging; + MVUX; + Configuration; + Navigation; + SkiaRenderer; + + + + diff --git a/src/MvuxListApp/Package.appxmanifest b/src/MvuxListApp/Package.appxmanifest new file mode 100644 index 0000000..9ef3814 --- /dev/null +++ b/src/MvuxListApp/Package.appxmanifest @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/MvuxListApp/Platforms/Desktop/Program.cs b/src/MvuxListApp/Platforms/Desktop/Program.cs new file mode 100644 index 0000000..01d8d6a --- /dev/null +++ b/src/MvuxListApp/Platforms/Desktop/Program.cs @@ -0,0 +1,20 @@ +using Uno.UI.Hosting; + +namespace MvuxListApp; +internal class Program +{ + [STAThread] + public static void Main(string[] args) + { + + var host = UnoPlatformHostBuilder.Create() + .App(() => new App()) + .UseX11() + .UseLinuxFrameBuffer() + .UseMacOS() + .UseWin32() + .Build(); + + host.Run(); + } +} diff --git a/src/MvuxListApp/Presentation/MainModel.cs b/src/MvuxListApp/Presentation/MainModel.cs new file mode 100644 index 0000000..14e7491 --- /dev/null +++ b/src/MvuxListApp/Presentation/MainModel.cs @@ -0,0 +1,65 @@ +using System.Data; +using Uno.Equality; +using Uno.Extensions.Reactive.Commands; + +namespace MvuxListApp.Presentation; + +public partial record MainModel +{ + private readonly ILogger _logger; + private INavigator _navigator; + private readonly IRouteNotifier _routeNotifier; + public MainModel( + IOptions appInfo, + INavigator navigator, + IRouteNotifier routeNotifier, + ILogger logger) + { + _navigator = navigator; + _routeNotifier = routeNotifier; + _routeNotifier.RouteChanged += Main_OnRouteChanged; + _logger = logger; + } + + + + public IState Title => State.Value(this, () => _navigator.Route?.ToString() ?? string.Empty); + + private async ValueTask> GetMembersAsync(CancellationToken ct) + => _listMembers; + + private readonly IImmutableList _listMembers = ImmutableList.Create( + [ + "Hans", + "Lisa", + "Anke", + "Tom" + ]); + private async void Main_OnRouteChanged(object? sender, RouteChangedEventArgs e) + { + await Title.SetAsync(e.Navigator?.Route?.ToString()); + } + + public IListState DashboardList => ListState.Async(this,GetMembersAsync) + .Selection(SelectedMember); + + public IState SelectedMember => State.Value(this,() => string.Empty); + + public IState ModifyedMemberName => State.Empty(this) + .ForEach(RenameMemberAsync); + + public async ValueTask RenameMemberAsync([FeedParameter(nameof(ModifyedMemberName))]string? modifyedName, CancellationToken ct) + { + + string replaceMeItem = await SelectedMember ?? string.Empty; + string modifyedItem = await ModifyedMemberName ?? string.Empty; + _logger.LogInformation("Modifyed MemberName ist:" + modifyedItem); + _logger.LogInformation("SelectedMemeber ist:" + replaceMeItem); + + await DashboardList.RemoveAllAsync(item => item == replaceMeItem); + + await DashboardList.AddAsync(modifyedItem,ct); + + await DashboardList.TrySelectAsync(modifyedItem,ct); + } +} diff --git a/src/MvuxListApp/Presentation/MainPage.xaml b/src/MvuxListApp/Presentation/MainPage.xaml new file mode 100644 index 0000000..3b6f7d8 --- /dev/null +++ b/src/MvuxListApp/Presentation/MainPage.xaml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + +