This commit is contained in:
BOT Alex 2023-05-11 10:11:48 +02:00
commit 607394c99a
2 changed files with 29 additions and 24 deletions

View File

@ -20,13 +20,15 @@
<MudGrid Spacing="6" Justify="Justify.Center"> <MudGrid Spacing="6" Justify="Justify.Center">
@for (int i = 0; i < 100; i++) @for (int i = 0; i < 100; i++)
{ {
<MudItem> int postId = (LoadedImages.Count > i) ? LoadedImages[i] : GetRandomImageNumber();
<MudPaper Class="md-8 rounded-lg" Style="position:relative">
<MudItem @onclick="() => ClickPost(postId)">
<MudPaper Class="md-8" Style="position:relative">
<MudContainer Style="position:absolute;" Class="mt-4"> <MudContainer Style="position:absolute;" Class="mt-4">
<MudText Style="background-color:rgba(0, 0, 0, 0.6); backdrop-filter:blur(2px)" Class="pl-2 rounded-t-lg py-2" Color="Color.Surface" Typo="Typo.h6">@("@" + RandomUsernames[random.Next(0, RandomUsernames.Length)])</MudText> <MudText Style="background-color:rgba(0, 0, 0, 0.55); backdrop-filter:blur(2px)" Class="pl-2 rounded-t-lg" Color="Color.Secondary" Typo="Typo.h6">@("@" + RandomUsernames[postId])</MudText>
</MudContainer> </MudContainer>
<MudContainer> <MudContainer>
<MudImage Class="rounded-lg my-4" Src="@GetRandomImage()" Height="250" Width="250"></MudImage> <MudImage Class="rounded-lg my-4" Src="@GetImage(postId)" Height="250" Width="250"></MudImage>
</MudContainer> </MudContainer>
</MudPaper> </MudPaper>
</MudItem> </MudItem>
@ -51,7 +53,7 @@
private Random random = new Random(); private Random random = new Random();
const int numImages = 211; const int numImages = 211;
string GetRandomImage() int GetRandomImageNumber()
{ {
int selectedImage; int selectedImage;
reselect: reselect:
@ -60,21 +62,30 @@
goto reselect; goto reselect;
LoadedImages.Add(selectedImage); LoadedImages.Add(selectedImage);
return $@"\images\AnimeImages\AnimeImage ({selectedImage}).jpeg"; return selectedImage;
}
string GetImage(int imageIndex)
{
return $@"\images\AnimeImages\AnimeImage ({imageIndex}).jpeg";
} }
protected override void OnAfterRender(bool firstRender) protected override void OnAfterRender(bool firstRender)
{ {
if (!firstRender)
{
LoadedImages.Clear();
}
} }
// TODO: Add a "save post" button to each post.
string[] RandomUsernames = new string[1000]; string[] RandomUsernames = new string[1000];
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
RandomUsernames = (await Http.GetStringAsync("RandomUsernames.txt")).Split("\n"); RandomUsernames = (await Http.GetStringAsync("RandomUsernames.txt")).Split("\n");
} }
void ClickPost(int postImage)
{
Console.WriteLine(postImage);
}
} }

View File

@ -4,16 +4,12 @@
<MudLayout Class="overflow-hidden"> <MudLayout Class="overflow-hidden">
<MudAppBar Elevation="1"> <MudAppBar Elevation="1">
@* <MudIconButton Icon="@Icons.Material.Filled.Menu" Color="Color.Inherit" Edge="Edge.Start" OnClick="@((e) => ToggleDrawer())" />
*@
<MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="AddUser">Primary</MudButton> <MudButton Variant="Variant.Filled" Color="Color.Primary" OnClick="AddUser">Primary</MudButton>
<MudSpacer /> <MudSpacer />
<MudAvatar Class="mr-n2"> <MudAvatar Style="cursor:pointer" @onclick="ToggleDrawer" Variant="Variant.Outlined" Color="Color.Success" Class="mr-n2">BT</MudAvatar>
<MudImage Src="images/BOTAlex.png"></MudImage>
</MudAvatar>
</MudAppBar> </MudAppBar>
<MudDrawer @bind-Open="@openStart" ClipMode="DrawerClipMode.Always" Breakpoint="Breakpoint.Lg" PreserveOpenState="false" Elevation="1" Variant="@DrawerVariant.Mini" OpenMiniOnHover="true"> <MudDrawer @bind-Open="@openContentDrawer" ClipMode="DrawerClipMode.Always" Breakpoint="Breakpoint.Lg" PreserveOpenState="false" Elevation="1" Variant="@DrawerVariant.Mini" OpenMiniOnHover="true">
<MudNavMenu> <MudNavMenu>
<MudNavLink Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.Image">Posts</MudNavLink> <MudNavLink Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.Image">Posts</MudNavLink>
<MudNavLink Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.LibraryBooks">Library</MudNavLink> <MudNavLink Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.LibraryBooks">Library</MudNavLink>
@ -21,7 +17,7 @@
</MudNavMenu> </MudNavMenu>
</MudDrawer> </MudDrawer>
<MudDrawer Anchor="Anchor.End" @bind-Open="@openEnd" ClipMode="DrawerClipMode.Always" Breakpoint="Breakpoint.Lg" PreserveOpenState="false" Elevation="1" Variant="@DrawerVariant.Mini" OpenMiniOnHover="true"> <MudDrawer Anchor="Anchor.End" @bind-Open="@openProfileDrawer" ClipMode="DrawerClipMode.Always" Breakpoint="Breakpoint.Lg" PreserveOpenState="true" Elevation="1" Variant="@DrawerVariant.Temporary">
<MudNavMenu> <MudNavMenu>
<MudNavLink Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.Store">Store</MudNavLink> <MudNavLink Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.Store">Store</MudNavLink>
<MudNavLink Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.LibraryBooks">Library</MudNavLink> <MudNavLink Match="NavLinkMatch.All" Icon="@Icons.Material.Filled.LibraryBooks">Library</MudNavLink>
@ -37,15 +33,13 @@
@code { @code {
bool openStart = false; bool openContentDrawer = false;
bool openEnd = false; bool openProfileDrawer = false;
void ToggleDrawer(Anchor anchor) void ToggleDrawer()
{ {
if (anchor == Anchor.Start) Console.WriteLine("Open!");
openStart = !openStart; openProfileDrawer = !openProfileDrawer;
if (anchor == Anchor.End)
openEnd = !openEnd;
} }
void getPos() void getPos()