feat: initialize Rating.

This commit is contained in:
Zhang Dian
2024-06-03 11:04:04 +08:00
parent 68c55dd331
commit ceede38804
15 changed files with 522 additions and 0 deletions

View File

@@ -0,0 +1,65 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:u="https://irihi.tech/ursa">
<ControlTheme x:Key="{x:Type u:RatingCharacter}" TargetType="u:RatingCharacter">
<Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="Foreground" Value="{DynamicResource RatingCharacterDefaultForeground}" />
<Setter Property="Background" Value="{DynamicResource RatingCharacterDefaultBackground}" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template">
<ControlTemplate TargetType="u:RatingCharacter">
<Border Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
<PathIcon Name="{x:Static u:RatingCharacter.PART_IconGlyph}"
Width="16"
Height="16"
Margin="4,0"
Data="{DynamicResource RatingStarUnSelectedIconGlyph}"
Foreground="{TemplateBinding Foreground}" />
<ToolTip.Tip>
<TextBlock Text="{Binding $parent[u:Rating].SelectedTooltip}" />
</ToolTip.Tip>
</Border>
</ControlTemplate>
</Setter>
<Style Selector="^:selected /template/ PathIcon#PART_IconGlyph">
<Setter Property="Data" Value="{DynamicResource RatingStarSelectedIconGlyph}" />
</Style>
</ControlTheme>
<ControlTheme x:Key="{x:Type u:Rating}" TargetType="u:Rating">
<Setter Property="Background" Value="Transparent" />
<Setter Property="ItemTemplate">
<DataTemplate>
<u:RatingCharacter Content="{Binding}" />
</DataTemplate>
</Setter>
<Setter Property="Template">
<ControlTemplate TargetType="u:Rating">
<Border Name="PART_RootBorder"
MinHeight="30"
Padding="8,4"
VerticalAlignment="Stretch"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}">
<Panel HorizontalAlignment="Stretch">
<ItemsControl Name="{x:Static u:Rating.PART_ItemsControl}"
HorizontalAlignment="Stretch"
VerticalAlignment="Top"
ItemTemplate="{TemplateBinding ItemTemplate}"
ItemsSource="{TemplateBinding Items}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</Panel>
</Border>
</ControlTemplate>
</Setter>
</ControlTheme>
</ResourceDictionary>

View File

@@ -28,6 +28,7 @@
<ResourceInclude Source="NumberDisplayer.axaml" />
<ResourceInclude Source="Pagination.axaml" />
<ResourceInclude Source="RangeSlider.axaml" />
<ResourceInclude Source="Rating.axaml" />
<ResourceInclude Source="ScrollToButton.axaml" />
<ResourceInclude Source="SelectionList.axaml" />
<ResourceInclude Source="TagInput.axaml" />

View File

@@ -0,0 +1,4 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="RatingCharacterDefaultForeground" Color="#FDDE43" />
<SolidColorBrush x:Key="RatingCharacterDefaultBackground" Color="Transparent" />
</ResourceDictionary>

View File

@@ -12,6 +12,7 @@
<MergeResourceInclude Source="Loading.axaml" />
<MergeResourceInclude Source="NavigationMenu.axaml" />
<MergeResourceInclude Source="Pagination.axaml" />
<MergeResourceInclude Source="Rating.axaml" />
<MergeResourceInclude Source="TagInput.axaml" />
<MergeResourceInclude Source="Timeline.axaml" />
<MergeResourceInclude Source="Skeleton.axaml" />

View File

@@ -0,0 +1,4 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<SolidColorBrush x:Key="RatingCharacterDefaultForeground" Color="#FAC800" />
<SolidColorBrush x:Key="RatingCharacterDefaultBackground" Color="Transparent" />
</ResourceDictionary>

View File

@@ -12,6 +12,7 @@
<MergeResourceInclude Source="Loading.axaml" />
<MergeResourceInclude Source="NavigationMenu.axaml" />
<MergeResourceInclude Source="Pagination.axaml" />
<MergeResourceInclude Source="Rating.axaml" />
<MergeResourceInclude Source="TagInput.axaml" />
<MergeResourceInclude Source="Timeline.axaml" />
<MergeResourceInclude Source="Skeleton.axaml" />

View File

@@ -0,0 +1,5 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<PathGeometry x:Key="RatingStarUnSelectedIconGlyph">M12 5.02863L9.56867 9.10197C9.39633 9.39072 9.10801 9.59094 8.77762 9.65133L4.47932 10.4369L7.47279 13.9041C7.69195 14.158 7.79145 14.494 7.74589 14.8265L7.13481 19.2864L11.5403 17.3919C11.8338 17.2657 12.1662 17.2657 12.4597 17.3919L16.8652 19.2864L16.2541 14.8265C16.2086 14.494 16.308 14.158 16.5272 13.9041L19.5207 10.4369L15.2224 9.65133C14.892 9.59095 14.6037 9.39072 14.4313 9.10198L12 5.02863ZM10.9998 2.56831C11.4521 1.81056 12.5479 1.81057 13.0002 2.56831L16.028 7.64098L21.5427 8.64887C22.4298 8.81101 22.8049 9.87773 22.215 10.561L18.4119 14.9659L19.1938 20.672C19.3171 21.5718 18.4126 22.2617 17.5795 21.9035L12 19.5041L6.4205 21.9035C5.58741 22.2617 4.68294 21.5718 4.80622 20.672L5.58806 14.9659L1.78503 10.561C1.19513 9.87772 1.57018 8.81101 2.45731 8.64887L7.97197 7.64098L10.9998 2.56831Z</PathGeometry>
<PathGeometry x:Key="RatingStarSelectedIconGlyph">M10.7525 1.90411C11.1451 0.698628 12.8549 0.698631 13.2475 1.90411L15.2395 8.01946H21.6858C22.9565 8.01946 23.4848 9.64143 22.4568 10.3865L17.2417 14.1659L19.2337 20.2813C19.6263 21.4868 18.2431 22.4892 17.2151 21.7442L12 17.9647L6.78489 21.7442C5.75687 22.4892 4.37368 21.4868 4.76635 20.2813L6.75834 14.1659L1.54323 10.3865C0.515206 9.64142 1.04354 8.01946 2.31425 8.01946H8.76048L10.7525 1.90411Z</PathGeometry>
</ResourceDictionary>

View File

@@ -13,6 +13,7 @@
<MergeResourceInclude Source="MessageBox.axaml" />
<MergeResourceInclude Source="NavigationMenu.axaml" />
<MergeResourceInclude Source="Pagination.axaml" />
<MergeResourceInclude Source="Rating.axaml" />
<MergeResourceInclude Source="ScrollToButton.axaml" />
<MergeResourceInclude Source="TagInput.axaml" />
<MergeResourceInclude Source="Skeleton.axaml" />