Skip to content

Commit 8044a14

Browse files
committed
mobile chat is functional, a bit more work is needed to get it right
1 parent 6abc306 commit 8044a14

File tree

3 files changed

+35
-17
lines changed

3 files changed

+35
-17
lines changed

src/web/Client/Features/Chat/ChatSelector.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<MudItem Class="chat-selector-window" md="3" lg="3" xl="3" xxl="3">
1+
<MudItem Class="chat-selector-window" xs="12" sm="12" md="3" lg="3" xl="3" xxl="3">
22
<MudList Clickable>
33
<MudListSubheader>
44
<UserAutoComplete SelectedUserChanged="StartNewChat" />

src/web/Client/Features/Chat/LargeChatComponent.razor

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
@inject IProfileCache ProfileCache
44
@inject ISnackbar Snackbar
55
@inject IJSRuntime JsRuntime
6+
@inject IBrowserViewportService BrowserViewportService
67
@inject ChatSignalRClient ChatSignalRClient
78
@attribute [Authorize]
89

@@ -14,18 +15,35 @@
1415
<MudLoading @bind-Loading="_isLoading" Darken Overlap>
1516
<MudGrid Style="height: 600px">
1617

17-
<ChatSelector CurrentUser="_currentUser" Chats="_chats" SelectChatCallback="SelectChat" StartNewChatCallback="StartNewChat"/>
18+
@if ((_activeChat is null && _isMobile) || _isMobile is false)
19+
{
20+
<ChatSelector CurrentUser="_currentUser" Chats="_chats" SelectChatCallback="SelectChat" StartNewChatCallback="StartNewChat"/>
21+
}
1822

19-
<MudItem md="1" lg="1" xl="1" xxl="1">
20-
<MudDivider Vertical DividerType="DividerType.FullWidth"/>
21-
</MudItem>
23+
@if (_isMobile is false)
24+
{
25+
<MudItem md="1" lg="1" xl="1" xxl="1">
26+
<MudDivider Vertical DividerType="DividerType.FullWidth"/>
27+
</MudItem>
28+
}
29+
30+
@if (_activeChat is not null)
31+
{
32+
<MudItem Class="chat-message-window" xs="12" sm="12" md="8" lg="8" xl="8" xxl="8">
33+
@if (_isMobile)
34+
{
35+
@*something like a banner is needed here, with display name and back button
36+
Use MudAppBar
37+
*@
38+
<MudScrollToTop OnClick="BackToList"></MudScrollToTop>
39+
<MudFab StartIcon="@Icons.Material.Filled.ArrowBack" OnClick="BackToList" Color="Color.Primary"/>
40+
<MudText>@_activeChat.GetDisplayName(_currentUser.Id)</MudText>
41+
42+
}
2243

23-
<MudItem Class="chat-message-window" md="8" lg="8" xl="8" xxl="8">
24-
@if (_activeChat != null)
25-
{
2644
<MudList Class="chat-message-list" DisablePadding Dense>
2745

28-
<ChatMessageList CurrentUser="_currentUser" ActiveChat="_activeChat" />
46+
<ChatMessageList CurrentUser="_currentUser" ActiveChat="_activeChat"/>
2947

3048

3149
<MudAnimate @ref="_messageSuccessfullySentAnimation"
@@ -56,8 +74,8 @@
5674
AdornmentColor="@(string.IsNullOrEmpty(_userText) ? Color.Default : Color.Primary)"
5775
OnAdornmentClick="SendMessage"/>
5876
</MudList>
59-
}
60-
</MudItem>
77+
</MudItem>
78+
}
6179
</MudGrid>
6280
</MudLoading>
6381

@@ -73,9 +91,11 @@
7391

7492
private bool _isActiveChatPublished = true;
7593
private bool _isLoading = true;
94+
private bool _isMobile = true;
7695

7796
private MudAnimate _messageSuccessfullySentAnimation = null!;
7897
private Dictionary<Guid, Guid> _lastSuccessfullySentMessageForChat = new();
98+
7999
private bool LastMessageWasSentSuccessfullyByCurrentUser
80100
{
81101
get
@@ -107,6 +127,9 @@
107127
return;
108128
}
109129

130+
var currentBreakpoint = await BrowserViewportService.GetCurrentBreakpointAsync();
131+
_isMobile = currentBreakpoint <= Breakpoint.SmAndDown;
132+
110133
_chats = await ChatService.GetChats(_currentUser.Id);
111134
if (ChatId is not null)
112135
{

src/web/Client/Pages/Chat/ChatPage.razor

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,9 @@
55

66
<MudContainer MaxWidth="MaxWidth.Large">
77
<MudPaper Class="pa-6" Elevation="5">
8+
89

9-
<MudHidden Breakpoint="Breakpoint.MdAndUp">
10-
<SmallChatComponent />
11-
</MudHidden>
12-
13-
<MudHidden Invert Breakpoint="Breakpoint.MdAndUp">
1410
<LargeChatComponent ChatId="ChatId"/>
15-
</MudHidden>
1611

1712
</MudPaper>
1813
</MudContainer>

0 commit comments

Comments
 (0)