Simplify converters
ADD
WalletWasabi.Fluent/Converters/BoolOpacityConverters.cs
+using Avalonia.Data.Converters;
+
+namespace WalletWasabi.Fluent.Converters
+{
+ public static class BoolOpacityConverters
+ {
+ public static readonly IValueConverter BoolToOpacity =
+ new FuncValueConverter<bool, double>(x => x ? 1.0 : 0.0);
+
+ public static readonly IValueConverter OpacityToBool =
+ new FuncValueConverter<double, bool>(x => x > 0);
+ }
+}

DELETE
WalletWasabi.Fluent/Converters/BoolToOpacityConverter.cs
-using Avalonia.Data.Converters;
-using System;
-using System.Globalization;
-
-namespace WalletWasabi.Fluent.Converters
-{
- public class BoolToOpacityConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return (bool)value ? 1.0 : 0.0;
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
-}
\ No newline at end of file

DELETE
WalletWasabi.Fluent/Converters/OpacityToBoolConverter.cs
-using Avalonia.Data.Converters;
-using System;
-using System.Collections.Generic;
-using System.Globalization;
-using System.Text;
-
-namespace WalletWasabi.Fluent.Converters
-{
- public class OpacityToBoolConverter : IValueConverter
- {
- public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- return ((double)value) > 0;
- }
-
- public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
-}

MODIFY
WalletWasabi.Fluent/ViewModels/Dialogs/EnterPasswordViewModel.cs
WalletWasabi.Fluent/ViewModels/Dialogs/EnterPasswordViewModel.cs
@@ -9,14 +9,11 @@ namespace WalletWasabi.Fluent.ViewModels.Dialogs
{
public class EnterPasswordViewModel : DialogViewModelBase<string>
{
- private IScreen _screen;
private string _password;
private string _confirmPassword;
public EnterPasswordViewModel(IScreen screen)
{
- _screen = screen;
-
this.ValidateProperty(x => x.Password, ValidatePassword);
this.ValidateProperty(x => x.ConfirmPassword, ValidateConfirmPassword);

MODIFY
WalletWasabi.Fluent/Views/AddWallet/ConfirmRecoveryWordsView.axaml
WalletWasabi.Fluent/Views/AddWallet/ConfirmRecoveryWordsView.axaml
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:i="clr-namespace:Avalonia.Xaml.Interactivity;assembly=Avalonia.Xaml.Interactivity"
xmlns:behaviors="clr-namespace:WalletWasabi.Fluent.Behaviors;assembly=WalletWasabi.Fluent"
- xmlns:converters="clr-namespace:WalletWasabi.Fluent.Converters;assembly=WalletWasabi.Fluent"
+ xmlns:conv="clr-namespace:WalletWasabi.Fluent.Converters"
xmlns:c="clr-namespace:WalletWasabi.Fluent.Controls"
mc:Ignorable="d"
d:DesignWidth="600" d:DesignHeight="500"
x:Class="WalletWasabi.Fluent.Views.AddWallet.ConfirmRecoveryWordsView">
- <UserControl.Resources>
- <converters:BoolToOpacityConverter x:Key="BoolToOpacityConverter" />
- </UserControl.Resources>
<UserControl.KeyBindings>
<KeyBinding Gesture="Enter" Command="{Binding FinishCommand}" />
</UserControl.KeyBindings>
<ItemsControl.ItemTemplate>
<DataTemplate>
<DockPanel Margin="0 0 0 20" HorizontalAlignment="Left">
- <PathIcon Classes="checkMark" Margin="15 42 0 0" Opacity="{Binding IsConfirmed, Converter={StaticResource BoolToOpacityConverter}}" VerticalAlignment="Top" DockPanel.Dock="Right" />
+ <PathIcon Classes="checkMark" Margin="15 42 0 0" Opacity="{Binding IsConfirmed, Converter={x:Static conv:BoolOpacityConverters.BoolToOpacity}}" VerticalAlignment="Top" DockPanel.Dock="Right" />
<Label Content="{Binding Index, StringFormat=Recovery word {0}}" DockPanel.Dock="Top" />
<TextBox Watermark="Type the word here..." Text="{Binding Input}" IsEnabled="{Binding !IsConfirmed}" DockPanel.Dock="Top" Width="350" FontSize="12">
<i:Interaction.Behaviors>

MODIFY
WalletWasabi.Fluent/Views/AddWalletPageView.axaml
WalletWasabi.Fluent/Views/AddWalletPageView.axaml
xmlns:c="clr-namespace:WalletWasabi.Fluent.Controls"
xmlns:conv="clr-namespace:WalletWasabi.Fluent.Converters"
xmlns:i="clr-namespace:Avalonia.Xaml.Interactivity;assembly=Avalonia.Xaml.Interactivity"
- xmlns:converters="clr-namespace:WalletWasabi.Fluent.Converters;assembly=WalletWasabi.Fluent"
xmlns:behaviors="clr-namespace:WalletWasabi.Fluent.Behaviors"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:DataType="vm:HomePageViewModel"
x:Class="WalletWasabi.Fluent.Views.AddWalletPageView">
- <UserControl.Resources>
- <converters:BoolToOpacityConverter x:Key="BoolToOpacityConverter" />
- <converters:OpacityToBoolConverter x:Key="OpacityToBoolConverter" />
- </UserControl.Resources>
<c:ContentArea Title="Add Wallet" Caption="Type in your wallets name and select an option:">
<DockPanel>
<Setter Property="BorderThickness" Value="1" />
<Setter Property="Padding" Value="0" />
<Setter Property="IsEnabled" Value="{Binding OptionsEnabled}" />
- <Setter Property="Opacity" Value="{Binding OptionsEnabled, Converter={StaticResource BoolToOpacityConverter}}" />
- <Setter Property="IsVisible" Value="{Binding $self.Opacity, Converter={StaticResource OpacityToBoolConverter}}}" />
+ <Setter Property="Opacity" Value="{Binding OptionsEnabled, Converter={x:Static conv:BoolOpacityConverters.BoolToOpacity}}" />
+ <Setter Property="IsVisible" Value="{Binding $self.Opacity, Converter={x:Static conv:BoolOpacityConverters.OpacityToBool}}" />
</Style>
<Style Selector="Button.option:disabled /template/ ContentPresenter#PART_ContentPresenter">
<Setter Property="Background" Value="{DynamicResource OptionButtonBackground}" />

Simplify converters