Skip to content

Commit a66c046

Browse files
authored
fix(MNavigationDrawer):fix MNavigationDrawer Windows event (masastack#164)
* fix(MNavigationDrawer):fix MNavigationDrawer Windows event * refactor code
1 parent 2cbdce2 commit a66c046

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

Masa.Blazor.Pro/Shared/Navigation.razor

+16-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
@inject GlobalConfig GlobalConfig;
44
@implements IDisposable
55

6-
<MNavigationDrawer Class="navigation" Width=300 MiniVariantWidth=80 Fixed ExpandOnHover="GlobalConfig.ExpandOnHover" @bind-MiniVariant="GlobalConfig.NavigationMini" App>
6+
<MNavigationDrawer @bind-Value="Visible" Class="navigation" Width=300 MiniVariantWidth=80 Fixed ExpandOnHover="GlobalConfig.ExpandOnHover" @bind-MiniVariant="GlobalConfig.NavigationMini" App>
77

88
<div style="height:132px" class="@($"block-center {(GlobalConfig.NavigationMini?"px-4":"px-12")}")" @onclick="()=>NavHelper.NavigateTo(GlobalVariables.DefaultRoute)">
99
@if (GlobalConfig.NavigationMini)
@@ -72,18 +72,31 @@
7272

7373
</MNavigationDrawer>
7474

75-
<MButton Small Fab Color="primary" Style="@($"bottom:58px;z-index:7;position: fixed;{(GlobalConfig.NavigationMini ? "left:60px;" : "left:280px;")}")" OnClick="()=>{GlobalConfig.ExpandOnHover=!GlobalConfig.ExpandOnHover;}">
75+
<MButton Small Fab Color="primary" Style="@($"bottom:58px;z-index:7;position: fixed;left:{ButtonLeft}px;")" OnClick=Switch>
7676
<MIcon Class="white--text">
77-
@(GlobalConfig.NavigationMini?"mdi-chevron-right":"mdi-chevron-left")
77+
@(GlobalConfig.NavigationMini ? "mdi-chevron-right" : "mdi-chevron-left")
7878
</MIcon>
7979
</MButton>
8080

8181
@code {
82+
public bool Visible { get; set; } = true;
83+
84+
public int ButtonLeft => !Visible ? -14 : GlobalConfig.NavigationMini ? 60 : 280;
85+
8286
protected override void OnInitialized()
8387
{
8488
GlobalConfig.OnLanguageChanged += base.StateHasChanged;
8589
}
8690

91+
public void Switch()
92+
{
93+
if (Visible)
94+
{
95+
GlobalConfig.ExpandOnHover = !GlobalConfig.ExpandOnHover;
96+
}
97+
else Visible = true;
98+
}
99+
87100
public void Dispose()
88101
{
89102
GlobalConfig.OnLanguageChanged -= base.StateHasChanged;

0 commit comments

Comments
 (0)