diff --git a/UI/ChatUI/src/.editorconfig b/UI/ChatUI/src/.editorconfig index b947be645..bf543a185 100644 --- a/UI/ChatUI/src/.editorconfig +++ b/UI/ChatUI/src/.editorconfig @@ -9,11 +9,30 @@ root = true ########################################## [*] -indent_style = space +indent_style = tab end_of_line = crlf trim_trailing_whitespace = true insert_final_newline = true charset = utf-8 +dotnet_style_operator_placement_when_wrapping = beginning_of_line +tab_width = 4 +indent_size = 4 +dotnet_style_coalesce_expression = true:suggestion +dotnet_style_null_propagation = true:suggestion +dotnet_style_prefer_is_null_check_over_reference_equality_method = true:suggestion +dotnet_style_prefer_auto_properties = true:silent +dotnet_style_object_initializer = true:suggestion +dotnet_style_collection_initializer = true:suggestion +dotnet_style_prefer_simplified_boolean_expressions = true:suggestion +dotnet_style_prefer_conditional_expression_over_assignment = true:silent +dotnet_style_prefer_conditional_expression_over_return = true:silent +dotnet_style_explicit_tuple_names = true:suggestion +dotnet_style_prefer_inferred_tuple_names = true:suggestion +dotnet_style_prefer_inferred_anonymous_type_member_names = true:suggestion +dotnet_style_prefer_compound_assignment = true:suggestion +dotnet_style_prefer_simplified_interpolation = true:suggestion +dotnet_style_prefer_collection_expression = when_types_loosely_match:suggestion +dotnet_style_namespace_match_folder = true:suggestion ########################################## # File Extension Settings @@ -31,40 +50,40 @@ indent_style = tab indent_size = 2 [*.{csproj,proj,projitems,shproj}] -indent_size = 2 +indent_size = 4 [*.{json,slnf}] indent_size = 2 end_of_line = lf [*.{props,targets}] -indent_size = 2 +indent_size = 4 [*.xaml] -indent_size = 2 +indent_size = 4 charset = utf-8-bom [*.xml] -indent_size = 2 +indent_size = 4 end_of_line = lf [*.plist] -indent_size = 2 +indent_size = 4 indent_style = tab end_of_line = lf [*.manifest] -indent_size = 2 +indent_size = 4 [*.appxmanifest] -indent_size = 2 +indent_size = 4 [*.{json,css,webmanifest}] indent_size = 2 end_of_line = lf [web.config] -indent_size = 2 +indent_size = 4 end_of_line = lf [*.sh] @@ -165,3 +184,17 @@ csharp_style_expression_bodied_indexers = true:silent csharp_style_expression_bodied_accessors = true:silent csharp_style_expression_bodied_lambdas = true:silent csharp_style_expression_bodied_local_functions = false:silent +csharp_space_around_binary_operators = before_and_after +csharp_prefer_system_threading_lock = true:suggestion +csharp_style_throw_expression = true:suggestion +csharp_style_prefer_null_check_over_type_check = true:suggestion +csharp_prefer_simple_default_expression = true:suggestion +csharp_style_prefer_local_over_anonymous_function = true:suggestion +csharp_style_prefer_index_operator = true:suggestion +csharp_style_prefer_range_operator = true:suggestion +csharp_style_implicit_object_creation_when_type_is_apparent = true:suggestion +csharp_style_prefer_implicitly_typed_lambda_expression = true:suggestion +csharp_style_prefer_tuple_swap = true:suggestion +csharp_style_prefer_unbound_generic_type_in_nameof = true:suggestion +csharp_style_prefer_utf8_string_literals = true:suggestion +csharp_style_inlined_variable_declaration = true:suggestion diff --git a/UI/ChatUI/src/.gitignore b/UI/ChatUI/src/.gitignore index ef88c2053..64f871fce 100644 --- a/UI/ChatUI/src/.gitignore +++ b/UI/ChatUI/src/.gitignore @@ -1,7 +1,10 @@ ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. ## -## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore +## Get latest from `dotnet new gitignore` + +# dotenv files +.env # User-specific files *.rsuser @@ -57,11 +60,14 @@ dlldata.c # Benchmark Results BenchmarkDotNet.Artifacts/ -# .NET Core +# .NET project.lock.json project.fragment.lock.json artifacts/ +# Tye +.tye/ + # ASP.NET Scaffolding ScaffoldingReadMe.txt @@ -82,6 +88,8 @@ StyleCopReport.xml *.pgc *.pgd *.rsp +# but not Directory.Build.rsp, as it configures directory-level build defaults +!Directory.Build.rsp *.sbr *.tlb *.tli @@ -396,6 +404,82 @@ FodyWeavers.xsd # JetBrains Rider *.sln.iml +.idea/ + +## +## Visual studio for Mac +## + + +# globs +Makefile.in +*.userprefs +*.usertasks +config.make +config.status +aclocal.m4 +install-sh +autom4te.cache/ +*.tar.gz +tarballs/ +test-results/ + +# content below from: https://github.com/github/gitignore/blob/main/Global/macOS.gitignore +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# content below from: https://github.com/github/gitignore/blob/main/Global/Windows.gitignore +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# Vim temporary swap files +*.swp # Single Target Config solution-config.props diff --git a/UI/ChatUI/src/.run/ChatUI.run.xml b/UI/ChatUI/src/.run/ChatUI.run.xml new file mode 100644 index 000000000..696ed50ce --- /dev/null +++ b/UI/ChatUI/src/.run/ChatUI.run.xml @@ -0,0 +1,47 @@ + + + + + + + + diff --git a/UI/ChatUI/src/.run/Readme.md b/UI/ChatUI/src/.run/Readme.md new file mode 100644 index 000000000..6e72638a0 --- /dev/null +++ b/UI/ChatUI/src/.run/Readme.md @@ -0,0 +1,3 @@ +# About the `.run` folder + +This folder is present to add support for the [Rider IDE](https://aka.platform.uno/rider-getstarted). You can remove this folder safely if you're not using Rider. diff --git a/UI/ChatUI/src/.vscode/extensions.json b/UI/ChatUI/src/.vscode/extensions.json new file mode 100644 index 000000000..a63ad4009 --- /dev/null +++ b/UI/ChatUI/src/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "unoplatform.vscode" + ], +} diff --git a/UI/ChatUI/src/.vscode/launch.json b/UI/ChatUI/src/.vscode/launch.json new file mode 100644 index 000000000..3f80b9031 --- /dev/null +++ b/UI/ChatUI/src/.vscode/launch.json @@ -0,0 +1,77 @@ +{ + // 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 + "version": "0.2.0", + "configurations": [ + { + "name": "Uno Platform Mobile Debug", + "type": "Uno", + "request": "launch", + // any Uno* task will do, this is simply to satisfy vscode requirement when a launch.json is present + "preLaunchTask": "Uno: android | Debug | android-x64" + }, + { + // 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 WebAssembly Debug (Chrome)", + "type": "chrome", + "request": "launch", + "url": "http://localhost:5000", + "webRoot": "${workspaceFolder}/ChatUI", + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", + "timeout": 30000, + "preLaunchTask": "build-wasm", + "server": { + "runtimeExecutable": "dotnet", + "program": "run", + "args": ["--no-build","-f","net9.0-browserwasm","--launch-profile", "ChatUI (WebAssembly)"], + "outputCapture": "std", + "timeout": 30000, + "cwd": "${workspaceFolder}/ChatUI" + } + }, + { + // 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 WebAssembly Debug (Edge)", + "type": "msedge", + "request": "launch", + "url": "http://localhost:5000", + "webRoot": "${workspaceFolder}/ChatUI", + "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", + "timeout": 30000, + "preLaunchTask": "build-wasm", + "server": { + "runtimeExecutable": "dotnet", + "program": "run", + "args": ["--no-build","-f","net9.0-browserwasm","--launch-profile", "ChatUI (WebAssembly)"], + "outputCapture": "std", + "timeout": 30000, + "cwd": "${workspaceFolder}/ChatUI" + } + }, + { + // 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", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build-desktop", + // If you have changed target frameworks, make sure to update the program path. + "program": "${workspaceFolder}/ChatUI/bin/Debug/net9.0-desktop/ChatUI.dll", + "args": [], + "launchSettingsProfile": "ChatUI (Desktop)", + "env": { + "DOTNET_MODIFIABLE_ASSEMBLIES": "debug" + }, + "cwd": "${workspaceFolder}/ChatUI", + // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console + "console": "internalConsole", + "stopAtEntry": false + }, + ] +} diff --git a/UI/ChatUI/src/.vscode/settings.json b/UI/ChatUI/src/.vscode/settings.json new file mode 100644 index 000000000..3405922d5 --- /dev/null +++ b/UI/ChatUI/src/.vscode/settings.json @@ -0,0 +1,10 @@ +{ + "explorer.fileNesting.enabled": true, + "explorer.fileNesting.expand": false, + "explorer.fileNesting.patterns": { + "*.xaml": "$(capture).xaml.cs" + }, + "files.associations": { + "global.json": "jsonc" + } +} diff --git a/UI/ChatUI/src/.vscode/tasks.json b/UI/ChatUI/src/.vscode/tasks.json new file mode 100644 index 000000000..30fb74a39 --- /dev/null +++ b/UI/ChatUI/src/.vscode/tasks.json @@ -0,0 +1,57 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build-wasm", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/ChatUI/ChatUI.csproj", + "/property:GenerateFullPaths=true", + "/property:TargetFramework=net9.0-browserwasm", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish-wasm", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/ChatUI/ChatUI.csproj", + "/property:GenerateFullPaths=true", + "/property:TargetFramework=net9.0-browserwasm", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "build-desktop", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/ChatUI/ChatUI.csproj", + "/property:GenerateFullPaths=true", + "/property:TargetFramework=net9.0-desktop", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + }, + { + "label": "publish-desktop", + "command": "dotnet", + "type": "process", + "args": [ + "publish", + "${workspaceFolder}/ChatUI/ChatUI.csproj", + "/property:GenerateFullPaths=true", + "/property:TargetFramework=net9.0-desktop", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + } + ] +} diff --git a/UI/ChatUI/src/.vsconfig b/UI/ChatUI/src/.vsconfig index 0439670d0..f6ff3911b 100644 --- a/UI/ChatUI/src/.vsconfig +++ b/UI/ChatUI/src/.vsconfig @@ -16,7 +16,6 @@ "Microsoft.VisualStudio.ComponentGroup.Web.Client", "Microsoft.VisualStudio.Workload.NetWeb", "Microsoft.VisualStudio.ComponentGroup.WebToolsExtensions.TemplateEngine", - "Microsoft.VisualStudio.ComponentGroup.MSIX.Packaging", "Microsoft.VisualStudio.Component.ManagedDesktop.Prerequisites", "Microsoft.VisualStudio.Component.Debugger.JustInTime", "Microsoft.VisualStudio.Workload.ManagedDesktop", @@ -27,8 +26,5 @@ "Component.OpenJDK", "Microsoft.VisualStudio.Workload.NetCrossPlat", "Microsoft.VisualStudio.Workload.NetCoreTools" - ], - "extensions": [ - "https://marketplace.visualstudio.com/items?itemName=unoplatform.uno-platform-addin-2022" ] } diff --git a/UI/ChatUI/src/ChatUI.sln b/UI/ChatUI/src/ChatUI.sln index 63d130ce9..f438fb07f 100644 --- a/UI/ChatUI/src/ChatUI.sln +++ b/UI/ChatUI/src/ChatUI.sln @@ -1,16 +1,14 @@ + Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 -VisualStudioVersion = 17.2.32210.308 -MinimumVisualStudioVersion = 15.0.26124.0 - -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ChatUI", "ChatUI\ChatUI.csproj", "{DD0412B8-7520-40B6-9606-B42B83F09A2E}" +VisualStudioVersion = 17.14.36429.23 d17.14 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChatUI", "ChatUI\ChatUI.csproj", "{C7C2D12E-FCFD-4B4C-BB91-DF3517A77DC9}" EndProject - -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{BADA71DC-7FFD-4EDC-9F28-FB74AEADC713}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}" ProjectSection(SolutionItems) = preProject .editorconfig = .editorconfig .gitignore = .gitignore - .vsconfig = .vsconfig Directory.Build.props = Directory.Build.props Directory.Build.targets = Directory.Build.targets Directory.Packages.props = Directory.Packages.props @@ -20,70 +18,20 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU - Debug|ARM = Debug|ARM - Debug|ARM64 = Debug|ARM64 - Debug|iPhone = Debug|iPhone - Debug|iPhoneSimulator = Debug|iPhoneSimulator - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 Release|Any CPU = Release|Any CPU - Release|ARM = Release|ARM - Release|ARM64 = Release|ARM64 - Release|iPhone = Release|iPhone - Release|iPhoneSimulator = Release|iPhoneSimulator - Release|x64 = Release|x64 - Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Debug|Any CPU.Deploy.0 = Debug|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Debug|ARM.ActiveCfg = Debug|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Debug|ARM.Build.0 = Debug|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Debug|ARM.Deploy.0 = Debug|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Debug|ARM64.ActiveCfg = Debug|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Debug|ARM64.Build.0 = Debug|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Debug|ARM64.Deploy.0 = Debug|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Debug|iPhone.ActiveCfg = Debug|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Debug|iPhone.Build.0 = Debug|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Debug|iPhone.Deploy.0 = Debug|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Debug|iPhoneSimulator.Deploy.0 = Debug|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Debug|x64.ActiveCfg = Debug|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Debug|x64.Build.0 = Debug|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Debug|x64.Deploy.0 = Debug|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Debug|x86.ActiveCfg = Debug|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Debug|x86.Build.0 = Debug|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Debug|x86.Deploy.0 = Debug|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Release|Any CPU.Build.0 = Release|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Release|Any CPU.Deploy.0 = Release|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Release|ARM.ActiveCfg = Release|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Release|ARM.Build.0 = Release|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Release|ARM.Deploy.0 = Release|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Release|ARM64.ActiveCfg = Release|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Release|ARM64.Build.0 = Release|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Release|ARM64.Deploy.0 = Release|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Release|iPhone.ActiveCfg = Release|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Release|iPhone.Build.0 = Release|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Release|iPhone.Deploy.0 = Release|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Release|iPhoneSimulator.Build.0 = Release|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Release|iPhoneSimulator.Deploy.0 = Release|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Release|x64.ActiveCfg = Release|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Release|x64.Build.0 = Release|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Release|x64.Deploy.0 = Release|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Release|x86.ActiveCfg = Release|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Release|x86.Build.0 = Release|Any CPU - {DD0412B8-7520-40B6-9606-B42B83F09A2E}.Release|x86.Deploy.0 = Release|Any CPU + {C7C2D12E-FCFD-4B4C-BB91-DF3517A77DC9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C7C2D12E-FCFD-4B4C-BB91-DF3517A77DC9}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C7C2D12E-FCFD-4B4C-BB91-DF3517A77DC9}.Debug|Any CPU.Deploy.0 = Debug|Any CPU + {C7C2D12E-FCFD-4B4C-BB91-DF3517A77DC9}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C7C2D12E-FCFD-4B4C-BB91-DF3517A77DC9}.Release|Any CPU.Build.0 = Release|Any CPU + {C7C2D12E-FCFD-4B4C-BB91-DF3517A77DC9}.Release|Any CPU.Deploy.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE EndGlobalSection - GlobalSection(NestedProjects) = preSolution - EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {DC039F1F-B795-4AEA-94A6-ECE1DB699A51} + SolutionGuid = {0426B7AB-C6BF-4015-8B2C-0A24BB7B27DF} EndGlobalSection EndGlobal diff --git a/UI/ChatUI/src/ChatUI/App.xaml b/UI/ChatUI/src/ChatUI/App.xaml index 24772655c..d9b56d71c 100644 --- a/UI/ChatUI/src/ChatUI/App.xaml +++ b/UI/ChatUI/src/ChatUI/App.xaml @@ -1,17 +1,12 @@  - - - - - - - - - - - - - + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> + + + + + + + + diff --git a/UI/ChatUI/src/ChatUI/App.xaml.cs b/UI/ChatUI/src/ChatUI/App.xaml.cs index cdd1df73b..d767ca18e 100644 --- a/UI/ChatUI/src/ChatUI/App.xaml.cs +++ b/UI/ChatUI/src/ChatUI/App.xaml.cs @@ -1,128 +1,128 @@ -using Uno.Resizetizer; - namespace ChatUI; - 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 override void OnLaunched(LaunchActivatedEventArgs args) - { - MainWindow = new Window(); + /// + /// 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 override void OnLaunched(LaunchActivatedEventArgs args) + { + MainWindow = new Window(); #if DEBUG - MainWindow.EnableHotReload(); + MainWindow.UseStudio(); #endif - // Do not repeat app initialization when the Window already has content, - // just ensure that the window is active - if (MainWindow.Content is not Frame rootFrame) - { - // Create a Frame to act as the navigation context and navigate to the first page - rootFrame = new Frame(); - - // Place the frame in the current Window - MainWindow.Content = rootFrame; - - rootFrame.NavigationFailed += OnNavigationFailed; - } - - if (rootFrame.Content == null) - { - // When the navigation stack isn't restored navigate to the first page, - // configuring the new page by passing required information as a navigation - // parameter - rootFrame.Navigate(typeof(MainPage), args.Arguments); - } - - MainWindow.SetWindowIcon(); - // Ensure the current window is active - MainWindow.Activate(); - } - - /// - /// Invoked when Navigation to a certain page fails - /// - /// The Frame which failed navigation - /// Details about the navigation failure - void OnNavigationFailed(object sender, NavigationFailedEventArgs e) - { - throw new InvalidOperationException($"Failed to load {e.SourcePageType.FullName}: {e.Exception}"); - } - - /// - /// Configures global Uno Platform logging - /// - public static void InitializeLogging() - { + // Do not repeat app initialization when the Window already has content, + // just ensure that the window is active + if (MainWindow.Content is not Frame rootFrame) + { + // Create a Frame to act as the navigation context and navigate to the first page + rootFrame = new Frame(); + + // Place the frame in the current Window + MainWindow.Content = rootFrame; + + rootFrame.NavigationFailed += OnNavigationFailed; + } + + if (rootFrame.Content == null) + { + // When the navigation stack isn't restored navigate to the first page, + // configuring the new page by passing required information as a navigation + // parameter + rootFrame.Navigate(typeof(MainPage), args.Arguments); + } + + MainWindow.SetWindowIcon(); + // Ensure the current window is active + MainWindow.Activate(); + } + + /// + /// Invoked when Navigation to a certain page fails + /// + /// The Frame which failed navigation + /// Details about the navigation failure + void OnNavigationFailed(object sender, NavigationFailedEventArgs e) + { + throw new InvalidOperationException($"Failed to load {e.SourcePageType.FullName}: {e.Exception}"); + } + + /// + /// Configures global Uno Platform logging + /// + public static void InitializeLogging() + { #if DEBUG - // Logging is disabled by default for release builds, as it incurs a significant - // initialization cost from Microsoft.Extensions.Logging setup. If startup performance - // is a concern for your application, keep this disabled. If you're running on the web or - // desktop targets, you can use URL or command line parameters to enable it. - // - // For more performance documentation: https://platform.uno/docs/articles/Uno-UI-Performance.html - - var factory = LoggerFactory.Create(builder => - { + // Logging is disabled by default for release builds, as it incurs a significant + // initialization cost from Microsoft.Extensions.Logging setup. If startup performance + // is a concern for your application, keep this disabled. If you're running on the web or + // desktop targets, you can use URL or command line parameters to enable it. + // + // For more performance documentation: https://platform.uno/docs/articles/Uno-UI-Performance.html + + var factory = LoggerFactory.Create(builder => + { #if __WASM__ - builder.AddProvider(new global::Uno.Extensions.Logging.WebAssembly.WebAssemblyConsoleLoggerProvider()); -#elif __IOS__ || __MACCATALYST__ - builder.AddProvider(new global::Uno.Extensions.Logging.OSLogLoggerProvider()); + builder.AddProvider(new global::Uno.Extensions.Logging.WebAssembly.WebAssemblyConsoleLoggerProvider()); +#elif __IOS__ + builder.AddProvider(new global::Uno.Extensions.Logging.OSLogLoggerProvider()); + + // Log to the Visual Studio Debug console + builder.AddConsole(); #else - builder.AddConsole(); + builder.AddConsole(); #endif - // Exclude logs below this level - builder.SetMinimumLevel(LogLevel.Information); + // Exclude logs below this level + builder.SetMinimumLevel(LogLevel.Information); - // Default filters for Uno Platform namespaces - builder.AddFilter("Uno", LogLevel.Warning); - builder.AddFilter("Windows", LogLevel.Warning); - builder.AddFilter("Microsoft", LogLevel.Warning); + // Default filters for Uno Platform namespaces + builder.AddFilter("Uno", LogLevel.Warning); + builder.AddFilter("Windows", LogLevel.Warning); + builder.AddFilter("Microsoft", LogLevel.Warning); - // Generic Xaml events - // builder.AddFilter("Microsoft.UI.Xaml", LogLevel.Debug ); - // builder.AddFilter("Microsoft.UI.Xaml.VisualStateGroup", LogLevel.Debug ); - // builder.AddFilter("Microsoft.UI.Xaml.StateTriggerBase", LogLevel.Debug ); - // builder.AddFilter("Microsoft.UI.Xaml.UIElement", LogLevel.Debug ); - // builder.AddFilter("Microsoft.UI.Xaml.FrameworkElement", LogLevel.Trace ); + // Generic Xaml events + // builder.AddFilter("Microsoft.UI.Xaml", LogLevel.Debug ); + // builder.AddFilter("Microsoft.UI.Xaml.VisualStateGroup", LogLevel.Debug ); + // builder.AddFilter("Microsoft.UI.Xaml.StateTriggerBase", LogLevel.Debug ); + // builder.AddFilter("Microsoft.UI.Xaml.UIElement", LogLevel.Debug ); + // builder.AddFilter("Microsoft.UI.Xaml.FrameworkElement", LogLevel.Trace ); - // Layouter specific messages - // builder.AddFilter("Microsoft.UI.Xaml.Controls", LogLevel.Debug ); - // builder.AddFilter("Microsoft.UI.Xaml.Controls.Layouter", LogLevel.Debug ); - // builder.AddFilter("Microsoft.UI.Xaml.Controls.Panel", LogLevel.Debug ); + // Layouter specific messages + // builder.AddFilter("Microsoft.UI.Xaml.Controls", LogLevel.Debug ); + // builder.AddFilter("Microsoft.UI.Xaml.Controls.Layouter", LogLevel.Debug ); + // builder.AddFilter("Microsoft.UI.Xaml.Controls.Panel", LogLevel.Debug ); - // builder.AddFilter("Windows.Storage", LogLevel.Debug ); + // builder.AddFilter("Windows.Storage", LogLevel.Debug ); - // Binding related messages - // builder.AddFilter("Microsoft.UI.Xaml.Data", LogLevel.Debug ); - // builder.AddFilter("Microsoft.UI.Xaml.Data", LogLevel.Debug ); + // Binding related messages + // builder.AddFilter("Microsoft.UI.Xaml.Data", LogLevel.Debug ); + // builder.AddFilter("Microsoft.UI.Xaml.Data", LogLevel.Debug ); - // Binder memory references tracking - // builder.AddFilter("Uno.UI.DataBinding.BinderReferenceHolder", LogLevel.Debug ); + // Binder memory references tracking + // builder.AddFilter("Uno.UI.DataBinding.BinderReferenceHolder", LogLevel.Debug ); - // DevServer and HotReload related - // builder.AddFilter("Uno.UI.RemoteControl", LogLevel.Information); + // DevServer and HotReload related + // builder.AddFilter("Uno.UI.RemoteControl", LogLevel.Information); - // Debug JS interop - // builder.AddFilter("Uno.Foundation.WebAssemblyRuntime", LogLevel.Debug ); - }); + // Debug JS interop + // builder.AddFilter("Uno.Foundation.WebAssemblyRuntime", LogLevel.Debug ); + }); - global::Uno.Extensions.LogExtensionPoint.AmbientLoggerFactory = factory; + global::Uno.Extensions.LogExtensionPoint.AmbientLoggerFactory = factory; #if HAS_UNO - global::Uno.UI.Adapter.Microsoft.Extensions.Logging.LoggingAdapter.Initialize(); + global::Uno.UI.Adapter.Microsoft.Extensions.Logging.LoggingAdapter.Initialize(); #endif #endif - } + } } diff --git a/UI/ChatUI/src/ChatUI/Assets/SharedAssets.md b/UI/ChatUI/src/ChatUI/Assets/SharedAssets.md index 1b84a74ab..b1cc4e762 100644 --- a/UI/ChatUI/src/ChatUI/Assets/SharedAssets.md +++ b/UI/ChatUI/src/ChatUI/Assets/SharedAssets.md @@ -22,7 +22,7 @@ See documentation about assets here: https://github.com/unoplatform/uno/blob/mas ### Table of scales -| Scale | WinUI | iOS/MacCatalyst | Android | +| Scale | WinUI | iOS | Android | |-------|:-----------:|:---------------:|:-------:| | `100` | scale-100 | @1x | mdpi | | `125` | scale-125 | N/A | N/A | diff --git a/UI/ChatUI/src/ChatUI/Behaviors/CommandOnKeyPressBehavior.cs b/UI/ChatUI/src/ChatUI/Behaviors/CommandOnKeyPressBehavior.cs index 30cdba7d9..606e9169e 100644 --- a/UI/ChatUI/src/ChatUI/Behaviors/CommandOnKeyPressBehavior.cs +++ b/UI/ChatUI/src/ChatUI/Behaviors/CommandOnKeyPressBehavior.cs @@ -4,36 +4,36 @@ namespace ChatUI.Behaviors; public class CommandOnKeyPressBehavior { - public static ICommand GetTextBoxCommand(DependencyObject dependencyObject) - { - return (ICommand)dependencyObject.GetValue(TextBoxCommandProperty); - } + public static ICommand GetTextBoxCommand(DependencyObject dependencyObject) + { + return (ICommand)dependencyObject.GetValue(TextBoxCommandProperty); + } - public static void SetTextBoxCommand(DependencyObject dependencyObject, ICommand value) - { - dependencyObject.SetValue(TextBoxCommandProperty, value); - } + public static void SetTextBoxCommand(DependencyObject dependencyObject, ICommand value) + { + dependencyObject.SetValue(TextBoxCommandProperty, value); + } - public static readonly DependencyProperty TextBoxCommandProperty = - DependencyProperty.RegisterAttached("TextBoxCommand", typeof(ICommand), typeof(CommandOnKeyPressBehavior), new PropertyMetadata(default(ICommand), OnTextBoxCommandChanged)); - - private static void OnTextBoxCommandChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - if(d is TextBox textBox) - { - textBox.KeyDown -= TextBox_KeyDown; + public static readonly DependencyProperty TextBoxCommandProperty = + DependencyProperty.RegisterAttached("TextBoxCommand", typeof(ICommand), typeof(CommandOnKeyPressBehavior), new PropertyMetadata(default(ICommand), OnTextBoxCommandChanged)); - textBox.KeyDown += TextBox_KeyDown; - } - } + private static void OnTextBoxCommandChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is TextBox textBox) + { + textBox.KeyDown -= TextBox_KeyDown; - private static void TextBox_KeyDown(object sender, Microsoft.UI.Xaml.Input.KeyRoutedEventArgs e) - { - if (e.Key == VirtualKey.Enter) - { - var textBox = sender as TextBox; - var command = GetTextBoxCommand(textBox); - command.Execute(null); - } - } + textBox.KeyDown += TextBox_KeyDown; + } + } + + private static void TextBox_KeyDown(object sender, Microsoft.UI.Xaml.Input.KeyRoutedEventArgs e) + { + if (e.Key == VirtualKey.Enter) + { + var textBox = sender as TextBox; + var command = GetTextBoxCommand(textBox); + command.Execute(null); + } + } } diff --git a/UI/ChatUI/src/ChatUI/Behaviors/ReversedPointerWheel.cs b/UI/ChatUI/src/ChatUI/Behaviors/ReversedPointerWheel.cs index e7e60cb50..4327d8a94 100644 --- a/UI/ChatUI/src/ChatUI/Behaviors/ReversedPointerWheel.cs +++ b/UI/ChatUI/src/ChatUI/Behaviors/ReversedPointerWheel.cs @@ -5,25 +5,25 @@ namespace ChatUI.Behaviors; public static class ReversedPointerWheel { - public static readonly DependencyProperty IsEnabledProperty = DependencyProperty.RegisterAttached( - "IsEnabled", - typeof(bool), - typeof(ReversedPointerWheel), - new PropertyMetadata(default(bool), OnIsEnabledChanged)); + public static readonly DependencyProperty IsEnabledProperty = DependencyProperty.RegisterAttached( + "IsEnabled", + typeof(bool), + typeof(ReversedPointerWheel), + new PropertyMetadata(default(bool), OnIsEnabledChanged)); - public static bool GetIsEnabled(FrameworkElement element) - => (bool)element.GetValue(IsEnabledProperty); + public static bool GetIsEnabled(FrameworkElement element) + => (bool)element.GetValue(IsEnabledProperty); - public static void SetIsEnabled(FrameworkElement element, bool value) - => element.SetValue(IsEnabledProperty, value); + public static void SetIsEnabled(FrameworkElement element, bool value) + => element.SetValue(IsEnabledProperty, value); - private static void OnIsEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) - { - if (d is ScrollContentPresenter scp) - { + private static void OnIsEnabledChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) + { + if (d is ScrollContentPresenter scp) + { #if HAS_UNO - // We do have native support for reversed PointerWheel in Uno. - Uno.UI.Xaml.Controls.ScrollContentPresenter.SetIsPointerWheelReversed(scp, (bool)e.NewValue); + // We do have native support for reversed PointerWheel in Uno. + Uno.UI.Xaml.Controls.ScrollContentPresenter.SetIsPointerWheelReversed(scp, (bool)e.NewValue); #else scp.PointerWheelChanged -= OnWheelChanged; if (e.NewValue is true) @@ -31,91 +31,91 @@ private static void OnIsEnabledChanged(DependencyObject d, DependencyPropertyCha scp.PointerWheelChanged += OnWheelChanged; } #endif - } - else if (d is FrameworkElement sv) - { - sv.Loaded -= PropagateValueToScp; - if (e.NewValue != DependencyProperty.UnsetValue) - { - sv.Loaded += PropagateValueToScp; - PropagateValueToScp(sv, null); - } + } + else if (d is FrameworkElement sv) + { + sv.Loaded -= PropagateValueToScp; + if (e.NewValue != DependencyProperty.UnsetValue) + { + sv.Loaded += PropagateValueToScp; + PropagateValueToScp(sv, null); + } - static void PropagateValueToScp(object sender, RoutedEventArgs? _) - { - if (sender is FrameworkElement sv && TryFindFirstChild(sv, 10, out ScrollContentPresenter scp)) - { - SetIsEnabled(scp, GetIsEnabled(sv)); - } - } - } - } + static void PropagateValueToScp(object sender, RoutedEventArgs? _) + { + if (sender is FrameworkElement sv && TryFindFirstChild(sv, 10, out ScrollContentPresenter scp)) + { + SetIsEnabled(scp, GetIsEnabled(sv)); + } + } + } + } - private static void OnWheelChanged(object sender, PointerRoutedEventArgs e) - { - if (sender is not ScrollContentPresenter { ScrollOwner: ScrollViewer sv } scp || !GetIsEnabled(scp)) - { - if (sender is FrameworkElement fe) - { - fe.PointerWheelChanged -= OnWheelChanged; - } + private static void OnWheelChanged(object sender, PointerRoutedEventArgs e) + { + if (sender is not ScrollContentPresenter { ScrollOwner: ScrollViewer sv } scp || !GetIsEnabled(scp)) + { + if (sender is FrameworkElement fe) + { + fe.PointerWheelChanged -= OnWheelChanged; + } - return; - } + return; + } - var properties = e.GetCurrentPoint(null).Properties; - if (e.KeyModifiers == VirtualKeyModifiers.Control) - { - // Zoom, do nothing. - } - else if (!scp.CanVerticallyScroll || properties.IsHorizontalMouseWheel || e.KeyModifiers == VirtualKeyModifiers.Shift) - { - if (scp.CanHorizontallyScroll) - { - sv.ChangeView( - horizontalOffset: sv.HorizontalOffset + properties.MouseWheelDelta, - verticalOffset: null, - zoomFactor: null, - disableAnimation: false); + var properties = e.GetCurrentPoint(null).Properties; + if (e.KeyModifiers == VirtualKeyModifiers.Control) + { + // Zoom, do nothing. + } + else if (!scp.CanVerticallyScroll || properties.IsHorizontalMouseWheel || e.KeyModifiers == VirtualKeyModifiers.Shift) + { + if (scp.CanHorizontallyScroll) + { + sv.ChangeView( + horizontalOffset: sv.HorizontalOffset + properties.MouseWheelDelta, + verticalOffset: null, + zoomFactor: null, + disableAnimation: false); - e.Handled = true; - } - } - else - { - sv.ChangeView( - horizontalOffset: null, - verticalOffset: sv.VerticalOffset + properties.MouseWheelDelta, - zoomFactor: null, - disableAnimation: false); + e.Handled = true; + } + } + else + { + sv.ChangeView( + horizontalOffset: null, + verticalOffset: sv.VerticalOffset + properties.MouseWheelDelta, + zoomFactor: null, + disableAnimation: false); - e.Handled = true; - } - } + e.Handled = true; + } + } - private static bool TryFindFirstChild(DependencyObject element, uint limit, /*[NotNullWhen(true)]*/ out T result) - { - // Finds the first child of type T in the visual tree of element. - // This is a workaround for the fact that ScrollViewer doesn't expose its ScrollContentPresenter. + private static bool TryFindFirstChild(DependencyObject element, uint limit, /*[NotNullWhen(true)]*/ out T result) + { + // Finds the first child of type T in the visual tree of element. + // This is a workaround for the fact that ScrollViewer doesn't expose its ScrollContentPresenter. - if (element is T t) - { - result = t; - return true; - } + if (element is T t) + { + result = t; + return true; + } - if (limit is not 0) - { - for (var i = 0; i < VisualTreeHelper.GetChildrenCount(element); i++) - { - if (TryFindFirstChild(VisualTreeHelper.GetChild(element, i), limit - 1, out result)) - { - return true; - } - } - } + if (limit is not 0) + { + for (var i = 0; i < VisualTreeHelper.GetChildrenCount(element); i++) + { + if (TryFindFirstChild(VisualTreeHelper.GetChild(element, i), limit - 1, out result)) + { + return true; + } + } + } - result = default; - return false; - } + result = default; + return false; + } } diff --git a/UI/ChatUI/src/ChatUI/ChatUI.csproj b/UI/ChatUI/src/ChatUI/ChatUI.csproj index ba2896879..df19693d6 100644 --- a/UI/ChatUI/src/ChatUI/ChatUI.csproj +++ b/UI/ChatUI/src/ChatUI/ChatUI.csproj @@ -1,6 +1,6 @@ - + - net8.0-android;net8.0-ios;net8.0-maccatalyst;net8.0-windows10.0.19041;net8.0-browserwasm;net8.0-desktop + net9.0-android;net9.0-ios;net9.0-browserwasm;net9.0-desktop Exe true @@ -8,7 +8,7 @@ ChatUI - com.companyname.chatui + com.companyname.ChatUI 1.0 1 @@ -16,27 +16,14 @@ ChatUI ChatUI powered by Uno Platform. - - - - - - 10.0.19041.38 - MVUX; + SkiaRenderer; - diff --git a/UI/ChatUI/src/ChatUI/Commands/RelayCommand.cs b/UI/ChatUI/src/ChatUI/Commands/RelayCommand.cs index a91cdbcc4..aa9889975 100644 --- a/UI/ChatUI/src/ChatUI/Commands/RelayCommand.cs +++ b/UI/ChatUI/src/ChatUI/Commands/RelayCommand.cs @@ -2,22 +2,22 @@ namespace ChatUI.Commands; public class RelayCommand : ICommand { - private Action _execute; + private Action _execute; - public RelayCommand(Action execute) - { - _execute = execute; - } + public RelayCommand(Action execute) + { + _execute = execute; + } - public event EventHandler CanExecuteChanged; + public event EventHandler CanExecuteChanged; - public bool CanExecute(object parameter) - { - return true; - } + public bool CanExecute(object parameter) + { + return true; + } - public void Execute(object parameter) - { - _execute((string)parameter); - } + public void Execute(object parameter) + { + _execute((string)parameter); + } } diff --git a/UI/ChatUI/src/ChatUI/GlobalUsings.cs b/UI/ChatUI/src/ChatUI/GlobalUsings.cs index eeafbe36f..7346fa9af 100644 --- a/UI/ChatUI/src/ChatUI/GlobalUsings.cs +++ b/UI/ChatUI/src/ChatUI/GlobalUsings.cs @@ -1,4 +1,3 @@ -global using System.Collections.Immutable; -global using Microsoft.Extensions.DependencyInjection; +global using System.Collections.Immutable; global using Microsoft.Extensions.Logging; -global using ApplicationExecutionState = Windows.ApplicationModel.Activation.ApplicationExecutionState; +[assembly: Uno.Extensions.Reactive.Config.BindableGenerationTool(3)] diff --git a/UI/ChatUI/src/ChatUI/MainPage.xaml b/UI/ChatUI/src/ChatUI/MainPage.xaml index fdb04fc6a..f040ffb16 100644 --- a/UI/ChatUI/src/ChatUI/MainPage.xaml +++ b/UI/ChatUI/src/ChatUI/MainPage.xaml @@ -1,258 +1,266 @@  + xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" + xmlns:android="http://uno.ui/android" + xmlns:behaviors="using:ChatUI.Behaviors" + xmlns:d="http://schemas.microsoft.com/expression/blend/2008" + xmlns:ios="http://uno.ui/ios" + xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" + xmlns:mvux="using:Uno.Extensions.Reactive.UI" + xmlns:presentation="using:ChatUI.Presentation" + xmlns:win="http://schemas.microsoft.com/winfx/2006/xaml/presentation" + xmlns:xamarin="http://uno.ui/xamarin" + x:Name="MessageView" + Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" + mc:Ignorable="d ios android xamarin"> - - - - + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -