about summary refs log tree commit diff
path: root/MatrixUtils.Web/Pages/Rooms/Index2Components/MainTabComponents/MainTabSpaceItem.razor
blob: 7a3b27b840a7546cbd1a0091664dd3ca41e7367e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
@using MatrixUtils.Abstractions
<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();
    }

    public void ToggleSpace() {
        if (OpenedSpaces.Contains(Space)) {
            OpenedSpaces.Remove(Space);
        }
        else {
            OpenedSpaces.Add(Space);
        }
    }

    public void SelectSpace() {
        SelectedSpace = Space;
        SelectedSpaceChanged.InvokeAsync(Space);
    }

    public bool IsSpaceOpened() {
        return OpenedSpaces.Contains(Space);
    }

}