Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: MaterialOutlinedPasswordBox content shift #1497

Merged
merged 5 commits into from
Oct 31, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions src/library/Uno.Material/Styles/Controls/v2/PasswordBox.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -471,32 +471,26 @@
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="PasswordBox">
<Border x:Name="RootBorder"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}"
Padding="{ThemeResource OutlinedPasswordBoxBorderPadding}">
Kunal22shah marked this conversation as resolved.
Show resolved Hide resolved

<Grid>
<VisualStateManager.VisualStateGroups>
<VisualStateGroup x:Name="CommonStates">
<VisualState x:Name="Normal" />

<VisualState x:Name="PointerOver">
<VisualState.Setters>
<Setter Target="RootBorder.BorderBrush" Value="{ThemeResource OutlinedPasswordBoxBorderBrushPointerOver}" />
<Setter Target="BorderBorder.BorderBrush" Value="{ThemeResource OutlinedPasswordBoxBorderBrushPointerOver}" />
Kunal22shah marked this conversation as resolved.
Show resolved Hide resolved
<Setter Target="ContentElement.Foreground" Value="{ThemeResource OutlinedPasswordBoxForegroundPointerOver}" />
<Setter Target="PlaceholderElement.Foreground" Value="{ThemeResource OutlinedPasswordBoxPlaceholderForegroundPointerOver}" />
<Setter Target="Root.Background" Value="{ThemeResource OutlinedPasswordBoxBackgroundPointerOver}" />
<Setter Target="RootBorder.BorderThickness" Value="{ThemeResource OutlinedPasswordBoxBorderThicknessPointerOver}" />
<Setter Target="RootBorder.Padding" Value="{ThemeResource OutlinedPasswordBoxBorderPaddingPointerOver}" />
<Setter Target="BorderBorder.BorderThickness" Value="{ThemeResource OutlinedPasswordBoxBorderThicknessPointerOver}" />
</VisualState.Setters>
</VisualState>

<VisualState x:Name="Pressed" />

<VisualState x:Name="Disabled">
<VisualState.Setters>
<Setter Target="RootBorder.BorderBrush" Value="{ThemeResource OutlinedPasswordBoxBorderBrushDisabled}" />
<Setter Target="BorderBorder.BorderBrush" Value="{ThemeResource OutlinedPasswordBoxBorderBrushDisabled}" />
<!-- In this case the opacity is not applied to the brush directly - known issue for ContentElement -->
<Setter Target="ContentElement.Foreground" Value="{ThemeResource OutlinedPasswordBoxForegroundDisabled}" />
<Setter Target="ContentElement.Opacity" Value="{ThemeResource OutlinedPasswordBoxForegroundOpacityDisabled}" />
Expand All @@ -508,12 +502,11 @@

<VisualState x:Name="Focused">
<VisualState.Setters>
<Setter Target="RootBorder.BorderBrush" Value="{ThemeResource OutlinedPasswordBoxBorderBrushFocused}" />
<Setter Target="BorderBorder.BorderBrush" Value="{ThemeResource OutlinedPasswordBoxBorderBrushFocused}" />
<Setter Target="ContentElement.Foreground" Value="{ThemeResource OutlinedPasswordBoxForegroundFocused}" />
<Setter Target="PlaceholderElement.Foreground" Value="{ThemeResource OutlinedPasswordBoxPlaceholderForegroundFocused}" />
<Setter Target="Root.Background" Value="{ThemeResource OutlinedPasswordBoxBackgroundFocused}" />
<Setter Target="RootBorder.BorderThickness" Value="{ThemeResource OutlinedPasswordBoxBorderThicknessFocused}" />
<Setter Target="RootBorder.Padding" Value="{ThemeResource OutlinedPasswordBoxBorderPaddingFocused}" />
<Setter Target="BorderBorder.BorderThickness" Value="{ThemeResource OutlinedPasswordBoxBorderThicknessFocused}" />
</VisualState.Setters>
</VisualState>
</VisualStateGroup>
Expand Down Expand Up @@ -568,6 +561,7 @@
</VisualStateGroup>
</VisualStateManager.VisualStateGroups>

<!-- Content Grid -->
<Grid x:Name="Root"
Padding="{TemplateBinding Padding}"
Background="{TemplateBinding Background}">
Expand All @@ -577,7 +571,9 @@
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>

<!-- IconPresenter -->
<ContentPresenter x:Name="IconPresenter"
Grid.Column="0"
MinWidth="25"
MaxWidth="34"
MaxHeight="34"
Expand All @@ -588,6 +584,7 @@
Content="{Binding Path=(ut:ControlExtensions.Icon), RelativeSource={RelativeSource TemplatedParent}}"
Visibility="{Binding Path=(ut:ControlExtensions.Icon), RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource NullToCollapsedConverter}, FallbackValue=Collapsed, TargetNullValue=Collapsed}" />

<!-- ContentElement -->
<ScrollViewer x:Name="ContentElement"
Grid.Column="1"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
Expand All @@ -606,6 +603,7 @@
</ScrollViewer.RenderTransform>
</ScrollViewer>

<!-- PlaceholderElement -->
<TextBlock x:Name="PlaceholderElement"
Grid.Column="1"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
Expand All @@ -619,6 +617,7 @@
</TextBlock.RenderTransform>
</TextBlock>

<!-- RevealButton -->
<Button x:Name="RevealButton"
Grid.Column="2"
MinWidth="34"
Expand All @@ -629,7 +628,12 @@
Style="{StaticResource MaterialRevealButtonStyle}"
Visibility="Collapsed" />
</Grid>
</Border>

<Border x:Name="BorderBorder"
Kunal22shah marked this conversation as resolved.
Show resolved Hide resolved
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
CornerRadius="{TemplateBinding CornerRadius}" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
Expand Down
Loading