Skip to content

Commit

Permalink
SelectedAmount
Browse files Browse the repository at this point in the history
  • Loading branch information
ichthus1604 committed Apr 20, 2024
1 parent efbdd50 commit 3d0c0ec
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 4 deletions.
6 changes: 4 additions & 2 deletions WalletWasabi.Fluent/Controls/AmountControl.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

<Setter Property="Template">
<ControlTemplate>
<TextBlock DataContext="{Binding Path=Amount, RelativeSource={RelativeSource TemplatedParent}}" Classes="monoSpaced" TextWrapping="Wrap">
<TextBlock DataContext="{Binding Path=Amount, RelativeSource={RelativeSource TemplatedParent}}" Classes="monoSpaced" TextWrapping="Wrap"
IsVisible="{Binding Path=Amount, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static ObjectConverters.IsNotNull}}">
<TextBlock.Text>
<MultiBinding StringFormat="{}{0} {1}">
<Binding Path="Btc" Converter="{x:Static converters:MoneyConverters.ToBtc}" />
Expand All @@ -20,7 +21,8 @@
<Style Selector="^.Fee">
<Setter Property="Template">
<ControlTemplate>
<TextBlock DataContext="{Binding Path=Amount, RelativeSource={RelativeSource TemplatedParent}}" Classes="monoSpaced" TextWrapping="Wrap">
<TextBlock DataContext="{Binding Path=Amount, RelativeSource={RelativeSource TemplatedParent}}" Classes="monoSpaced" TextWrapping="Wrap"
IsVisible="{Binding Path=Amount, RelativeSource={RelativeSource TemplatedParent}, Converter={x:Static ObjectConverters.IsNotNull}}">
<TextBlock.Text>
<MultiBinding StringFormat="{}{0} {1}">
<Binding Path="Btc" Converter="{x:Static converters:MoneyConverters.ToFeeWithUnit}" />
Expand Down
4 changes: 2 additions & 2 deletions WalletWasabi.Fluent/Controls/AmountControl.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ namespace WalletWasabi.Fluent.Controls;

public class AmountControl : TemplatedControl
{
public static readonly StyledProperty<Amount> AmountProperty = AvaloniaProperty.Register<AmountControl, Amount>(nameof(Amount));
public static readonly StyledProperty<Amount?> AmountProperty = AvaloniaProperty.Register<AmountControl, Amount?>(nameof(Amount));

public Amount Amount
public Amount? Amount
{
get => GetValue(AmountProperty);
set => SetValue(AmountProperty, value);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
using Avalonia.Data.Converters;
using DynamicData;
using DynamicData.Binding;
using ReactiveUI;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Linq;
using WalletWasabi.Blockchain.TransactionOutputs;
using WalletWasabi.Fluent.Converters;
using WalletWasabi.Fluent.Models.Transactions;
using WalletWasabi.Fluent.Models.Wallets;
using WalletWasabi.Fluent.ViewModels.Dialogs.Base;
Expand Down Expand Up @@ -38,13 +40,21 @@ private ManualControlDialogViewModel(IWalletModel walletModel, Wallet wallet)

NextCommand = ReactiveCommand.Create(OnNext, nextCommandCanExecute);

SelectedAmount =
CoinList.Selection
.ToObservableChangeSet()
.ToCollection()
.Select(c => c.Any() ? walletModel.AmountProvider.Create(c.TotalAmount()) : null);

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

public CoinListViewModel CoinList { get; }

public IObservable<Amount?> SelectedAmount { get; }

protected override void OnNavigatedFrom(bool isInHistory)
{
CoinList.Dispose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@
</Button.Flyout>
</Button>
</ContentArea.TopContent>
<ContentArea.BottomContent>
<!-- Selected Amount -->
<AmountControl Amount="{Binding SelectedAmount^}"/>
</ContentArea.BottomContent>
<coins:CoinListView DataContext="{Binding CoinList}" />
</ContentArea>
</UserControl>

0 comments on commit 3d0c0ec

Please sign in to comment.