Refactor history table column creation into methods
MODIFY
WalletWasabi.Fluent/ViewModels/Wallets/Home/History/HistoryViewModel.cs
WalletWasabi.Fluent/ViewModels/Wallets/Home/History/HistoryViewModel.cs
@@ -68,8 +68,31 @@ public partial class HistoryViewModel : ActivatableViewModel
{
Columns =
{
- // Indicators
- new HierarchicalExpanderColumn<HistoryItemViewModelBase>(
+ IndicatorsColumn(),
+ DateColumn(),
+ LabelsColumn(),
+ IncomingColumn(),
+ OutgoingColumn(),
+ BalanceColumn(),
+ }
+ };
+
+ Source.RowSelection!.SingleSelect = true;
+
+ Source.RowSelection
+ .WhenAnyValue(x => x.SelectedItem)
+ .Subscribe(x => SelectedItem = x);
+ }
+
+ public ObservableCollection<HistoryItemViewModelBase> UnfilteredTransactions => _unfilteredTransactions;
+
+ public ObservableCollection<HistoryItemViewModelBase> Transactions => _transactions;
+
+ public HierarchicalTreeDataGridSource<HistoryItemViewModelBase> Source { get; }
+
+ private static IColumn<HistoryItemViewModelBase> IndicatorsColumn()
+ {
+ return new HierarchicalExpanderColumn<HistoryItemViewModelBase>(
new TemplateColumn<HistoryItemViewModelBase>(
null,
new FuncDataTemplate<HistoryItemViewModelBase>((node, ns) => new IndicatorsColumnView(), true),
@@ -84,10 +107,12 @@ public partial class HistoryViewModel : ActivatableViewModel
width: new GridLength(0, GridUnitType.Auto)),
x => x.Children,
x => x.HasChildren(),
- x => x.IsExpanded),
+ x => x.IsExpanded);
+ }
- // Date
- new PrivacyTextColumn<HistoryItemViewModelBase>(
+ private static IColumn<HistoryItemViewModelBase> DateColumn()
+ {
+ return new PrivacyTextColumn<HistoryItemViewModelBase>(
"Date / Time",
x => x.DateString,
options: new ColumnOptions<HistoryItemViewModelBase>
@@ -99,10 +124,12 @@ public partial class HistoryViewModel : ActivatableViewModel
MinWidth = new GridLength(150, GridUnitType.Pixel)
},
width: new GridLength(0, GridUnitType.Auto),
- numberOfPrivacyChars: 15),
+ numberOfPrivacyChars: 15);
+ }
- // Labels
- new TemplateColumn<HistoryItemViewModelBase>(
+ private static IColumn<HistoryItemViewModelBase> LabelsColumn()
+ {
+ return new TemplateColumn<HistoryItemViewModelBase>(
"Labels",
new FuncDataTemplate<HistoryItemViewModelBase>((node, ns) => new LabelsColumnView(), true),
options: new ColumnOptions<HistoryItemViewModelBase>
@@ -113,10 +140,12 @@ public partial class HistoryViewModel : ActivatableViewModel
CompareDescending = HistoryItemViewModelBase.SortDescending(x => x.Label),
MinWidth = new GridLength(100, GridUnitType.Pixel)
},
- width: new GridLength(1, GridUnitType.Star)),
+ width: new GridLength(1, GridUnitType.Star));
+ }
- // Incoming
- new PrivacyTextColumn<HistoryItemViewModelBase>(
+ private static IColumn<HistoryItemViewModelBase> IncomingColumn()
+ {
+ return new PrivacyTextColumn<HistoryItemViewModelBase>(
"Incoming (BTC)",
x => x.IncomingAmount?.ToFormattedString(),
options: new ColumnOptions<HistoryItemViewModelBase>
@@ -129,10 +158,12 @@ public partial class HistoryViewModel : ActivatableViewModel
MaxWidth = new GridLength(210, GridUnitType.Pixel)
},
width: new GridLength(0, GridUnitType.Auto),
- numberOfPrivacyChars: 9),
+ numberOfPrivacyChars: 9);
+ }
- // Outgoing
- new PrivacyTextColumn<HistoryItemViewModelBase>(
+ private static IColumn<HistoryItemViewModelBase> OutgoingColumn()
+ {
+ return new PrivacyTextColumn<HistoryItemViewModelBase>(
"Outgoing (BTC)",
x => x.OutgoingAmount?.ToFormattedString(),
options: new ColumnOptions<HistoryItemViewModelBase>
@@ -145,10 +176,12 @@ public partial class HistoryViewModel : ActivatableViewModel
MaxWidth = new GridLength(210, GridUnitType.Pixel)
},
width: new GridLength(0, GridUnitType.Auto),
- numberOfPrivacyChars: 9),
+ numberOfPrivacyChars: 9);
+ }
- // Balance
- new PrivacyTextColumn<HistoryItemViewModelBase>(
+ private static IColumn<HistoryItemViewModelBase> BalanceColumn()
+ {
+ return new PrivacyTextColumn<HistoryItemViewModelBase>(
"Balance (BTC)",
x => x.Balance?.ToFormattedString(),
options: new ColumnOptions<HistoryItemViewModelBase>
@@ -161,22 +194,8 @@ public partial class HistoryViewModel : ActivatableViewModel
MaxWidth = new GridLength(210, GridUnitType.Pixel)
},
width: new GridLength(0, GridUnitType.Auto),
- numberOfPrivacyChars: 9),
+ numberOfPrivacyChars: 9);
}
- };
-
- Source.RowSelection!.SingleSelect = true;
-
- Source.RowSelection
- .WhenAnyValue(x => x.SelectedItem)
- .Subscribe(x => SelectedItem = x);
- }
-
- public ObservableCollection<HistoryItemViewModelBase> UnfilteredTransactions => _unfilteredTransactions;
-
- public ObservableCollection<HistoryItemViewModelBase> Transactions => _transactions;
-
- public HierarchicalTreeDataGridSource<HistoryItemViewModelBase> Source { get; }
public void SelectTransaction(uint256 txid)
{

Refactor history table column creation into methods