mirror of
https://gitcode.com/gh_mirrors/se/Semi.Avalonia
synced 2026-04-08 10:16:35 +08:00
Implement Semi Design theme for page-based navigation controls (ContentPage / DrawerPage / NavigationPage / TabbedPage) (#766)
* 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>
This commit is contained in:
66
demo/Semi.Avalonia.Demo/Pages/NavigationDemoHelper.cs
Normal file
66
demo/Semi.Avalonia.Demo/Pages/NavigationDemoHelper.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Layout;
|
||||
using Avalonia.Media;
|
||||
|
||||
namespace Semi.Avalonia.Demo.Pages;
|
||||
|
||||
/// <summary>
|
||||
/// Shared helpers for ControlCatalog demo pages.
|
||||
/// </summary>
|
||||
internal static class NavigationDemoHelper
|
||||
{
|
||||
/// <summary>
|
||||
/// Pastel background brushes cycled by page index.
|
||||
/// </summary>
|
||||
internal static readonly IBrush[] PageBrushes =
|
||||
[
|
||||
new SolidColorBrush(Color.Parse("#BBDEFB")),
|
||||
new SolidColorBrush(Color.Parse("#C8E6C9")),
|
||||
new SolidColorBrush(Color.Parse("#FFE0B2")),
|
||||
new SolidColorBrush(Color.Parse("#E1BEE7")),
|
||||
new SolidColorBrush(Color.Parse("#FFCDD2")),
|
||||
new SolidColorBrush(Color.Parse("#B2EBF2"))
|
||||
];
|
||||
|
||||
internal static IBrush GetPageBrush(int index) =>
|
||||
PageBrushes[(index % PageBrushes.Length + PageBrushes.Length) % PageBrushes.Length];
|
||||
|
||||
/// <summary>
|
||||
/// Creates a simple demo ContentPage with a centered title and subtitle.
|
||||
/// </summary>
|
||||
internal static ContentPage MakePage(string header, string body, int colorIndex) =>
|
||||
new()
|
||||
{
|
||||
Header = header,
|
||||
Background = GetPageBrush(colorIndex),
|
||||
Content = new StackPanel
|
||||
{
|
||||
HorizontalAlignment = HorizontalAlignment.Center,
|
||||
VerticalAlignment = VerticalAlignment.Center,
|
||||
Spacing = 8,
|
||||
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
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user