From b00df41716c328735b32b115bb8ccd91b0cc1302 Mon Sep 17 00:00:00 2001 From: BOT Alex <44818698+MagicBOTAlex@users.noreply.github.com> Date: Thu, 11 May 2023 01:28:34 +0200 Subject: [PATCH] Now allows the user to select a post --- Otakians/Pages/Index.razor | 29 ++++++++++++++++++++--------- Otakians/Shared/MainLayout.razor | 24 +++++++++--------------- 2 files changed, 29 insertions(+), 24 deletions(-) diff --git a/Otakians/Pages/Index.razor b/Otakians/Pages/Index.razor index 6219f7a..7598148 100644 --- a/Otakians/Pages/Index.razor +++ b/Otakians/Pages/Index.razor @@ -20,13 +20,15 @@ @for (int i = 0; i < 25; i++) { - + int postId = (LoadedImages.Count > i) ? LoadedImages[i] : GetRandomImageNumber(); + + - @("@" + RandomUsernames[random.Next(0, RandomUsernames.Length)]) + @("@" + RandomUsernames[postId]) - + @@ -51,7 +53,7 @@ private Random random = new Random(); const int numImages = 211; - string GetRandomImage() + int GetRandomImageNumber() { int selectedImage; reselect: @@ -60,21 +62,30 @@ goto reselect; 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) { - if (!firstRender) - { - LoadedImages.Clear(); - } + } + // TODO: Add a "save post" button to each post. + string[] RandomUsernames = new string[1000]; protected override async Task OnInitializedAsync() { RandomUsernames = (await Http.GetStringAsync("RandomUsernames.txt")).Split("\n"); } + + void ClickPost(int postImage) + { + Console.WriteLine(postImage); + } } \ No newline at end of file diff --git a/Otakians/Shared/MainLayout.razor b/Otakians/Shared/MainLayout.razor index 5e8ef43..0957e67 100644 --- a/Otakians/Shared/MainLayout.razor +++ b/Otakians/Shared/MainLayout.razor @@ -4,24 +4,20 @@ - @* - *@ Primary - - - + BT - + - Store + Posts Library Community - + Store Library @@ -37,15 +33,13 @@ @code { - bool openStart = false; - bool openEnd = false; + bool openContentDrawer = false; + bool openProfileDrawer = false; - void ToggleDrawer(Anchor anchor) + void ToggleDrawer() { - if (anchor == Anchor.Start) - openStart = !openStart; - if (anchor == Anchor.End) - openEnd = !openEnd; + Console.WriteLine("Open!"); + openProfileDrawer = !openProfileDrawer; } void getPos()