Skip to content

Commit

Permalink
SelectAll Button
Browse files Browse the repository at this point in the history
  • Loading branch information
ichthus1604 committed Jun 11, 2024
1 parent 4ee4f48 commit ace312b
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 25 deletions.
23 changes: 23 additions & 0 deletions WalletWasabi.Fluent/Controls/Button.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,29 @@
</Setter>
</ControlTheme>

<ControlTheme x:Key="DialogSelectAllButton" TargetType="ToggleButton" BasedOn="{StaticResource DialogButton}">
<Style Selector="^[IsChecked=True]">
<Setter Property="ToolTip.Tip" Value="Unselect all" />
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<PathIcon Height="13" Foreground="{DynamicResource AcrylicTrimForeground}" Data="{StaticResource select_none}" />
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
<Style Selector="^[IsChecked=False]">
<Setter Property="ToolTip.Tip" Value="Select all" />
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<PathIcon Height="13" Foreground="{DynamicResource AcrylicTrimForeground}" Data="{StaticResource select_all}" />
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</ControlTheme>

<ControlTheme x:Key="FunctionButton" TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
<Setter Property="BorderThickness" Value="0" />
<Setter Property="Padding" Value="{StaticResource FunctionButtonPadding}" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
using ReactiveUI;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Disposables;
using System.Reactive.Linq;
using System.Windows.Input;
using WalletWasabi.Blockchain.TransactionOutputs;
using WalletWasabi.Fluent.Models.Transactions;
using WalletWasabi.Fluent.Models.Wallets;
Expand All @@ -21,6 +23,8 @@ namespace WalletWasabi.Fluent.ViewModels.Wallets.Send;
NavigationTarget = NavigationTarget.DialogScreen)]
public partial class ManualControlDialogViewModel: DialogViewModelBase<IEnumerable<SmartCoin>>
{
[AutoNotify] private bool _hasSelection;

private readonly IWalletModel _walletModel;
private readonly Wallet _wallet;

Expand All @@ -44,15 +48,29 @@ private ManualControlDialogViewModel(IWalletModel walletModel, Wallet wallet)
.ToCollection()
.Select(c => c.Any() ? walletModel.AmountProvider.Create(c.TotalAmount()) : null);

ToggleSelectionCommand = ReactiveCommand.Create(() => SelectAll(!CoinList.Selection.Any()));

SetupCancel(true, true, true);
_walletModel = walletModel;
_wallet = wallet;
}

public CoinListViewModel CoinList { get; }

public ICommand ToggleSelectionCommand { get; }

public IObservable<Amount?> SelectedAmount { get; }

protected override void OnNavigatedTo(bool isInHistory, CompositeDisposable disposables)
{
CoinList.CoinItems
.ToObservableChangeSet()
.WhenPropertyChanged(x => x.IsSelected)
.Select(_ => CoinList.Selection.Count > 0)
.BindTo(this, x => x.HasSelection)
.DisposeWith(disposables);
}

protected override void OnNavigatedFrom(bool isInHistory)
{
if (!isInHistory)
Expand All @@ -69,4 +87,12 @@ private void OnNext()

Navigate().To().Send(_walletModel, sendParameters);
}

private void SelectAll(bool value)
{
foreach (var coin in CoinList.CoinItems)
{
coin.IsSelected = value;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@
</Flyout>
</Button.Flyout>
</Button>


<ToggleButton Theme="{StaticResource DialogSelectAllButton}"
Command="{Binding ToggleSelectionCommand}"
IsChecked="{Binding HasSelection}"/>
</StackPanel>

</ContentArea.TopContent>
Expand Down
27 changes: 3 additions & 24 deletions WalletWasabi.Fluent/Views/Wallets/Settings/ExcludedCoinsView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,9 @@
</Flyout>
</Button.Flyout>
</Button>
<ToggleButton Theme="{StaticResource DialogButton}" Command="{Binding ToggleSelectionCommand}" IsChecked="{Binding HasSelection}">
<ToggleButton.Styles>
<Style Selector="ToggleButton[IsChecked=True]">
<Setter Property="ToolTip.Tip" Value="Unselect all" />
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<PathIcon Height="13" Foreground="{DynamicResource AcrylicTrimForeground}" Data="{StaticResource select_none}" />
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
<Style Selector="ToggleButton[IsChecked=False]">
<Setter Property="ToolTip.Tip" Value="Select all" />
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<PathIcon Height="13" Foreground="{DynamicResource AcrylicTrimForeground}" Data="{StaticResource select_all}" />
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</ToggleButton.Styles>
</ToggleButton>
<ToggleButton Theme="{StaticResource DialogSelectAllButton}"
Command="{Binding ToggleSelectionCommand}"
IsChecked="{Binding HasSelection}"/>
</StackPanel>
</ContentArea.TopContent>
<coins:CoinListView DataContext="{Binding CoinList}" />
Expand Down

0 comments on commit ace312b

Please sign in to comment.