wabbajack/Wabbajack.App.Blazor/Pages/Gallery.razor
2022-01-11 14:00:23 +11:00

47 lines
1.1 KiB
Plaintext

@page "/gallery"
@layout Shared.MainLayout
@using Wabbajack.Networking.WabbajackClientApi;
@using System.Linq;
@using Wabbajack.DTOs
@inject Client _client
<div id="content">
@foreach (ModListItem item in listItems)
{
<ModListItem ImageURL=@item.ImageURL Title=@item.Title Description=@item.Description></ModListItem>
}
</div>
@code {
List<ModListItem> listItems = new();
private class ModListItem
{
public readonly string Title;
public readonly string Description;
public readonly string ImageURL;
public ModListItem(string title, string description, string imageUrl)
{
Description = description;
ImageURL = imageUrl;
Title = title;
}
}
protected override async Task OnInitializedAsync()
{
try
{
ModlistMetadata[] modLists = await _client.LoadLists();
listItems = modLists.Select(x => new ModListItem(x.Title, x.Description, x.Links.ImageUri)).ToList();
StateHasChanged();
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
}