Skip to content
Permalink
Browse files

[WIP] Show coin status in CoinList

  • Loading branch information...
molnard committed Nov 16, 2018
1 parent 91914ee commit c6e197596715a0f3eb6303819f5f5132862589c6
@@ -4,6 +4,8 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<UserControl.Resources>
<converters:PrivacyLevelValueConverter x:Key="PrivacyLevelValueConverter" />
<converters:CoinStatusStringConverter x:Key="CoinStatusStringConverter" />
<converters:CoinStatusColorConverter x:Key="CoinStatusColorConverter" />
</UserControl.Resources>
<UserControl.Styles>
<Style Selector="TextBlock">
@@ -24,12 +26,13 @@
</UserControl.Styles>

<DockPanel LastChildFill="True">
<Grid ColumnDefinitions="30,30,100,100,Auto" Margin="35 0" DockPanel.Dock="Top">
<Grid ColumnDefinitions="30,30,100,100,100,Auto" Margin="35 0" DockPanel.Dock="Top">
<TextBlock Text="" />
<TextBlock Text="" Grid.Column="1" />
<TextBlock Text="Amount (BTC)" Grid.Column="2" />
<TextBlock Text="Privacy" Grid.Column="3" Margin="20 0 0 0" />
<TextBlock Text="History" Grid.Column="4" />
<TextBlock Text="Status" Grid.Column="4" />
<TextBlock Text="History" Grid.Column="5" />
</Grid>
<ListBox Items="{Binding Coins}" VirtualizationMode="None">
<ListBox.ItemTemplate>
@@ -58,7 +61,7 @@
</Grid>
</StackPanel>
</Expander>
<Grid ColumnDefinitions="30,30,100,100,Auto" Margin="30 0 0 0" VerticalAlignment="Top">
<Grid ColumnDefinitions="30,30,100,100,100,Auto" Margin="30 0 0 0" VerticalAlignment="Top">
<CheckBox HorizontalContentAlignment="Left" IsChecked="{Binding IsSelected}" />
<Path HorizontalAlignment="Left" Grid.Column="1" Data="F1 M 23.7501,33.25L 34.8334,44.3333L 52.2499,22.1668L 56.9999,26.9168L 34.8334,53.8333L 19.0001,38L 23.7501,33.25 Z" Fill="#22B14C" Height="16" Width="16" IsVisible="{Binding Confirmed}" Stretch="Fill">
<ToolTip.Tip>
@@ -71,8 +74,9 @@
ToolTip.Tip="{Binding ToolTip}">
<DrawingPresenter Drawing="{Binding Icon}" Margin="0 0 25 0" />
</Panel>
<controls:ExtendedTextBox Classes="selectableTextBlock" Grid.Column="4" Text="{Binding History}" />
<TextBlock Text="" Grid.Column="5" />
<controls:ExtendedTextBox Classes="selectableTextBlock" Grid.Column="4" Text="{Binding Status, Converter={StaticResource CoinStatusStringConverter}}" Background="{Binding Status, Converter={StaticResource CoinStatusColorConverter}}"/>
<controls:ExtendedTextBox Classes="selectableTextBlock" Grid.Column="5" Text="{Binding History}" />
<TextBlock Text="" Grid.Column="6" />
</Grid>
</Grid>
</DataTemplate>
@@ -10,9 +10,14 @@

namespace WalletWasabi.Gui.Controls.WalletExplorer
{
public enum CoinStatusEnum
{
None,
}
public class CoinViewModel : ViewModelBase
{
private bool _isSelected;
private CoinStatusEnum _status;

public CoinViewModel(SmartCoin model)
{
@@ -76,5 +81,13 @@ public bool IsSelected
public string InCoinJoin => Model.CoinJoinInProgress ? "Yes" : "No";

public string History => string.Join(", ", Global.WalletService.GetHistory(Model, Enumerable.Empty<SmartCoin>()).Select(x => x.Label).Distinct());

public CoinStatusEnum Status
{
get => _status;
set { this.RaiseAndSetIfChanged(ref _status, value); }
}


}
}
@@ -0,0 +1,34 @@
using Avalonia.Data.Converters;
using Avalonia.Media;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using WalletWasabi.Gui.Controls.WalletExplorer;
using WalletWasabi.Models.ChaumianCoinJoin;

namespace WalletWasabi.Gui.Converters
{
public class CoinStatusColorConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is CoinStatusEnum status)
{
switch (status)
{
case CoinStatusEnum.None:
return Brushes.Black;
default:
return Brushes.Transparent;
}
}
throw new InvalidOperationException();
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new InvalidOperationException();
}
}
}
@@ -0,0 +1,29 @@
using Avalonia.Data.Converters;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;
using WalletWasabi.Gui.Controls.WalletExplorer;
using WalletWasabi.Models.ChaumianCoinJoin;

namespace WalletWasabi.Gui.Converters
{
public class CoinStatusStringConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is CoinStatusEnum status)
{
return status.ToString();
}

throw new InvalidOperationException();
}

public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
var s = value.ToString();
return Enum.Parse<CoinStatusEnum>(s);
}
}
}

0 comments on commit c6e1975

Please sign in to comment.
You can’t perform that action at this time.