Skip to content

Commit

Permalink
Created TransactionComponent.razor
Browse files Browse the repository at this point in the history
  • Loading branch information
michielpost committed Mar 28, 2024
1 parent 88c2a64 commit bdb0f81
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 109 deletions.
52 changes: 1 addition & 51 deletions src/aoWebWallet/Pages/TokenDetail.razor
Original file line number Diff line number Diff line change
Expand Up @@ -44,57 +44,7 @@
<MudTimeline TimelinePosition="TimelinePosition.Left">
@foreach (var transfer in BindingContext.TokenTransferList.Data)
{
var tokenData = BindingContext.TokenList.Data?.Where(x => x.TokenId == transfer.TokenId).Select(x => x.TokenData).FirstOrDefault();
if (tokenData == null)
{
continue;
}
string txUrl = $"transaction/{transfer.Id}";
<MudTimelineItem>
<ItemDot>
<MudAvatar Image="@UrlHelper.GetArweaveUrl(tokenData.Logo)" Size="Size.Medium" title="@tokenData.TokenId" />
</ItemDot>
<ItemContent>
@if(transfer.BlockHeight.HasValue)
{
<MudText Typo="Typo.caption">@transfer.Timestamp.ToString("s")</MudText>
}
else
{
<MudText Typo="Typo.caption">unconfirmed</MudText>
}
@*<MudText Typo="Typo.body1">@tokenData.Name</MudText>*@
<MudText style="font-weight:500;" Typo="Typo.body2">@tokenData.Ticker</MudText>

<MudStack Row=true>
<MudText>txId: </MudText>
<MudLink Class="KodeMono" style="text-overflow: ellipsis; white-space: nowrap;overflow: hidden;" Href="@txUrl" Typo="Typo.body1">
@transfer.Id
</MudLink>
</MudStack>

@{
string detailUrlFrom = $"wallet/{transfer.From}";
string detailUrlTo = $"wallet/{transfer.To}";
}

<MudLink Class="KodeMono" style="text-overflow: ellipsis; white-space: nowrap;overflow: hidden;" Href="@detailUrlFrom" Typo="Typo.h6">
@transfer.From
</MudLink>
<br/>
<MudIcon style="width:15px;" Icon="@Icons.Material.Filled.South" aria-label="Receive"></MudIcon>
<br/>

<MudLink Class="KodeMono" style="text-overflow: ellipsis; white-space: nowrap;overflow: hidden;" Href="@detailUrlTo" Typo="Typo.h6">
@transfer.To
</MudLink>

@if (tokenData != null)
{
<MudText Typo="Typo.h4">@BalanceHelper.FormatBalance(transfer.Quantity, tokenData.Denomination ?? 0)</MudText>
}
</ItemContent>
</MudTimelineItem>
<TransactionComponent transfer="transfer" />
}
</MudTimeline>
}
Expand Down
59 changes: 1 addition & 58 deletions src/aoWebWallet/Pages/WalletDetail.razor
Original file line number Diff line number Diff line change
Expand Up @@ -147,64 +147,7 @@
<MudTimeline TimelinePosition="TimelinePosition.Left">
@foreach (var transfer in BindingContext.TokenTransferList.Data)
{
var tokenData = BindingContext.TokenList.Data?.Where(x => x.TokenId == transfer.TokenId).Select(x => x.TokenData).FirstOrDefault();
var isSend = BindingContext.SelectedAddress == transfer.From;
var isReceive = BindingContext.SelectedAddress == transfer.To;
if (tokenData == null)
{
continue;
}
string txUrl = $"transaction/{transfer.Id}";
<MudTimelineItem>
<ItemDot>
<MudAvatar Image="@UrlHelper.GetArweaveUrl(tokenData.Logo)" Size="Size.Medium" title="@tokenData.TokenId" />
</ItemDot>
<ItemContent>
@if (transfer.BlockHeight.HasValue)
{
<MudText Typo="Typo.caption">@transfer.Timestamp.ToString("s")</MudText>
}
else
{
<MudText Typo="Typo.caption">unconfirmed</MudText>
}
@*<MudText Typo="Typo.body1">@tokenData.Name</MudText>*@
<MudText style="font-weight:500;" Typo="Typo.body2">@tokenData.Ticker</MudText>
<MudStack Row=true>
<MudText>txId: </MudText>
<MudLink Class="KodeMono" style="text-overflow: ellipsis; white-space: nowrap;overflow: hidden;" Href="@txUrl" Typo="Typo.body1">
@transfer.Id
</MudLink>
</MudStack>


@if (isSend)
{
<MudText Typo="Typo.h6" style="color:red">- @BalanceHelper.FormatBalance(transfer.Quantity, tokenData.Denomination ?? 0)</MudText>
}
else
{
<MudText Typo="Typo.h6" style="color:green">+ @BalanceHelper.FormatBalance(transfer.Quantity, tokenData.Denomination ?? 0)</MudText>
}

@if (isSend)
{
string detailUrl = $"wallet/{transfer.To}";
<MudIcon Icon="@Icons.Material.Filled.ArrowOutward" aria-label="Receive"></MudIcon>
<MudLink Class="KodeMono" style="text-overflow: ellipsis; white-space: nowrap;overflow: hidden;" Href="@detailUrl" Typo="Typo.h6">
@transfer.To
</MudLink>
}
else if (isReceive)
{
string detailUrl = $"wallet/{transfer.From}";
<MudIcon Icon="@Icons.Material.Filled.South" aria-label="Receive"></MudIcon>
<MudLink Class="KodeMono" style="text-overflow: ellipsis; white-space: nowrap;overflow: hidden;" Href="@detailUrl" Typo="Typo.h6">
@transfer.From
</MudLink>
}
</ItemContent>
</MudTimelineItem>
<TransactionComponent transfer="transfer" SelectedAddress="@BindingContext.SelectedAddress" />
}
</MudTimeline>

Expand Down
81 changes: 81 additions & 0 deletions src/aoWebWallet/Shared/Components/TransactionComponent.razor
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
@using aoWebWallet.Models
@inherits MvvmComponentBase<MainViewModel>

@if (transfer != null)
{
var tokenData = BindingContext.TokenList.Data?.Where(x => x.TokenId == transfer.TokenId).Select(x => x.TokenData).FirstOrDefault();
var isSend = SelectedAddress == transfer.From;
var isReceive = SelectedAddress == transfer.To;
string txUrl = $"transaction/{transfer.Id}";
<MudTimelineItem>
<ItemDot>
<MudAvatar Image="@UrlHelper.GetArweaveUrl(tokenData?.Logo)" Size="Size.Medium" title="@tokenData?.TokenId" />
</ItemDot>
<ItemContent>
@if (transfer.BlockHeight.HasValue)
{
<MudText Typo="Typo.caption">@transfer.Timestamp.ToString("s")</MudText>
}
else
{
<MudText Typo="Typo.caption">unconfirmed</MudText>
}
@*<MudText Typo="Typo.body1">@tokenData.Name</MudText>*@
<MudText style="font-weight:500;" Typo="Typo.body2">@tokenData?.Ticker</MudText>
<MudStack Row=true>
<MudText>txId: </MudText>
<MudLink Class="KodeMono" style="text-overflow: ellipsis; white-space: nowrap;overflow: hidden;" Href="@txUrl" Typo="Typo.body1">
@transfer.Id
</MudLink>
</MudStack>

@{
string detailUrlFrom = $"wallet/{transfer.From}";
string detailUrlTo = $"wallet/{transfer.To}";
}


@if (isSend)
{
<MudText Typo="Typo.h6" style="color:red">- @BalanceHelper.FormatBalance(transfer.Quantity, tokenData?.Denomination ?? 0)</MudText>
<MudIcon Icon="@Icons.Material.Filled.ArrowOutward" aria-label="Receive"></MudIcon>
<MudLink Class="KodeMono" style="text-overflow: ellipsis; white-space: nowrap;overflow: hidden;" Href="@detailUrlTo" Typo="Typo.h6">
@transfer.To
</MudLink>
}
else if(isReceive)
{
<MudText Typo="Typo.h6" style="color:green">+ @BalanceHelper.FormatBalance(transfer.Quantity, tokenData?.Denomination ?? 0)</MudText>
<MudIcon Icon="@Icons.Material.Filled.South" aria-label="Receive"></MudIcon>
<MudLink Class="KodeMono" style="text-overflow: ellipsis; white-space: nowrap;overflow: hidden;" Href="@detailUrlFrom" Typo="Typo.h6">
@transfer.From
</MudLink>
}
else
{
<MudLink Class="KodeMono" style="text-overflow: ellipsis; white-space: nowrap;overflow: hidden;" Href="@detailUrlFrom" Typo="Typo.h6">
@transfer.From
</MudLink>
<br />
<MudIcon style="width:15px;" Icon="@Icons.Material.Filled.South" aria-label="Receive"></MudIcon>
<br />

<MudLink Class="KodeMono" style="text-overflow: ellipsis; white-space: nowrap;overflow: hidden;" Href="@detailUrlTo" Typo="Typo.h6">
@transfer.To
</MudLink>

<MudText Typo="Typo.h4">@BalanceHelper.FormatBalance(transfer.Quantity, tokenData?.Denomination ?? 0)</MudText>
}
</ItemContent>
</MudTimelineItem>
}


@code {
[Parameter]
public TokenTransfer? transfer { get; set; }

[Parameter]
public string? SelectedAddress { get; set; }

}

0 comments on commit bdb0f81

Please sign in to comment.