feat: uppdate to latest nightly. add clear button to ComboBox and DatePicker

This commit is contained in:
rabbitism 2023-10-04 14:51:05 +08:00
parent e563f860ad
commit d638b0603d
10 changed files with 91 additions and 17 deletions

View File

@ -1,6 +1,6 @@
<Project> <Project>
<PropertyGroup> <PropertyGroup>
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
<AvaloniaVersion>11.0.0</AvaloniaVersion> <AvaloniaVersion>11.1.999-cibuild0040425</AvaloniaVersion>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@ -15,6 +15,13 @@
<ComboBoxItem>Mr. 17</ComboBoxItem> <ComboBoxItem>Mr. 17</ComboBoxItem>
<ComboBoxItem>Cass</ComboBoxItem> <ComboBoxItem>Cass</ComboBoxItem>
</ComboBox> </ComboBox>
<ComboBox Width="150" Classes="ClearButton">
<ComboBoxItem>Ding</ComboBoxItem>
<ComboBoxItem>Otter</ComboBoxItem>
<ComboBoxItem>Husky</ComboBoxItem>
<ComboBoxItem>Mr. 17</ComboBoxItem>
<ComboBoxItem>Cass</ComboBoxItem>
</ComboBox>
<ComboBox Width="150" PlaceholderText="Please Select"> <ComboBox Width="150" PlaceholderText="Please Select">
<ComboBoxItem>Ding</ComboBoxItem> <ComboBoxItem>Ding</ComboBoxItem>
<ComboBoxItem>Otter</ComboBoxItem> <ComboBoxItem>Otter</ComboBoxItem>

View File

@ -9,6 +9,7 @@
mc:Ignorable="d"> mc:Ignorable="d">
<StackPanel Spacing="20"> <StackPanel Spacing="20">
<DatePicker /> <DatePicker />
<DatePicker Classes="ClearButton" />
<DatePicker DayFormat="d (ddd)" YearVisible="False" /> <DatePicker DayFormat="d (ddd)" YearVisible="False" />
<DatePicker IsEnabled="False" /> <DatePicker IsEnabled="False" />
<DatePicker Classes="Large" /> <DatePicker Classes="Large" />

View File

@ -8,14 +8,15 @@
<AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault> <AvaloniaUseCompiledBindingsByDefault>true</AvaloniaUseCompiledBindingsByDefault>
</PropertyGroup> </PropertyGroup>
<Import Project="../Directory.Build.props" />
<ItemGroup> <ItemGroup>
<PackageReference Include="Avalonia" Version="11.0.0" /> <PackageReference Include="Avalonia" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Desktop" Version="11.0.0" /> <PackageReference Include="Avalonia.Desktop" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.0.0" /> <PackageReference Include="Avalonia.Themes.Fluent" Version="$(AvaloniaVersion)" />
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.0.0" /> <PackageReference Include="Avalonia.Fonts.Inter" Version="$(AvaloniaVersion)" />
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.--> <!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.0.0" /> <PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="$(AvaloniaVersion)" />
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" /> <PackageReference Include="CommunityToolkit.Mvvm" Version="8.2.1" />
</ItemGroup> </ItemGroup>

View File

@ -7,7 +7,7 @@
<Authors>IRIHI Technology</Authors> <Authors>IRIHI Technology</Authors>
<Description>Avalonia Theme inspired by Semi Design.</Description> <Description>Avalonia Theme inspired by Semi Design.</Description>
<PackageProjectUrl>https://github.com/irihitech/Semi.Avalonia</PackageProjectUrl> <PackageProjectUrl>https://github.com/irihitech/Semi.Avalonia</PackageProjectUrl>
<AvaloniaVersion>11.0.0</AvaloniaVersion> <AvaloniaVersion>11.1.999-cibuild0040425</AvaloniaVersion>
<PackageLicenseExpression>MIT</PackageLicenseExpression> <PackageLicenseExpression>MIT</PackageLicenseExpression>
</PropertyGroup> </PropertyGroup>
</Project> </Project>

View File

@ -204,4 +204,26 @@
</Style> </Style>
</ControlTheme> </ControlTheme>
<ControlTheme x:Key="ButtonInputInnerButton" TargetType="Button">
<Setter Property="Foreground" Value="{DynamicResource ButtonInputInnerForeground}" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="Template">
<ControlTemplate TargetType="Button">
<ContentControl Background="Transparent">
<PathIcon
Width="16"
Height="16"
Data="{TemplateBinding Content}"
Foreground="{TemplateBinding Foreground}" />
</ContentControl>
</ControlTemplate>
</Setter>
<Style Selector="^:pointerover">
<Setter Property="Foreground" Value="{DynamicResource ButtonInputInnerPointeroverForeground}" />
</Style>
<Style Selector="^:pressed">
<Setter Property="Foreground" Value="{DynamicResource ButtonInputInnerPressedForeground}" />
</Style>
</ControlTheme>
</ResourceDictionary> </ResourceDictionary>

View File

@ -33,6 +33,7 @@
<Setter Property="MaxDropDownHeight" Value="504" /> <Setter Property="MaxDropDownHeight" Value="504" />
<Setter Property="Background" Value="{DynamicResource ComboBoxSelectorBackground}" /> <Setter Property="Background" Value="{DynamicResource ComboBoxSelectorBackground}" />
<Setter Property="BorderThickness" Value="1" /> <Setter Property="BorderThickness" Value="1" />
<Setter Property="Cursor" Value="Hand" />
<Setter Property="CornerRadius" Value="{DynamicResource ComboBoxSelectorCornerRadius}" /> <Setter Property="CornerRadius" Value="{DynamicResource ComboBoxSelectorCornerRadius}" />
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" /> <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" /> <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto" />
@ -43,11 +44,11 @@
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate TargetType="ComboBox"> <ControlTemplate TargetType="ComboBox">
<DataValidationErrors> <DataValidationErrors>
<Grid ColumnDefinitions="*,32"> <Grid ColumnDefinitions="*, Auto, 32">
<Border <Border
x:Name="Background" x:Name="Background"
Grid.Column="0" Grid.Column="0"
Grid.ColumnSpan="2" Grid.ColumnSpan="3"
MinWidth="{DynamicResource ComboBoxThemeMinWidth}" MinWidth="{DynamicResource ComboBoxThemeMinWidth}"
MinHeight="{DynamicResource ComboBoxDefaultHeight}" MinHeight="{DynamicResource ComboBoxDefaultHeight}"
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
@ -73,10 +74,16 @@
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}" VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Content="{TemplateBinding SelectionBoxItem}" Content="{TemplateBinding SelectionBoxItem}"
ContentTemplate="{TemplateBinding ItemTemplate}" /> ContentTemplate="{TemplateBinding ItemTemplate}" />
<Button
Grid.Column="1"
Name="ClearButton"
Content="{DynamicResource TextBoxClearButtonData}"
IsVisible="False"
Command="{Binding $parent[ComboBox].Clear}"
Theme="{DynamicResource ButtonInputInnerButton}" />
<Border <Border
x:Name="DropDownOverlay" x:Name="DropDownOverlay"
Grid.Column="1" Grid.Column="2"
Width="30" Width="30"
Margin="0,1,1,1" Margin="0,1,1,1"
HorizontalAlignment="Right" HorizontalAlignment="Right"
@ -85,7 +92,7 @@
<PathIcon <PathIcon
x:Name="DropDownGlyph" x:Name="DropDownGlyph"
Grid.Column="1" Grid.Column="2"
Width="12" Width="12"
Height="12" Height="12"
Margin="0,0,10,0" Margin="0,0,10,0"
@ -130,6 +137,12 @@
</DataValidationErrors> </DataValidationErrors>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
<Style Selector="^.clearButton, ^.ClearButton">
<Style Selector="^:pointerover /template/ Button#ClearButton" >
<Setter Property="IsVisible" Value="{Binding $parent[ComboBox].SelectionBoxItem, Converter={x:Static ObjectConverters.IsNotNull}}"></Setter>
</Style>
</Style>
<Style Selector="^.Large /template/ Border#Background"> <Style Selector="^.Large /template/ Border#Background">
<Setter Property="ComboBox.MinHeight" Value="{DynamicResource ComboBoxLargeHeight}" /> <Setter Property="ComboBox.MinHeight" Value="{DynamicResource ComboBoxLargeHeight}" />

View File

@ -135,11 +135,17 @@
<Setter Property="Template"> <Setter Property="Template">
<ControlTemplate TargetType="DatePicker"> <ControlTemplate TargetType="DatePicker">
<DataValidationErrors> <DataValidationErrors>
<Grid Name="LayoutRoot" Margin="{TemplateBinding Padding}"> <Grid
Name="LayoutRoot"
Margin="{TemplateBinding Padding}"
ColumnDefinitions="*, Auto">
<Button <Button
Name="PART_FlyoutButton" Name="PART_FlyoutButton"
Grid.Column="0"
Grid.ColumnSpan="2"
Width="298" Width="298"
MinWidth="298" MinWidth="298"
MinHeight="{DynamicResource DateTimePickerButtonDefaultHeight}"
HorizontalAlignment="Stretch" HorizontalAlignment="Stretch"
VerticalAlignment="Stretch" VerticalAlignment="Stretch"
Background="{TemplateBinding Background}" Background="{TemplateBinding Background}"
@ -150,7 +156,6 @@
DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}" DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}"
Foreground="{TemplateBinding Foreground}" Foreground="{TemplateBinding Foreground}"
IsEnabled="{TemplateBinding IsEnabled}" IsEnabled="{TemplateBinding IsEnabled}"
MinHeight="{DynamicResource DateTimePickerButtonDefaultHeight}"
Theme="{StaticResource DateTimePickerFlyoutButton}"> Theme="{StaticResource DateTimePickerFlyoutButton}">
<Grid ColumnDefinitions="*, Auto"> <Grid ColumnDefinitions="*, Auto">
<Grid <Grid
@ -210,21 +215,38 @@
Foreground="{DynamicResource DateTimePickerIconForeground}" /> Foreground="{DynamicResource DateTimePickerIconForeground}" />
</Grid> </Grid>
</Button> </Button>
<Popup <Popup
Name="PART_Popup" Name="PART_Popup"
Grid.Column="0"
Grid.ColumnSpan="2"
IsLightDismissEnabled="True" IsLightDismissEnabled="True"
Placement="Bottom" Placement="Bottom"
PlacementTarget="{TemplateBinding}" PlacementTarget="{TemplateBinding}"
WindowManagerAddShadowHint="False"> WindowManagerAddShadowHint="False">
<DatePickerPresenter Name="PART_PickerPresenter" /> <DatePickerPresenter Name="PART_PickerPresenter" />
</Popup> </Popup>
<Button
Name="ClearButton"
Grid.Column="1"
Command="{Binding $parent[DatePicker].Clear}"
Content="{DynamicResource TextBoxClearButtonData}"
IsVisible="False"
Margin="0 0 8 0"
Theme="{DynamicResource ButtonInputInnerButton}" />
</Grid> </Grid>
</DataValidationErrors> </DataValidationErrors>
</ControlTemplate> </ControlTemplate>
</Setter> </Setter>
<Style Selector="^.clearButton:pointerover, ^.ClearButton:pointerover">
<Style Selector="^:not(:hasnodate) /template/ Button#ClearButton">
<Setter Property="IsVisible" Value="True" />
</Style>
<Style Selector="^:not(:hasnodate) /template/ PathIcon#PART_Icon">
<Setter Property="Opacity" Value="0" />
</Style>
</Style>
<Style Selector="^:disabled /template/ PathIcon#PART_Icon"> <Style Selector="^:disabled /template/ PathIcon#PART_Icon">
<Setter Property="Foreground" Value="{DynamicResource DateTimePickerButtonDisabledIconForeground}" /> <Setter Property="Foreground" Value="{DynamicResource DateTimePickerButtonDisabledIconForeground}" />
</Style> </Style>

View File

@ -75,4 +75,8 @@
<SolidColorBrush x:Key="ButtonSolidDisabledBorderBrush" Color="#FF2E3238" /> <SolidColorBrush x:Key="ButtonSolidDisabledBorderBrush" Color="#FF2E3238" />
<!-- end Solid --> <!-- end Solid -->
<SolidColorBrush x:Key="ButtonInputInnerForeground" Color="#888D92" />
<SolidColorBrush x:Key="ButtonInputInnerPointeroverForeground" Color="#A7ABB0" />
<SolidColorBrush x:Key="ButtonInputInnerPressedForeground" Color="#C6CACD" />
</ResourceDictionary> </ResourceDictionary>

View File

@ -78,4 +78,8 @@
<SolidColorBrush x:Key="ButtonSolidDisabledBorderBrush" Color="Gray" /> <SolidColorBrush x:Key="ButtonSolidDisabledBorderBrush" Color="Gray" />
<!-- end Solid --> <!-- end Solid -->
<SolidColorBrush x:Key="ButtonInputInnerForeground" Color="#6B7075" />
<SolidColorBrush x:Key="ButtonInputInnerPointeroverForeground" Color="#555B61" />
<SolidColorBrush x:Key="ButtonInputInnerPressedForeground" Color="#41464C" />
</ResourceDictionary> </ResourceDictionary>