Skip to content

Commit

Permalink
Merge pull request #207 from AuroraZiling/main
Browse files Browse the repository at this point in the history
[Fix] CalendarDatePicker foreground
  • Loading branch information
kikipoulet authored Jun 1, 2024
2 parents 843d8ad + 5e5311f commit ac6ef1b
Show file tree
Hide file tree
Showing 3 changed files with 141 additions and 133 deletions.
140 changes: 140 additions & 0 deletions SukiUI/Theme/CalendarDatePickerStyle.axaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
<ResourceDictionary xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="using:System"
x:ClassModifier="internal">

<Design.PreviewWith>
<Border Width="800"
Height="800"
Padding="50">
<CalendarDatePicker />
</Border>
</Design.PreviewWith>

<ControlTheme x:Key="{x:Type CalendarDatePicker}" TargetType="CalendarDatePicker">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderThickness" Value="0,0,0,1" />
<Setter Property="FontSize" Value="14" />
<Setter Property="BorderBrush" Value="{DynamicResource SukiControlBorderBrush}" />
<Setter Property="Padding" Value="4" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="Template">
<ControlTemplate>
<Grid ColumnDefinitions="*,Auto">
<Grid.Styles>
<Style Selector="Button.CalendarDropDown">
<Setter Property="Template">
<ControlTemplate>
<Grid Width="22"
Height="20"
Margin="0,0,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Background="Transparent"
ClipToBounds="False"
ColumnDefinitions="*,*,*,*"
RowDefinitions="23*,19*,19*,19*">

<Border Name="Background"
Grid.Row="1"
Grid.RowSpan="3"
Grid.Column="0"
Grid.ColumnSpan="4"
Margin="0,-1,0,0"
BorderBrush="{DynamicResource SukiControlBorderBrush}"
BorderThickness="1"
CornerRadius="0,0,2,2" />

<Border Grid.Row="0"
Grid.Column="0"
Grid.ColumnSpan="4"
Background="{DynamicResource SukiPrimaryColor}"
BorderBrush="{DynamicResource SukiControlBorderBrush}"
BorderThickness="1"
CornerRadius="3,3,0,0" />

<TextBlock Grid.Row="1"
Grid.RowSpan="3"
Grid.Column="0"
Grid.ColumnSpan="4"
Margin="0,-1,0,0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="{DynamicResource FontSizeSmall}"
Foreground="{DynamicResource SukiLowText}"
Text="{Binding Source={x:Static sys:DateTime.Today}, Path=Day}" />

<Ellipse Grid.Row="0"
Grid.Column="0"
Grid.ColumnSpan="4"
Width="2"
Height="2"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Fill="{DynamicResource SukiControlBorderBrush}"
StrokeThickness="0" />
</Grid>
</ControlTemplate>
</Setter>
</Style>

<Style Selector="Button.CalendarDropDown:pointerover /template/ Border#Background">
<Setter Property="Background" Value="{DynamicResource SukiPrimaryColor5}" />
</Style>
</Grid.Styles>

<TextBox Name="PART_TextBox"
Grid.Column="0"
Padding="{TemplateBinding Padding}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}"
DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}"
UseFloatingWatermark="{TemplateBinding UseFloatingWatermark}"
Watermark="{TemplateBinding Watermark}" />

<Button Name="PART_Button"
Grid.Column="1"
Width="20"
Margin="6,0"
Padding="0"
Background="Transparent"
BorderThickness="0"
Classes="CalendarDropDown"
ClipToBounds="False"
Focusable="False"
Foreground="{TemplateBinding Foreground}" />

<Popup Name="PART_Popup"
Grid.Column="0"
IsLightDismissEnabled="False"
PlacementTarget="{TemplateBinding}">
<Panel>
<Border Margin="15"
Padding="15,8,8,12"
Background="{DynamicResource SukiStrongBackground}"
BoxShadow="{DynamicResource SukiPopupShadow}"
CornerRadius="14">
<Calendar Name="PART_Calendar"
DisplayDate="{TemplateBinding DisplayDate}"
DisplayDateEnd="{TemplateBinding DisplayDateEnd}"
DisplayDateStart="{TemplateBinding DisplayDateStart}"
FirstDayOfWeek="{TemplateBinding FirstDayOfWeek}"
Foreground="{DynamicResource SukiText}"
IsTodayHighlighted="{TemplateBinding IsTodayHighlighted}"
SelectedDate="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=SelectedDate, Mode=TwoWay}" />
</Border>
</Panel>
</Popup>
</Grid>
</ControlTemplate>
</Setter>

<Style Selector="^:focus /template/ TextBox#PART_TextBox">
<Setter Property="BorderBrush" Value="{DynamicResource ThemeBorderHighBrush}" />
</Style>
</ControlTheme>
</ResourceDictionary>
132 changes: 0 additions & 132 deletions SukiUI/Theme/CalendarDatePickertyle.axaml

This file was deleted.

2 changes: 1 addition & 1 deletion SukiUI/Theme/Index.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<ResourceInclude Source="avares://sukiUI/Theme/Button.axaml" />
<ResourceInclude Source="avares://sukiUI/Theme/PathIcon.axaml" />
<ResourceInclude Source="avares://sukiUI/Theme/Expander.axaml" />
<ResourceInclude Source="avares://sukiUI/Theme/CalendarDatePickertyle.axaml" />
<ResourceInclude Source="avares://sukiUI/Theme/CalendarDatePickerStyle.axaml" />
<ResourceInclude Source="avares://sukiUI/Theme/TabControl.axaml" />
<ResourceInclude Source="avares://sukiUI/Theme/TabItem.axaml" />
<ResourceInclude Source="avares://sukiUI/Theme/DropDownButton.axaml" />
Expand Down

0 comments on commit ac6ef1b

Please sign in to comment.