diff options
author | Rory& <root@rory.gay> | 2024-05-14 17:49:09 +0200 |
---|---|---|
committer | Rory& <root@rory.gay> | 2024-05-14 17:49:09 +0200 |
commit | 41c5a84dacfd036b8d8f01f72226ac5a519995e3 (patch) | |
tree | a4bfc76541692cbbb0fc18f34463cf31a57440f5 /MatrixUtils.Web/Pages/Labs/Rooms2/Index2.razor | |
parent | Improve the heatmap layout (diff) | |
download | MatrixUtils-41c5a84dacfd036b8d8f01f72226ac5a519995e3.tar.xz |
Organise tools somewhat, set proper icons for nav menu
Diffstat (limited to 'MatrixUtils.Web/Pages/Labs/Rooms2/Index2.razor')
-rw-r--r-- | MatrixUtils.Web/Pages/Labs/Rooms2/Index2.razor | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/MatrixUtils.Web/Pages/Labs/Rooms2/Index2.razor b/MatrixUtils.Web/Pages/Labs/Rooms2/Index2.razor new file mode 100644 index 0000000..3392960 --- /dev/null +++ b/MatrixUtils.Web/Pages/Labs/Rooms2/Index2.razor @@ -0,0 +1,87 @@ +@page "/Labs/Rooms2" +@using LibMatrix.Responses +@using System.Collections.ObjectModel +@using System.ComponentModel +@using MatrixUtils.Abstractions +@using MatrixUtils.Web.Pages.Labs.Rooms2.Index2Components +@inject ILogger<Index> logger +<h3>Room list</h3> + +<RoomsIndex2SyncContainer Data="@Data"></RoomsIndex2SyncContainer> +@if (Data.Homeserver is null || Data.GlobalProfile is null) { + <p>Creating homeserver instance and fetching global profile...</p> + return; +} + +<div> + <LinkButton Color="@(SelectedTab == Tab.Main ? null : "#0b0e62")" OnClick="() => Task.FromResult(SelectedTab = Tab.Main)">Main</LinkButton> + <LinkButton Color="@(SelectedTab == Tab.DMs ? null : "#0b0e62")" OnClick="() => Task.FromResult(SelectedTab = Tab.DMs)">DMs</LinkButton> + <LinkButton Color="@(SelectedTab == Tab.ByRoomType ? null : "#0b0e62")" OnClick="() => Task.FromResult(SelectedTab = Tab.ByRoomType)">By room type</LinkButton> +</div> +<br/> +<CascadingValue Value="@Data"> + @switch (SelectedTab) { + case Tab.Main: + <h3>Main tab</h3> + <RoomsIndex2MainTab></RoomsIndex2MainTab> + break; + case Tab.DMs: + <h3>DMs tab</h3> + <RoomsIndex2DMsTab></RoomsIndex2DMsTab> + break; + case Tab.ByRoomType: + <h3>By room type tab</h3> + <RoomsIndex2ByRoomTypeTab></RoomsIndex2ByRoomTypeTab> + break; + default: + throw new InvalidEnumArgumentException(); + } +</CascadingValue> +<br/> + +@* <LinkButton href="/Rooms/Create">Create new room</LinkButton> *@ + + +@code { + + private Tab SelectedTab { + get => _selectedTab; + set { + _selectedTab = value; + StateHasChanged(); + } + } + + public RoomListViewData Data { get; set; } = new RoomListViewData(); + + protected override async Task OnInitializedAsync() { + Data.Homeserver = await RMUStorage.GetCurrentSessionOrNavigate(); + if (Data.Homeserver is null) return; + var rooms = await Data.Homeserver.GetJoinedRooms(); + Data.GlobalProfile = await Data.Homeserver.GetProfileAsync(Data.Homeserver.WhoAmI.UserId); + + foreach (var room in rooms) { + Data.Rooms.Add(new RoomInfo(room)); + } + StateHasChanged(); + + await base.OnInitializedAsync(); + } + + private Tab _selectedTab = Tab.Main; + + private enum Tab { + Main, + DMs, + ByRoomType + } + + public class RoomListViewData { + public ObservableCollection<RoomInfo> Rooms { get; } = []; + + public UserProfileResponse? GlobalProfile { get; set; } + + public AuthenticatedHomeserverGeneric? Homeserver { get; set; } + } + +} \ No newline at end of file |