-
Notifications
You must be signed in to change notification settings - Fork 28
feat: Restore debug tools in Settings page with conditional compilation #1539
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
Draft
Copilot
wants to merge
12
commits into
main
Choose a base branch
from
copilot/add-version-number-settings-popup-again
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
8251204
Initial plan
Copilot 8e6f3d6
chore: Adjust restore
jeromelaban 6ce9211
feat: Add Settings page with version information display
Copilot 68e8dcf
refactor: Cache SettingsPage instance and clear NavigationView selection
Copilot ea751ae
fix: Remove duplicate using and move initialization to constructor
Copilot 21f3b9c
chore: Adjust samples app override
jeromelaban fea077e
fix: Improve platform detection for desktop builds
Copilot e2380e6
chore: Restore original native build
jeromelaban df2ebe3
feat: Add debug tools to Settings page
Copilot 00b20d4
chore: fix DebugVTAsync impl
Xiaoy312 47fd452
chore: update debug panel impl
Xiaoy312 b439af1
chore: add packages info and copy button
Xiaoy312 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,29 @@ | ||
| #!/usr/bin/env bash | ||
| set -euo pipefail | ||
|
|
||
| # Create a desktop-only crosstargeting override for build pipelines | ||
| cat > "src/crosstargeting_override.props" << 'EOF' | ||
| <Project ToolsVersion="15.0"> | ||
| <PropertyGroup> | ||
| <DisableMobileTargets>true</DisableMobileTargets> | ||
| <SamplesTargetFrameworkOverride>net10.0-desktop</SamplesTargetFrameworkOverride> | ||
| <TargetFrameworkOverride>net9.0</TargetFrameworkOverride> | ||
jeromelaban marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| </PropertyGroup> | ||
| </Project> | ||
| EOF | ||
|
|
||
| cd src | ||
|
|
||
| dotnet workload restore | ||
| dotnet workload install android | ||
|
|
||
| # Restore solution packages to ensure dependencies are ready for subsequent steps | ||
| dotnet restore src/Uno.Toolkit.sln -p:SamplesTargetFrameworkOverride=net9.0-desktop -p:DisableMobileTargets=true | ||
| dotnet restore Uno.Toolkit.sln | ||
|
|
||
| # Preload the dev server tool | ||
| dotnet dnx -y uno.devserver --prerelease -- start -l trace | ||
|
|
||
| sleep 20 | ||
|
|
||
| dotnet dnx -y uno.devserver --prerelease -- stop -l trace | ||
jeromelaban marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 135 additions & 0 deletions
135
samples/Uno.Toolkit.Samples/Uno.Toolkit.Samples/Content/SettingsPage.xaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| <Page x:Class="Uno.Toolkit.Samples.Content.SettingsPage" | ||
| xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | ||
| xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | ||
| xmlns:local="using:Uno.Toolkit.Samples.Content" | ||
| xmlns:d="http://schemas.microsoft.com/expression/blend/2008" | ||
| xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" | ||
| mc:Ignorable="d" | ||
| Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"> | ||
|
|
||
| <Grid> | ||
| <ScrollViewer> | ||
| <StackPanel Padding="48,24" Spacing="24" MaxWidth="600"> | ||
| <!-- Header --> | ||
| <TextBlock Text="Settings" | ||
| FontSize="32" | ||
| FontWeight="Bold" | ||
| Foreground="{ThemeResource OnBackgroundBrush}" /> | ||
|
|
||
| <!-- App Information Section --> | ||
| <StackPanel Spacing="16"> | ||
| <TextBlock Text="About" | ||
| FontSize="20" | ||
| FontWeight="SemiBold" | ||
| Foreground="{ThemeResource OnBackgroundBrush}" /> | ||
|
|
||
| <Border Background="{ThemeResource SurfaceBrush}" | ||
| CornerRadius="8" | ||
| Padding="16"> | ||
| <StackPanel x:Name="AppInfoPanel" Spacing="12"> | ||
| <!-- note: any top-level StackPanel here is automatically captured for CopyInfo --> | ||
|
|
||
| <!-- App Name --> | ||
| <StackPanel Spacing="4"> | ||
| <TextBlock Text="Application" | ||
| FontSize="14" | ||
| Opacity="0.7" | ||
| Foreground="{ThemeResource OnSurfaceBrush}" /> | ||
| <TextBlock Text="Uno Toolkit Samples" | ||
| FontSize="16" | ||
| FontWeight="SemiBold" | ||
| Foreground="{ThemeResource OnSurfaceBrush}" /> | ||
| </StackPanel> | ||
|
|
||
| <!-- Version --> | ||
| <StackPanel Spacing="4"> | ||
| <TextBlock Text="Version" | ||
| FontSize="14" | ||
| Opacity="0.7" | ||
| Foreground="{ThemeResource OnSurfaceBrush}" /> | ||
| <TextBlock x:Name="VersionTextBlock" | ||
| FontSize="16" | ||
| FontWeight="SemiBold" | ||
| Foreground="{ThemeResource OnSurfaceBrush}" /> | ||
| </StackPanel> | ||
|
|
||
| <!-- Framework --> | ||
| <StackPanel Spacing="4"> | ||
| <TextBlock Text="Framework" | ||
| FontSize="14" | ||
| Opacity="0.7" | ||
| Foreground="{ThemeResource OnSurfaceBrush}" /> | ||
| <TextBlock x:Name="FrameworkTextBlock" | ||
| FontSize="16" | ||
| FontWeight="SemiBold" | ||
| Foreground="{ThemeResource OnSurfaceBrush}" /> | ||
| </StackPanel> | ||
|
|
||
| <!-- Platform --> | ||
| <StackPanel Spacing="4"> | ||
| <TextBlock Text="Platform" | ||
| FontSize="14" | ||
| Opacity="0.7" | ||
| Foreground="{ThemeResource OnSurfaceBrush}" /> | ||
| <TextBlock x:Name="PlatformTextBlock" | ||
| FontSize="16" | ||
| FontWeight="SemiBold" | ||
| Foreground="{ThemeResource OnSurfaceBrush}" /> | ||
| </StackPanel> | ||
|
|
||
| <!-- Package Versions --> | ||
| <StackPanel Spacing="4"> | ||
| <TextBlock Text="Package Versions" | ||
| FontSize="14" | ||
| Opacity="0.7" | ||
| Foreground="{ThemeResource OnSurfaceBrush}" /> | ||
| <TextBox x:Name="PackageVersionsTextBlock" | ||
| IsReadOnly="True" | ||
| AcceptsReturn="True" | ||
| FontSize="16" | ||
| Foreground="{ThemeResource OnSurfaceBrush}" /> | ||
| </StackPanel> | ||
|
|
||
| <Button Content="Copy to Clipboard" | ||
| Click="CopyInfo" | ||
| HorizontalAlignment="Stretch" /> | ||
| </StackPanel> | ||
| </Border> | ||
| </StackPanel> | ||
|
|
||
| <!-- Additional Information --> | ||
| <StackPanel Spacing="16"> | ||
| <TextBlock Text="Learn More" | ||
| FontSize="20" | ||
| FontWeight="SemiBold" | ||
| Foreground="{ThemeResource OnBackgroundBrush}" /> | ||
|
|
||
| <Border Background="{ThemeResource SurfaceBrush}" | ||
| CornerRadius="8" | ||
| Padding="16"> | ||
| <StackPanel Spacing="12"> | ||
| <HyperlinkButton Content="Uno Toolkit Documentation" | ||
| NavigateUri="https://platform.uno/docs/articles/external/uno.toolkit.ui/doc/getting-started.html" | ||
| Padding="0" /> | ||
| <HyperlinkButton Content="GitHub Repository" | ||
| NavigateUri="https://github.com/unoplatform/uno.toolkit.ui" | ||
| Padding="0" /> | ||
| <HyperlinkButton Content="Report an Issue" | ||
| NavigateUri="https://github.com/unoplatform/uno.toolkit.ui/issues" | ||
| Padding="0" /> | ||
| </StackPanel> | ||
| </Border> | ||
| </StackPanel> | ||
|
|
||
| <!-- Debug Tools Section --> | ||
| <StackPanel Spacing="16"> | ||
|
|
||
| <Button Content="Enable visual debugging tool" | ||
| Click="EnableDebugPanel" | ||
| HorizontalAlignment="Stretch" /> | ||
|
|
||
| </StackPanel> | ||
| </StackPanel> | ||
| </ScrollViewer> | ||
| </Grid> | ||
| </Page> |
121 changes: 121 additions & 0 deletions
121
samples/Uno.Toolkit.Samples/Uno.Toolkit.Samples/Content/SettingsPage.xaml.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| using System.Reflection; | ||
| using System.Runtime.InteropServices; | ||
| using Uno.Extensions; | ||
| using Uno.UI.Extensions; | ||
| using Windows.ApplicationModel.DataTransfer; | ||
|
|
||
| namespace Uno.Toolkit.Samples.Content | ||
| { | ||
| public sealed partial class SettingsPage : Page | ||
| { | ||
| public SettingsPage() | ||
| { | ||
| this.InitializeComponent(); | ||
|
|
||
| UpdateAppInfoSafe(); | ||
| } | ||
|
|
||
| private void UpdateAppInfoSafe() | ||
| { | ||
| // this is called in ctor, dont fail creating the page and the subsequent navigation if anything went wrong | ||
| try | ||
| { | ||
| UpdateAppInfo(); | ||
| } | ||
| catch (Exception) { } | ||
| } | ||
| private void UpdateAppInfo() | ||
| { | ||
| // Set version text | ||
| VersionTextBlock.Text = Assembly.GetExecutingAssembly().GetName().Version?.ToString() ?? "Unknown"; | ||
|
|
||
| // Set framework information | ||
| FrameworkTextBlock.Text = RuntimeInformation.FrameworkDescription; | ||
|
|
||
| // Set platform information | ||
| #if __ANDROID__ | ||
| PlatformTextBlock.Text = "Android"; | ||
| #elif __IOS__ | ||
| PlatformTextBlock.Text = "iOS"; | ||
| #elif __WASM__ | ||
| PlatformTextBlock.Text = "WebAssembly"; | ||
| #elif __MACOS__ | ||
| PlatformTextBlock.Text = "macOS"; | ||
| #elif WINDOWS_UWP | ||
| PlatformTextBlock.Text = "UWP"; | ||
| #elif WINDOWS || WINDOWS_WINUI | ||
| PlatformTextBlock.Text = "Windows (WinUI)"; | ||
| #else | ||
| // For Skia desktop builds, detect at runtime | ||
| // Check if we're running on a desktop platform (Windows, Linux, macOS) but not in browser | ||
| var isDesktop = RuntimeInformation.IsOSPlatform(OSPlatform.Windows) || | ||
| RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || | ||
| RuntimeInformation.IsOSPlatform(OSPlatform.OSX); | ||
|
|
||
| if (isDesktop) | ||
| { | ||
| PlatformTextBlock.Text = "Skia (Desktop)"; | ||
| } | ||
| else | ||
| { | ||
| PlatformTextBlock.Text = "Unknown"; | ||
| } | ||
jeromelaban marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| #endif | ||
|
|
||
| // Set packages information | ||
| var assemblyMarkerTypes = new[] | ||
| { | ||
| typeof(Microsoft.UI.Xaml.Application), | ||
| typeof(Uno.Material.MaterialTheme), | ||
| // typeof(Uno.Cupertino.CupertinoResources), | ||
| typeof(Uno.Toolkit.UI.ToolkitResources), | ||
| }; | ||
| PackageVersionsTextBlock.Text = string.Join("\n", assemblyMarkerTypes | ||
| .Select(x => | ||
| { | ||
| var name = x.Assembly.GetName(); | ||
| var version = | ||
| (x.Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion?.Trim() is { Length: > 0 } aiv ? aiv : null) ?? | ||
| name.Version?.ToString() ?? | ||
| "Unknown"; | ||
|
|
||
| return $"{name.Name}: {version}"; | ||
| }) | ||
| ); | ||
| } | ||
|
|
||
| private void EnableDebugPanel(object sender, RoutedEventArgs e) | ||
| { | ||
| if (this.FindFirstAncestor<Shell>() is { } shell) | ||
| { | ||
| shell.EnableDebugPanel(); | ||
| } | ||
| } | ||
|
|
||
| private void CopyInfo(object sender, RoutedEventArgs e) | ||
| { | ||
| var text = string.Join('\n', AppInfoPanel.Children.OfType<StackPanel>() | ||
| .Select(x => | ||
| { | ||
| var label = (x.Children.ElementAtOrDefault(0) as TextBlock)?.Text ?? "???"; | ||
| var value = string.Join('\n', x.Children.Skip(1) | ||
| .Select(x => x switch | ||
| { | ||
| TextBlock tblock => tblock.Text, | ||
| TextBox tbox => tbox.Text, | ||
| _ => null, | ||
| }) | ||
| .Where(x => !string.IsNullOrEmpty(x)) | ||
| ); | ||
|
|
||
| return value.Split(['\n', '\r']) is { Length: > 1 } multilines | ||
| ? string.Join('\n', [$"{label}:", .. multilines.Select(x => " " + x)]) | ||
| : $"{label}: {value}"; | ||
| }) | ||
| ); | ||
|
|
||
| Clipboard.SetContent(new DataPackage().Apply(x => x.SetText(text))); | ||
| Console.WriteLine(text); | ||
| } | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file writes src/crosstargeting_override.props and the samples csproj auto-imports it if present. That can affect local builds after the script runs. Maybe consider scoping/cleanup or env-gated import no ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a workaround until the devserver fixes a few things, it probably won't get merged as-is.