Skip to content

Commit

Permalink
Fixed the issue where the font color did not change when disabling Te…
Browse files Browse the repository at this point in the history
…xtBox and NumericUpDown
  • Loading branch information
YJammak committed Oct 17, 2024
1 parent 4a1abef commit 6cc18c4
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 68 deletions.
97 changes: 52 additions & 45 deletions SukiUI/Theme/NumericUpDownStyles.xaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:theme="clr-namespace:SukiUI.Theme"
xmlns:suki="https://github.com/kikipoulet/SukiUI">
xmlns:suki="https://github.com/kikipoulet/SukiUI"
xmlns:theme="clr-namespace:SukiUI.Theme">
<Design.PreviewWith>
<Border Padding="20">
<StackPanel Orientation="Horizontal" Spacing="5" >
<NumericUpDown Value="4" />
<TextBox Classes="NoShadow" Text="test"></TextBox>
<StackPanel Orientation="Horizontal" Spacing="5">
<NumericUpDown Value="4" />
<TextBox Classes="NoShadow" Text="test" />
</StackPanel>
</Border>
</Design.PreviewWith>
Expand All @@ -19,45 +19,50 @@
<Setter Property="Padding" Value="4" />
<Setter Property="Template">
<ControlTemplate>
<suki:GlassCard Classes="Discrete" VerticalAlignment="Center" CornerRadius="{TemplateBinding CornerRadius}" Padding="0">
<ButtonSpinner Name="PART_Spinner"
Margin="5,4"
Height="26"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
AllowSpin="{TemplateBinding AllowSpin}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
ButtonSpinnerLocation="{TemplateBinding ButtonSpinnerLocation}"
CornerRadius="{TemplateBinding CornerRadius}"
ShowButtonSpinner="{TemplateBinding ShowButtonSpinner}">
<Grid ColumnDefinitions="*,Auto">
<TextBox Name="PART_TextBox"
MinWidth="20"
Margin="-5,-5,-5,-6"
Padding="{TemplateBinding Padding}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
theme:TextBoxExtensions.AddDeleteButton="False"
AcceptsReturn="False"
Background="Transparent"
BorderThickness="0"
Classes="NoShadow"
CornerRadius="0"
DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}"
IsReadOnly="{TemplateBinding IsReadOnly}"
Text="{TemplateBinding Text}"
TextWrapping="NoWrap"
Watermark="{TemplateBinding Watermark}" />
<TextBlock VerticalAlignment="Center" Margin="0,1,9,0"
FontSize="13" Grid.Column="1"
Foreground="{DynamicResource SukiLowText}"
Text="{TemplateBinding theme:NumericUpDownExtensions.Unit}" />
</Grid>

</ButtonSpinner>
</suki:GlassCard>
<suki:GlassCard Padding="0"
VerticalAlignment="Center"
Classes="Discrete"
CornerRadius="{TemplateBinding CornerRadius}">
<ButtonSpinner Name="PART_Spinner"
Height="26"
Margin="5,4"
HorizontalContentAlignment="Stretch"
VerticalContentAlignment="Stretch"
AllowSpin="{TemplateBinding AllowSpin}"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
ButtonSpinnerLocation="{TemplateBinding ButtonSpinnerLocation}"
CornerRadius="{TemplateBinding CornerRadius}"
ShowButtonSpinner="{TemplateBinding ShowButtonSpinner}">
<Grid ColumnDefinitions="*,Auto">
<TextBox Name="PART_TextBox"
MinWidth="20"
Margin="-5,-5,-5,-6"
Padding="{TemplateBinding Padding}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
theme:TextBoxExtensions.AddDeleteButton="False"
AcceptsReturn="False"
Background="Transparent"
BorderThickness="0"
Classes="NoShadow"
CornerRadius="0"
DataValidationErrors.Errors="{TemplateBinding (DataValidationErrors.Errors)}"
IsReadOnly="{TemplateBinding IsReadOnly}"
Text="{TemplateBinding Text}"
TextWrapping="NoWrap"
Watermark="{TemplateBinding Watermark}" />
<TextBlock Grid.Column="1"
Margin="0,1,9,0"
VerticalAlignment="Center"
FontSize="13"
Foreground="{DynamicResource SukiLowText}"
Text="{TemplateBinding theme:NumericUpDownExtensions.Unit}" />
</Grid>

</ButtonSpinner>
</suki:GlassCard>
</ControlTemplate>
</Setter>
</Style>
Expand All @@ -77,6 +82,9 @@
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderBrush" Value="{DynamicResource SukiControlBorderBrush}" />
</Style>
<Style Selector="NumericUpDown:disabled">
<Setter Property="Foreground" Value="{DynamicResource SukiDisabledText}" />
</Style>

<Style Selector="RepeatButton:pointerover">
<Setter Property="BorderBrush" Value="{DynamicResource SukiBorderBrush}" />
Expand Down Expand Up @@ -128,7 +136,6 @@
</RepeatButton>
</UniformGrid>
<ContentPresenter Name="PART_ContentPresenter"
Grid.Column="1"
Padding="{TemplateBinding Padding}"
HorizontalContentAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalContentAlignment="{TemplateBinding VerticalContentAlignment}"
Expand Down
50 changes: 27 additions & 23 deletions SukiUI/Theme/TextBoxStyles.xaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
<Styles xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:content="clr-namespace:SukiUI.Content"
xmlns:theme="clr-namespace:SukiUI.Theme"
xmlns:suki="https://github.com/kikipoulet/SukiUI"
xmlns:system="clr-namespace:System;assembly=netstandard">
xmlns:theme="clr-namespace:SukiUI.Theme">

<Design.PreviewWith>
<Border Width="300"
Expand All @@ -27,6 +26,10 @@
<TextBox Width="200"
Margin="5"
Text="Elem" />
<TextBox Width="200"
Margin="5"
IsEnabled="False"
Text="Elem" />
<TextBox Classes="NoShadow" Text="Elem" />

<Panel>
Expand Down Expand Up @@ -224,7 +227,6 @@
</Style>



<Style Selector="TextBox.Suffix">
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="BorderThickness" Value="1.2" />
Expand Down Expand Up @@ -353,23 +355,23 @@

<Border Padding="5">
<Border.Resources>


<theme:StringToDoubleConverter x:Key="StringToDoubleC" />
</Border.Resources>
<Panel>
<suki:GlassCard Name="border"
Padding="0" Classes="Discrete"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"

CornerRadius="{TemplateBinding CornerRadius}">
<suki:GlassCard.Transitions>
<Transitions>
<BrushTransition Property="BorderBrush" Duration="0:0:0.2" />
</Transitions>
</suki:GlassCard.Transitions>
</suki:GlassCard>
<suki:GlassCard Name="border"
Padding="0"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
Classes="Discrete"
CornerRadius="{TemplateBinding CornerRadius}">
<suki:GlassCard.Transitions>
<Transitions>
<BrushTransition Property="BorderBrush" Duration="0:0:0.2" />
</Transitions>
</suki:GlassCard.Transitions>
</suki:GlassCard>
<Border Name="borderbottom"
Margin="1,-1,1,-1"
BorderBrush="{TemplateBinding BorderBrush}"
Expand Down Expand Up @@ -474,7 +476,7 @@
<Style Selector="TextBox.FlatTextBox /template/ suki|GlassCard#border">
<Setter Property="BorderThickness" Value="0" />
<Setter Property="ClipToBounds" Value="True" />

</Style>


Expand All @@ -496,7 +498,7 @@
</Style>
<Style Selector="TextBox:focus /template/ suki|GlassCard#border">
<Setter Property="BorderBrush" Value="{DynamicResource SukiPrimaryColor}" />
<Setter Property="BorderThickness" Value="1.2" />
<Setter Property="BorderThickness" Value="1.2" />
</Style>
<Style Selector="TextBox:error /template/ suki|GlassCard#border">
<Setter Property="BorderBrush" Value="{DynamicResource ErrorBrush}" />
Expand All @@ -507,6 +509,9 @@
<Style Selector="TextBox:disabled /template/ suki|GlassCard#border">
<Setter Property="Opacity" Value="{DynamicResource ThemeDisabledOpacity}" />
</Style>
<Style Selector="TextBox:disabled">
<Setter Property="Foreground" Value="{DynamicResource SukiDisabledText}" />
</Style>

<Style Selector="TextBox.clearButton[AcceptsReturn=False][IsReadOnly=False]:focus:not(TextBox:empty)">
<Setter Property="InnerRightContent">
Expand Down Expand Up @@ -606,17 +611,16 @@
<Style Selector="TextBox.NoShadow /template/ Border">
<Setter Property="BoxShadow" Value="0 0 0 0 Gray" />
</Style>

<Style Selector="TextBox.NoShadow /template/ suki|GlassCard#border">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
<Setter Property="IsVisible" Value="False"></Setter>
<Setter Property="IsVisible" Value="False" />
</Style>

<Style Selector="TextBox.NoShadow:focus /template/ suki|GlassCard#border">
<Setter Property="Background" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" />
</Style>


</Styles>

0 comments on commit 6cc18c4

Please sign in to comment.