Улучшена адаптивность для телефонов. Добавлен новый ContextActionBarService

This commit is contained in:
FrigaT
2026-04-22 13:55:30 +03:00
parent 45b8a168a1
commit 0f9dd1a8d8
6 changed files with 150 additions and 70 deletions

View File

@@ -2,6 +2,7 @@
@inherits LayoutComponentBase
@inject PwaUpdateService PwaUpdateService
@inject IJSRuntime JSRuntime
@inject ContextualActionBarService ContextualActionBarService
<MudThemeProvider Theme="@_theme" IsDarkMode="_isDarkMode" />
<MudPopoverProvider />
@@ -9,36 +10,40 @@
<MudSnackbarProvider />
<MudLayout>
<MudAppBar Elevation="1">
<MudAppBar Elevation="1" Contextual Bottom = "@_actionBarBottom" Fixed>
<MudIconButton Icon="@Icons.Material.Filled.Menu" Color="Color.Inherit" Edge="Edge.Start" OnClick="@DrawerToggle" />
<MudSpacer />
<LoginDisplay />
<MudIconButton Icon="@(DarkLightModeButtonIcon)" Color="Color.Inherit" OnClick="@DarkModeToggle" Class="ml-2" />
<MudLink Href="https://git.frigat.duckdns.org/FrigaT/PlaylistShared" Target="_blank" Color="Color.Inherit" Underline="Underline.None" Class="ml-4">
<MudIcon Icon="@Icons.Custom.Brands.GitHub" Size="Size.Small" Class="mr-1" /> Git
</MudLink>
@if (_actionBarContent != null)
{
@_actionBarContent
}
else
{
<MudSpacer />
<LoginDisplay />
<MudIconButton Icon="@(DarkLightModeButtonIcon)" Color="Color.Inherit" OnClick="@DarkModeToggle" Class="ml-2" />
<MudLink Href="https://git.frigat.duckdns.org/FrigaT/PlaylistShared" Target="_blank" Color="Color.Inherit" Underline="Underline.None" Class="ml-4">
<MudIcon Icon="@Icons.Custom.Brands.GitHub" Size="Size.Small" Class="mr-1" /> Git
</MudLink>
}
</MudAppBar>
<MudDrawer @bind-Open="_drawerOpen" ClipMode="DrawerClipMode.Always" Elevation="2">
<NavMenu />
</MudDrawer>
<MudMainContent Class="pt-16 d-flex flex-column" Style="height: 100vh;">
<MudItem Class="flex-grow-1 overflow-y-auto">
@Body
</MudItem>
<MudItem>
<AudioPlayer />
</MudItem>
<MudMainContent Class="@("d-flex flex-column" + (_actionBarBottom ? " pt-0 pb-16" : ""))" Style="height: 100dvh;">
@Body
</MudMainContent>
</MudLayout>
@code {
private RenderFragment? _actionBarContent;
private bool _actionBarBottom = false;
private bool _drawerOpen = true;
private bool _isDarkMode = true;
private MudTheme? _theme;
private DotNetObjectReference<PwaUpdateService>? _dotNetRef;
protected override void OnInitialized()
@@ -51,6 +56,8 @@
PaletteDark = _darkPalette,
LayoutProperties = new LayoutProperties()
};
ContextualActionBarService.OnChanged += OnContextualChangedHandler;
}
protected override async Task OnAfterRenderAsync(bool firstRender)
@@ -62,6 +69,13 @@
}
}
private void OnContextualChangedHandler()
{
_actionBarContent = ContextualActionBarService.Content;
_actionBarBottom = ContextualActionBarService.Bottom ?? false;
StateHasChanged();
}
private void DrawerToggle()
{
_drawerOpen = !_drawerOpen;