Skip to content

Commit

Permalink
Merge pull request WalletWasabi#13177 from SuperJMN/improvements/chec…
Browse files Browse the repository at this point in the history
…kmark-inside-passwordbox

[UI] Moved validation checkmark inside PasswordBox
  • Loading branch information
RolandUI authored Jun 21, 2024
2 parents 57d79dc + 0b55d4e commit 936b546
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 102 deletions.
21 changes: 8 additions & 13 deletions WalletWasabi.Fluent/Behaviors/CheckMarkVisibilityBehavior.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,15 @@ protected override void OnAttachedToVisualTree(CompositeDisposable disposable)

hasErrors.ToSignal()
.Merge(text.ToSignal())
.Throttle(TimeSpan.FromMilliseconds(100))
.ObserveOn(RxApp.MainThreadScheduler)
.Subscribe(
_ =>
.Subscribe(_ =>
{
if (AssociatedObject is { })
{
if (AssociatedObject is { })
{
AssociatedObject.Opacity =
!DataValidationErrors.GetHasErrors(ownerTextBox) &&
!string.IsNullOrEmpty(ownerTextBox.Text)
? 1
: 0;
}
})
AssociatedObject.IsVisible =
!DataValidationErrors.GetHasErrors(ownerTextBox) &&
!string.IsNullOrEmpty(ownerTextBox.Text);
}
})
.DisposeWith(disposable);
}
}
141 changes: 68 additions & 73 deletions WalletWasabi.Fluent/Controls/TextBox.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,79 +21,74 @@

<DataValidationErrors DockPanel.Dock="Bottom" Margin="0 5 0 0" />

<DockPanel>
<PathIcon Classes="checkMark checkMarkDataValidation" Margin="15 0" VerticalAlignment="Center" DockPanel.Dock="Right">
<Interaction.Behaviors>
<CheckMarkVisibilityBehavior />
</Interaction.Behaviors>
</PathIcon>
<!-- TODO: Fix System.ArgumentException: Unable to resolve namespace for type validation:CheckMarkStatus -->
<!-- TODO: Seems like CheckMarkStatus.IsEnabled is never actually set to True -->
<!--<PathIcon Classes="checkMark checkMarkBoolean"
Margin="15 0"
VerticalAlignment="Center"
DockPanel.Dock="Right"
Opacity="{Binding (validation:CheckMarkStatus.IsEnabled), RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static conv:BoolOpacityConverters.BoolToOpacity}}" />-->
<Panel>
<Border
Name="PART_BorderElement"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
MinWidth="{TemplateBinding MinWidth}"
MinHeight="{TemplateBinding MinHeight}" />

<Border
Margin="{TemplateBinding BorderThickness}">
<Grid ColumnDefinitions="Auto,*,Auto">
<ContentPresenter Grid.Column="0" Grid.ColumnSpan="1" Content="{TemplateBinding InnerLeftContent}" />
<DockPanel x:Name="PART_InnerDockPanel" Grid.Column="1" Grid.ColumnSpan="1" Margin="{TemplateBinding Padding}">
<TextBlock Name="PART_FloatingWatermark"
Foreground="{DynamicResource SystemAccentColor}"
FontSize="{TemplateBinding FontSize}"
Text="{TemplateBinding Watermark}"
IsVisible="{TemplateBinding UseFloatingWatermark}"
DockPanel.Dock="Top" />
<ScrollViewer HorizontalScrollBarVisibility="{TemplateBinding (ScrollViewer.HorizontalScrollBarVisibility)}"
VerticalScrollBarVisibility="{TemplateBinding (ScrollViewer.VerticalScrollBarVisibility)}">
<Panel>
<TextBlock Name="PART_Watermark"
Opacity="0.5"
Text="{TemplateBinding Watermark}"
TextAlignment="{TemplateBinding TextAlignment}"
TextWrapping="{TemplateBinding TextWrapping}"
IsVisible="{TemplateBinding Text, Converter={x:Static StringConverters.IsNullOrEmpty}}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
<TextPresenter Name="PART_TextPresenter"
Text="{TemplateBinding Text, Mode=TwoWay}"
CaretIndex="{TemplateBinding CaretIndex}"
SelectionStart="{TemplateBinding SelectionStart}"
SelectionEnd="{TemplateBinding SelectionEnd}"
TextAlignment="{TemplateBinding TextAlignment}"
TextWrapping="{TemplateBinding TextWrapping}"
LineHeight="{TemplateBinding LineHeight}"
LetterSpacing="{TemplateBinding LetterSpacing}"
PasswordChar="{TemplateBinding PasswordChar}"
RevealPassword="{TemplateBinding RevealPassword}"
SelectionBrush="{TemplateBinding SelectionBrush}"
SelectionForegroundBrush="{TemplateBinding SelectionForegroundBrush}"
CaretBrush="{TemplateBinding CaretBrush}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</Panel>
<ScrollViewer.Styles>
<Style Selector="ScrollContentPresenter#PART_ContentPresenter">
<Setter Property="Cursor" Value="IBeam" />
</Style>
</ScrollViewer.Styles>
</ScrollViewer>
</DockPanel>
<ContentPresenter Grid.Column="2" Grid.ColumnSpan="1" Content="{TemplateBinding InnerRightContent}" />
</Grid>
</Border>
</Panel>
</DockPanel>
<Panel>
<Border
Name="PART_BorderElement"
Background="{TemplateBinding Background}"
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}"
MinWidth="{TemplateBinding MinWidth}"
MinHeight="{TemplateBinding MinHeight}" />

<Border
Margin="{TemplateBinding BorderThickness}">
<Grid ColumnDefinitions="Auto,*,Auto">
<ContentPresenter Grid.Column="0" Grid.ColumnSpan="1" Content="{TemplateBinding InnerLeftContent}" />
<DockPanel x:Name="PART_InnerDockPanel" Grid.Column="1" Grid.ColumnSpan="1" Margin="{TemplateBinding Padding}">
<TextBlock Name="PART_FloatingWatermark"
Foreground="{DynamicResource SystemAccentColor}"
FontSize="{TemplateBinding FontSize}"
Text="{TemplateBinding Watermark}"
IsVisible="{TemplateBinding UseFloatingWatermark}"
DockPanel.Dock="Top" />
<ScrollViewer HorizontalScrollBarVisibility="{TemplateBinding (ScrollViewer.HorizontalScrollBarVisibility)}"
VerticalScrollBarVisibility="{TemplateBinding (ScrollViewer.VerticalScrollBarVisibility)}">
<Panel>
<TextBlock Name="PART_Watermark"
Opacity="0.5"
Text="{TemplateBinding Watermark}"
TextAlignment="{TemplateBinding TextAlignment}"
TextWrapping="{TemplateBinding TextWrapping}"
IsVisible="{TemplateBinding Text, Converter={x:Static StringConverters.IsNullOrEmpty}}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
<TextPresenter Name="PART_TextPresenter"
Text="{TemplateBinding Text, Mode=TwoWay}"
CaretIndex="{TemplateBinding CaretIndex}"
SelectionStart="{TemplateBinding SelectionStart}"
SelectionEnd="{TemplateBinding SelectionEnd}"
TextAlignment="{TemplateBinding TextAlignment}"
TextWrapping="{TemplateBinding TextWrapping}"
LineHeight="{TemplateBinding LineHeight}"
LetterSpacing="{TemplateBinding LetterSpacing}"
PasswordChar="{TemplateBinding PasswordChar}"
RevealPassword="{TemplateBinding RevealPassword}"
SelectionBrush="{TemplateBinding SelectionBrush}"
SelectionForegroundBrush="{TemplateBinding SelectionForegroundBrush}"
CaretBrush="{TemplateBinding CaretBrush}"
HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
VerticalAlignment="{TemplateBinding VerticalContentAlignment}" />
</Panel>
<ScrollViewer.Styles>
<Style Selector="ScrollContentPresenter#PART_ContentPresenter">
<Setter Property="Cursor" Value="IBeam" />
</Style>
</ScrollViewer.Styles>
</ScrollViewer>
</DockPanel>
<StackPanel Grid.Column="2" Orientation="Horizontal" Spacing="10">
<Panel x:Name="CheckmarkHost">
<PathIcon Classes="checkMark" VerticalAlignment="Center">
<Interaction.Behaviors>
<CheckMarkVisibilityBehavior />
</Interaction.Behaviors>
</PathIcon>
</Panel>
<ContentPresenter Content="{TemplateBinding InnerRightContent}" />
</StackPanel>
</Grid>
</Border>
</Panel>
</DockPanel>
</ControlTemplate>
</Setter>
Expand Down
6 changes: 0 additions & 6 deletions WalletWasabi.Fluent/Styles/Checkmark.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,5 @@
<Setter Property="Width" Value="15" />
<Setter Property="Height" Value="15" />
<Setter Property="Data" Value="{StaticResource checkmark_filled}" />
<Setter Property="Opacity" Value="0" />
<Setter Property="Transitions">
<Transitions>
<DoubleTransition Property="Opacity" Duration="0:0:0.3" />
</Transitions>
</Setter>
</Style>
</Styles>
12 changes: 2 additions & 10 deletions WalletWasabi.Fluent/Styles/TextBox.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,11 @@
<Setter Property="Theme" Value="{DynamicResource TextBoxTheme}" />
</Style>

<Style Selector="TextBox:not(.hasCheckMark) /template/ PathIcon.checkMark.checkMarkDataValidation">
<Style Selector="TextBox:not(.hasCheckMark) /template/ Panel#CheckmarkHost">
<Setter Property="IsVisible" Value="False" />
</Style>

<Style Selector="TextBox.hasCheckMark /template/ PathIcon.checkMark.checkMarkDataValidation">
<Setter Property="IsVisible" Value="True" />
</Style>

<Style Selector="TextBox:not(.hasCheckMarkBoolean) /template/ PathIcon.checkMark.checkMarkBoolean">
<Setter Property="IsVisible" Value="False" />
</Style>

<Style Selector="TextBox.hasCheckMarkBoolean /template/ PathIcon.checkMark.checkMarkBoolean">
<Style Selector="TextBox.hasCheckMark /template/ Panel#CheckmarkHost">
<Setter Property="IsVisible" Value="True" />
</Style>

Expand Down

0 comments on commit 936b546

Please sign in to comment.