-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathDropdownCustom.razor
91 lines (81 loc) · 3.48 KB
/
DropdownCustom.razor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
@using System.Globalization
@inject WalletStorage walletStorage;
<div>
<div class="atomex-input-container @(!string.IsNullOrEmpty(Description) ? "with-description" : "") @(Disabled ? "disabled" : "")">
@if (Description != null)
{
<div class="input-description light @(ForEth ? "for-eth-address" : "")">
<span>@Description</span>
</div>
}
<button class="custom-dropdown @(IsOpened ? "opened" : "")"
@onclick=@(() => IsOpened = !IsOpened)>
<div class="dropdown-custom-item">
<div class="dropdown-left-content">
@SelectedAddressObj.Address
</div>
<div class="dropdown-right-content">
<div>
@SelectedAddressObj.AvailableBalance.ToString(SelectedAddressObj.CurrencyFormat, CultureInfo.InvariantCulture)
<span> @SelectedAddressObj.CurrencyCode</span>
</div>
@if (SelectedAddressObj.ShowTokenBalance)
{
<div>
@SelectedAddressObj.TokenBalance.ToString(SelectedAddressObj.CurrencyFormat, CultureInfo.InvariantCulture)
<span> @SelectedAddressObj.TokenCode</span>
</div>
}
</div>
</div>
@if (IsOpened)
{
<div class="custom-dropdown-list__container">
@foreach (var address in Addresses)
{
<div class="dropdown-custom-item" @onclick="@(() => OnAddressChange.InvokeAsync(address.Address))">
<div class="dropdown-left-content">
@if (address.IsFreeAddress)
{
<span class="new-badge">(new) </span>
}
@address.Address
</div>
<div class="dropdown-right-content">
<div>
@address.AvailableBalance.ToString(address.CurrencyFormat, CultureInfo.InvariantCulture)
<span> @address.CurrencyCode</span>
</div>
@if (address.ShowTokenBalance)
{
<div>
@address.TokenBalance.ToString(address.CurrencyFormat, CultureInfo.InvariantCulture)
<span> @address.TokenCode</span>
</div>
}
</div>
</div>
}
</div>
}
</button>
</div>
</div>
@code
{
[Parameter]
public string Description { get; set; }
[Parameter]
public EventCallback<string> OnAddressChange { get; set; }
[Parameter]
public List<WalletAddressViewModel> Addresses { get; set; }
[Parameter]
public string SelectedAddress { get; set; }
[Parameter]
public bool Disabled { get; set; }
[Parameter]
public bool ForEth { get; set; }
private WalletAddressViewModel SelectedAddressObj => Addresses
.Find(a => a.Address == SelectedAddress);
private bool IsOpened { get; set; }
}