diff --git a/src/AtomUI.Controls/AtomUIOSSControlThemesProvider.axaml b/src/AtomUI.Controls/AtomUIOSSControlThemesProvider.axaml index 06dfc32a0..2043861c8 100644 --- a/src/AtomUI.Controls/AtomUIOSSControlThemesProvider.axaml +++ b/src/AtomUI.Controls/AtomUIOSSControlThemesProvider.axaml @@ -16,6 +16,7 @@ + diff --git a/src/AtomUI.Controls/EmptyIndicator/EmptyIndicator.cs b/src/AtomUI.Controls/EmptyIndicator/EmptyIndicator.cs index 86ea66b05..2fc86e72d 100644 --- a/src/AtomUI.Controls/EmptyIndicator/EmptyIndicator.cs +++ b/src/AtomUI.Controls/EmptyIndicator/EmptyIndicator.cs @@ -1,4 +1,5 @@ -using AtomUI.Media; +using AtomUI.Controls.Themes; +using AtomUI.Media; using AtomUI.Theme; using AtomUI.Theme.Utils; using Avalonia; @@ -239,7 +240,7 @@ public class EmptyIndicator : TemplatedControl, protected override void OnApplyTemplate(TemplateAppliedEventArgs e) { base.OnApplyTemplate(e); - _svg = e.NameScope.Find(EmptyIndicatorTheme.SvgImagePart); + _svg = e.NameScope.Find(EmptyIndicatorThemeConstants.SvgImagePart); HorizontalAlignment = HorizontalAlignment.Center; VerticalAlignment = VerticalAlignment.Center; CheckImageSource(); diff --git a/src/AtomUI.Controls/EmptyIndicator/EmptyIndicatorTheme.cs b/src/AtomUI.Controls/EmptyIndicator/EmptyIndicatorTheme.cs deleted file mode 100644 index 220595fae..000000000 --- a/src/AtomUI.Controls/EmptyIndicator/EmptyIndicatorTheme.cs +++ /dev/null @@ -1,117 +0,0 @@ -using AtomUI.Theme; -using AtomUI.Theme.Styling; -using Avalonia.Controls; -using Avalonia.Controls.Templates; -using Avalonia.Layout; -using Avalonia.Media; -using Avalonia.Styling; - -namespace AtomUI.Controls; - -[ControlThemeProvider] -internal class EmptyIndicatorTheme : BaseControlTheme -{ - public const string SvgImagePart = "PART_SvgImage"; - public const string DescriptionPart = "PART_Description"; - - public EmptyIndicatorTheme() - : base(typeof(EmptyIndicator)) - { - } - - protected override IControlTemplate BuildControlTemplate() - { - return new FuncControlTemplate((indicator, scope) => - { - var layout = new StackPanel - { - Orientation = Orientation.Vertical - }; - - var svg = new Avalonia.Svg.Svg(new Uri("https://github.com/avaloniaui")) - { - Name = SvgImagePart - }; - layout.Children.Add(svg); - svg.RegisterInNameScope(scope); - - var description = new TextBlock - { - Name = DescriptionPart, - HorizontalAlignment = HorizontalAlignment.Center, - TextWrapping = TextWrapping.Wrap, - }; - CreateTemplateParentBinding(description, TextBlock.TextProperty, EmptyIndicator.DescriptionProperty); - layout.Children.Add(description); - - return layout; - }); - } - - protected override void BuildStyles() - { - // 设置本身样式 - BuildSvgStyle(); - - this.Add(EmptyIndicator.ColorFillProperty, SharedTokenKey.ColorFill); - this.Add(EmptyIndicator.ColorFillTertiaryProperty, SharedTokenKey.ColorFillTertiary); - this.Add(EmptyIndicator.ColorFillQuaternaryProperty, SharedTokenKey.ColorFillQuaternary); - this.Add(EmptyIndicator.ColorBgContainerProperty, SharedTokenKey.ColorBgContainer); - - var sizeSmallAndMiddleStyle = new Style(selector => Selectors.Or( - selector.Nesting().PropertyEquals(EmptyIndicator.SizeTypeProperty, SizeType.Middle), - selector.Nesting().PropertyEquals(EmptyIndicator.SizeTypeProperty, SizeType.Small))); - { - var descriptionStyle = new Style(selector => selector.Nesting().Template().Name(DescriptionPart)); - descriptionStyle.Add(TextBlock.MarginProperty, EmptyIndicatorTokenKey.DescriptionMarginSM); - Add(descriptionStyle); - } - Add(sizeSmallAndMiddleStyle); - - var sizeLargeStyle = new Style(selector => - selector.Nesting().PropertyEquals(EmptyIndicator.SizeTypeProperty, SizeType.Large)); - { - var descriptionStyle = new Style(selector => selector.Nesting().Template().Name(DescriptionPart)); - descriptionStyle.Add(TextBlock.MarginProperty, EmptyIndicatorTokenKey.DescriptionMargin); - Add(descriptionStyle); - } - Add(sizeLargeStyle); - - { - var descriptionStyle = new Style(selector => selector.Nesting().Template().Name(DescriptionPart)); - descriptionStyle.Add(TextBlock.ForegroundProperty, SharedTokenKey.ColorTextDescription); - Add(descriptionStyle); - } - } - - private void BuildSvgStyle() - { - var svgSelector = default(Selector).Nesting().Template().OfType(); - { - var largeSizeStyle = new Style(selector => - selector.Nesting().PropertyEquals(EmptyIndicator.SizeTypeProperty, SizeType.Large)); - var svgStyle = new Style(selector => svgSelector); - svgStyle.Add(Layoutable.HeightProperty, EmptyIndicatorTokenKey.EmptyImgHeight); - largeSizeStyle.Add(svgStyle); - Add(largeSizeStyle); - } - - { - var middleSizeStyle = new Style(selector => - selector.Nesting().PropertyEquals(EmptyIndicator.SizeTypeProperty, SizeType.Middle)); - var svgStyle = new Style(selector => svgSelector); - svgStyle.Add(Layoutable.HeightProperty, EmptyIndicatorTokenKey.EmptyImgHeightMD); - middleSizeStyle.Add(svgStyle); - Add(middleSizeStyle); - } - - { - var smallSizeStyle = new Style(selector => - selector.Nesting().PropertyEquals(EmptyIndicator.SizeTypeProperty, SizeType.Small)); - var svgStyle = new Style(selector => svgSelector); - svgStyle.Add(Layoutable.HeightProperty, EmptyIndicatorTokenKey.EmptyImgHeightSM); - smallSizeStyle.Add(svgStyle); - Add(smallSizeStyle); - } - } -} \ No newline at end of file diff --git a/src/AtomUI.Controls/EmptyIndicator/Themes/EmptyIndicatorTheme.axaml b/src/AtomUI.Controls/EmptyIndicator/Themes/EmptyIndicatorTheme.axaml new file mode 100644 index 000000000..3db642690 --- /dev/null +++ b/src/AtomUI.Controls/EmptyIndicator/Themes/EmptyIndicatorTheme.axaml @@ -0,0 +1,60 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/AtomUI.Controls/EmptyIndicator/Themes/EmptyIndicatorThemeConstants.cs b/src/AtomUI.Controls/EmptyIndicator/Themes/EmptyIndicatorThemeConstants.cs new file mode 100644 index 000000000..745eff5e3 --- /dev/null +++ b/src/AtomUI.Controls/EmptyIndicator/Themes/EmptyIndicatorThemeConstants.cs @@ -0,0 +1,7 @@ +namespace AtomUI.Controls.Themes; + +internal static class EmptyIndicatorThemeConstants +{ + public const string SvgImagePart = "PART_SvgImage"; + public const string DescriptionPart = "PART_Description"; +} \ No newline at end of file diff --git a/src/AtomUI.Controls/GeneratedFiles/AtomUI.Generator/AtomUI.Generator.ControlThemePoolGenerator/ControlThemePool.g.cs b/src/AtomUI.Controls/GeneratedFiles/AtomUI.Generator/AtomUI.Generator.ControlThemePoolGenerator/ControlThemePool.g.cs index 91e7f8136..6b2b0812a 100644 --- a/src/AtomUI.Controls/GeneratedFiles/AtomUI.Generator/AtomUI.Generator.ControlThemePoolGenerator/ControlThemePool.g.cs +++ b/src/AtomUI.Controls/GeneratedFiles/AtomUI.Generator/AtomUI.Generator.ControlThemePoolGenerator/ControlThemePool.g.cs @@ -17,7 +17,6 @@ namespace AtomUI.Theme themes.Add(new AtomUI.Controls.CircleProgressTheme()); themes.Add(new AtomUI.Controls.ContextMenuTheme()); themes.Add(new AtomUI.Controls.DashboardProgressTheme()); - themes.Add(new AtomUI.Controls.EmptyIndicatorTheme()); themes.Add(new AtomUI.Controls.ExpanderTheme()); themes.Add(new AtomUI.Controls.GroupBoxTheme()); themes.Add(new AtomUI.Controls.HorizontalNavMenuTheme());