diff options
Diffstat (limited to 'MatrixUtils.Web/Pages/Rooms')
3 files changed, 89 insertions, 44 deletions
diff --git a/MatrixUtils.Web/Pages/Rooms/Index2Components/MainTabComponents/MainTabSpaceItem.razor b/MatrixUtils.Web/Pages/Rooms/Index2Components/MainTabComponents/MainTabSpaceItem.razor index 4216824..7a3b27b 100644 --- a/MatrixUtils.Web/Pages/Rooms/Index2Components/MainTabComponents/MainTabSpaceItem.razor +++ b/MatrixUtils.Web/Pages/Rooms/Index2Components/MainTabComponents/MainTabSpaceItem.razor @@ -1,17 +1,34 @@ @using MatrixUtils.Abstractions -<div class="spaceListItem" onclick="@ToggleSpace"> +<div class="spaceListItem" style="@(SelectedSpace == Space ? "background-color: #FFFFFF33;" : "")" onclick="@SelectSpace"> + @if (IsSpaceOpened()) { + <span onclick="@ToggleSpace">▼ </span> + } + else { + <span onclick="@ToggleSpace">▶ </span> + } + <MxcImage Circular="true" Height="32" Width="32" Homeserver="Space.Room.Homeserver" MxcUri="@Space.RoomIcon"></MxcImage> <span class="spaceNameEllipsis">@Space.RoomName</span> + + @if (IsSpaceOpened()) { + <span>meow</span> + } </div> @code { [Parameter] public RoomInfo Space { get; set; } + + [Parameter] + public RoomInfo SelectedSpace { get; set; } + + [Parameter] + public EventCallback<RoomInfo> SelectedSpaceChanged { get; set; } [Parameter] public List<RoomInfo> OpenedSpaces { get; set; } - + protected override Task OnInitializedAsync() { Space.PropertyChanged += (sender, args) => { StateHasChanged(); }; return base.OnInitializedAsync(); @@ -20,8 +37,20 @@ public void ToggleSpace() { if (OpenedSpaces.Contains(Space)) { OpenedSpaces.Remove(Space); - } else { + } + else { OpenedSpaces.Add(Space); } } -} \ No newline at end of file + + public void SelectSpace() { + SelectedSpace = Space; + SelectedSpaceChanged.InvokeAsync(Space); + } + + public bool IsSpaceOpened() { + return OpenedSpaces.Contains(Space); + } + +} + diff --git a/MatrixUtils.Web/Pages/Rooms/Index2Components/MainTabComponents/MainTabSpaceItem.razor.css b/MatrixUtils.Web/Pages/Rooms/Index2Components/MainTabComponents/MainTabSpaceItem.razor.css index c174567..a88975b 100644 --- a/MatrixUtils.Web/Pages/Rooms/Index2Components/MainTabComponents/MainTabSpaceItem.razor.css +++ b/MatrixUtils.Web/Pages/Rooms/Index2Components/MainTabComponents/MainTabSpaceItem.razor.css @@ -5,11 +5,15 @@ text-overflow: ellipsis; white-space: nowrap; vertical-align: middle; - width: calc(100% - 38px); + width: calc(100% - 64px); } .spaceListItem { display: block; width: 100%; height: 50px; +} + +.spaceListItem > img { + display: inline-block; } \ No newline at end of file diff --git a/MatrixUtils.Web/Pages/Rooms/Index2Components/RoomsIndex2MainTab.razor b/MatrixUtils.Web/Pages/Rooms/Index2Components/RoomsIndex2MainTab.razor index 2b7c5ac..b163a52 100644 --- a/MatrixUtils.Web/Pages/Rooms/Index2Components/RoomsIndex2MainTab.razor +++ b/MatrixUtils.Web/Pages/Rooms/Index2Components/RoomsIndex2MainTab.razor @@ -31,11 +31,17 @@ <div class="col-3" style="background-color: #ffffff22;"> <LinkButton>Uncategorised rooms</LinkButton> @foreach (var space in GetTopLevelSpaces()) { - @RecursingSpaceChildren(space) + @* @RecursingSpaceChildren(space) *@ + <MainTabSpaceItem Space="space" OpenedSpaces="OpenedSpaces" @bind-SelectedSpace="SelectedSpace" /> } </div> <div class="col-9" style="background-color: #ff00ff66;"> <p>Placeholder for rooms list...</p> + @if (SelectedSpace != null) { + foreach (var room in GetSpaceChildRooms(SelectedSpace)) { + <p>@room.RoomName</p> + } + } </div> </div> </div> @@ -116,48 +122,54 @@ var childSpaces = children.Where(x => x.RoomType == "m.space").ToList(); return childSpaces; } + + private List<RoomInfo> GetSpaceChildRooms(RoomInfo space) { + var children = GetSpaceChildren(space); + var childRooms = children.Where(x => x.RoomType != "m.space").ToList(); + return childRooms; + } private RoomInfo? SelectedSpace { get; set; } private List<RoomInfo> OpenedSpaces { get; set; } = new List<RoomInfo>(); - private RenderFragment RecursingSpaceChildren(RoomInfo space, List<RoomInfo>? parents = null, int depth = 0) { - parents ??= []; - var totalSw = Stopwatch.StartNew(); - var children = GetSpaceChildSpaces(space); - - var randomColor = RandomNumberGenerator.GetBytes(3).Append((byte)0x33).ToArray().AsHexString().Replace(" ", ""); - var isExpanded = OpenedSpaces.Contains(space); - - // Console.WriteLine($"RecursingSpaceChildren::FetchData - Depth: {depth}, Space: {space.RoomName}, Children: {children.Count} - {totalSw.Elapsed}"); - - // var renderSw = Stopwatch.StartNew(); - var rf = new RenderFragment(builder => { - builder.OpenElement(0, "div"); - //space list entry render fragment - // builder.AddContent(1, SpaceListEntry(space)); - builder.OpenComponent<MainTabSpaceItem>(1); - builder.AddAttribute(2, "Space", space); - builder.AddAttribute(2, "OpenedSpaces", OpenedSpaces); - builder.CloseComponent(); - builder.CloseElement(); - //space children render fragment - if (isExpanded) { - builder.OpenElement(2, "div"); - builder.AddAttribute(3, "style", "padding-left: 10px;"); - foreach (var child in children) { - builder.AddContent(4, RecursingSpaceChildren(child, parents.Append(space).ToList(), depth + 1)); - } - - builder.CloseElement(); - } - }); - - // Console.WriteLine($"RecursingSpaceChildren::Render - Depth: {depth}, Space: {space.RoomName}, Children: {children.Count} - {renderSw.Elapsed}"); - if (totalSw.ElapsedMilliseconds > 20) - Console.WriteLine($"RecursingSpaceChildren::Total - Depth: {depth}, Space: {space.RoomName}, Children: {children.Count} - {totalSw.Elapsed}"); - // Console.WriteLine($"RecursingSpaceChildren::Total - Depth: {depth}, Space: {space.RoomName}, Children: {children.Count} - {totalSw.Elapsed}"); - return rf; - } + // private RenderFragment RecursingSpaceChildren(RoomInfo space, List<RoomInfo>? parents = null, int depth = 0) { + // parents ??= []; + // var totalSw = Stopwatch.StartNew(); + // var children = GetSpaceChildSpaces(space); + // + // var randomColor = RandomNumberGenerator.GetBytes(3).Append((byte)0x33).ToArray().AsHexString().Replace(" ", ""); + // var isExpanded = OpenedSpaces.Contains(space); + // + // // Console.WriteLine($"RecursingSpaceChildren::FetchData - Depth: {depth}, Space: {space.RoomName}, Children: {children.Count} - {totalSw.Elapsed}"); + // + // // var renderSw = Stopwatch.StartNew(); + // var rf = new RenderFragment(builder => { + // builder.OpenElement(0, "div"); + // //space list entry render fragment + // // builder.AddContent(1, SpaceListEntry(space)); + // builder.OpenComponent<MainTabSpaceItem>(1); + // builder.AddAttribute(2, "Space", space); + // builder.AddAttribute(2, "OpenedSpaces", OpenedSpaces); + // builder.CloseComponent(); + // builder.CloseElement(); + // //space children render fragment + // if (isExpanded) { + // builder.OpenElement(2, "div"); + // builder.AddAttribute(3, "style", "padding-left: 10px;"); + // foreach (var child in children) { + // builder.AddContent(4, RecursingSpaceChildren(child, parents.Append(space).ToList(), depth + 1)); + // } + // + // builder.CloseElement(); + // } + // }); + // + // // Console.WriteLine($"RecursingSpaceChildren::Render - Depth: {depth}, Space: {space.RoomName}, Children: {children.Count} - {renderSw.Elapsed}"); + // if (totalSw.ElapsedMilliseconds > 20) + // Console.WriteLine($"RecursingSpaceChildren::Total - Depth: {depth}, Space: {space.RoomName}, Children: {children.Count} - {totalSw.Elapsed}"); + // // Console.WriteLine($"RecursingSpaceChildren::Total - Depth: {depth}, Space: {space.RoomName}, Children: {children.Count} - {totalSw.Elapsed}"); + // return rf; + // } // private RenderFragment SpaceListEntry(RoomInfo space) { // return builder => { |