mirror of
https://gitcode.com/gh_mirrors/se/Semi.Avalonia
synced 2026-04-08 18:26:35 +08:00
* Initial plan * Implement Semi Design theme for ContentPage, DrawerPage, NavigationPage, TabbedPage Co-authored-by: zdpcdt <54255897+zdpcdt@users.noreply.github.com> * fix: bind ItemsSource to Pages in TabControl of TabbedPage. * chore: split demo navigation pages. * demo: improve NavigationPage demo pages with interactive controls Co-authored-by: zdpcdt <54255897+zdpcdt@users.noreply.github.com> * fix: use comma-separated Padding syntax and remove trailing newline Co-authored-by: zdpcdt <54255897+zdpcdt@users.noreply.github.com> * feat: implement semi design theme for navigation controls in demo pages. * feat: enhance demo pages with foreground color for better visibility * feat: add back button visibility control and improve navigation page layout. * chore: remove DrawerPage unused static resources. * feat: add HighContrast resources for ContentPage, DrawerPage, NavigationPage, TabbedPage Co-authored-by: zdpcdt <54255897+zdpcdt@users.noreply.github.com> * feat: implement CardTabbedPage & ButtonTabbedPage themes. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: zdpcdt <54255897+zdpcdt@users.noreply.github.com> Co-authored-by: Dong Bin <popmessiah@hotmail.com>
93 lines
2.9 KiB
C#
93 lines
2.9 KiB
C#
using Avalonia.Controls;
|
|
using Avalonia.Interactivity;
|
|
using Avalonia.Media;
|
|
using Avalonia.Layout;
|
|
|
|
namespace Semi.Avalonia.Demo.Pages;
|
|
|
|
public partial class ContentPageDemo : UserControl
|
|
{
|
|
private static readonly Color[] PageColors =
|
|
[
|
|
Color.FromRgb(0xE3, 0xF2, 0xFD), // blue
|
|
Color.FromRgb(0xF3, 0xE5, 0xF5), // purple
|
|
Color.FromRgb(0xE8, 0xF5, 0xE9), // green
|
|
Color.FromRgb(0xFF, 0xF8, 0xE1), // amber
|
|
Color.FromRgb(0xFB, 0xE9, 0xE7), // deep orange
|
|
];
|
|
|
|
private int _pageCount;
|
|
|
|
public ContentPageDemo()
|
|
{
|
|
InitializeComponent();
|
|
Loaded += OnLoaded;
|
|
}
|
|
|
|
private async void OnLoaded(object? sender, RoutedEventArgs e)
|
|
{
|
|
await DemoNav.PushAsync(MakePage("Root Page", "ContentPage inside a NavigationPage.\nUse the options to navigate."));
|
|
UpdateStatus();
|
|
}
|
|
|
|
private async void OnPush(object? sender, RoutedEventArgs e)
|
|
{
|
|
_pageCount++;
|
|
await DemoNav.PushAsync(MakePage($"Page {_pageCount}", $"ContentPage #{_pageCount}.\nNavigate back using the back button."));
|
|
UpdateStatus();
|
|
}
|
|
|
|
private async void OnPop(object? sender, RoutedEventArgs e)
|
|
{
|
|
await DemoNav.PopAsync();
|
|
UpdateStatus();
|
|
}
|
|
|
|
private async void OnPopToRoot(object? sender, RoutedEventArgs e)
|
|
{
|
|
await DemoNav.PopToRootAsync();
|
|
_pageCount = 0;
|
|
UpdateStatus();
|
|
}
|
|
|
|
private void UpdateStatus()
|
|
{
|
|
StatusText.Text = $"Depth: {DemoNav.StackDepth} | Current: {DemoNav.CurrentPage?.Header}";
|
|
}
|
|
|
|
private ContentPage MakePage(string header, string body) =>
|
|
new ContentPage
|
|
{
|
|
Header = header,
|
|
Background = new SolidColorBrush(PageColors[_pageCount % PageColors.Length]),
|
|
Content = new StackPanel
|
|
{
|
|
HorizontalAlignment = HorizontalAlignment.Center,
|
|
VerticalAlignment = VerticalAlignment.Center,
|
|
Spacing = 10,
|
|
Children =
|
|
{
|
|
new TextBlock
|
|
{
|
|
Text = header,
|
|
FontSize = 20,
|
|
FontWeight = FontWeight.SemiBold,
|
|
HorizontalAlignment = HorizontalAlignment.Center,
|
|
Foreground = Brushes.Black,
|
|
},
|
|
new TextBlock
|
|
{
|
|
Text = body,
|
|
FontSize = 13,
|
|
Opacity = 0.7,
|
|
TextWrapping = TextWrapping.Wrap,
|
|
TextAlignment = TextAlignment.Center,
|
|
MaxWidth = 260,
|
|
Foreground = Brushes.Black,
|
|
}
|
|
}
|
|
},
|
|
HorizontalContentAlignment = HorizontalAlignment.Stretch,
|
|
VerticalContentAlignment = VerticalAlignment.Stretch
|
|
};
|
|
} |