File tree Expand file tree Collapse file tree 5 files changed +61
-6
lines changed
Blazor.AdminLte.Site.Shared Expand file tree Collapse file tree 5 files changed +61
-6
lines changed Original file line number Diff line number Diff line change 11@inherits LayoutComponentBase
22@inject NavigationManager NavigationManager
33@inject IJSRuntime JS
4+ @inject ILayoutManager layoutManager
45@inject NavBarLeftInjectableMenu navBarLeftInjectableMenu
56<NavBar >
67 <NavBarLeft >
203204
204205 protected override void OnAfterRender (bool isFirstRender )
205206 {
206- JS .InvokeVoidAsync (" sideBarFixed" , true );
207- JS .InvokeVoidAsync (" navBarFixed" , true );
208- JS .InvokeVoidAsync (" footerFixed" , true );
207+ layoutManager .IsFooterFixed = true ;
208+ layoutManager .IsNavBarFixed = true ;
209+ layoutManager .IsSideBarFixed = true ;
210+ // JS.InvokeVoidAsync("sideBarFixed", true);
211+ // JS.InvokeVoidAsync("navBarFixed", true);
212+ // JS.InvokeVoidAsync("footerFixed", true);
209213 base .OnAfterRender (isFirstRender );
210214 }
211215}
Original file line number Diff line number Diff line change 1+ namespace Blazor . AdminLte
2+ {
3+ public interface ILayoutManager
4+ {
5+ bool IsFooterFixed { get ; set ; }
6+ bool IsNavBarFixed { get ; set ; }
7+ bool IsSideBarFixed { get ; set ; }
8+
9+ void OverlayMode ( bool isOverlayMode ) ;
10+ }
11+ }
Original file line number Diff line number Diff line change 1+ using Microsoft . JSInterop ;
2+
3+ namespace Blazor . AdminLte
4+ {
5+ public class LayoutManager : ILayoutManager
6+ {
7+ private bool _IsSideBarFixed ;
8+ private bool _IsNavBarFixed ;
9+ private bool _IsFooterFixed ;
10+
11+ public bool IsSideBarFixed { get { return _IsSideBarFixed ; } set { _IsSideBarFixed = value ; js . InvokeVoidAsync ( "sideBarFixed" , value ) ; } }
12+ public bool IsNavBarFixed { get { return _IsNavBarFixed ; } set { _IsNavBarFixed = value ; js . InvokeVoidAsync ( "navBarFixed" , value ) ; } }
13+ public bool IsFooterFixed { get { return _IsFooterFixed ; } set { _IsFooterFixed = value ; js . InvokeVoidAsync ( "footerFixed" , value ) ; } }
14+
15+ private readonly IJSRuntime js ;
16+
17+ public LayoutManager ( IJSRuntime js )
18+ {
19+ this . js = js ;
20+ }
21+
22+ public void OverlayMode ( bool isOverlayMode )
23+ {
24+ if ( isOverlayMode )
25+ {
26+ js . InvokeVoidAsync ( "navBarFixed" , false ) ;
27+ js . InvokeVoidAsync ( "footerFixed" , false ) ;
28+ }
29+ else
30+ {
31+ js . InvokeVoidAsync ( "navBarFixed" , _IsNavBarFixed ) ;
32+ js . InvokeVoidAsync ( "footerFixed" , _IsFooterFixed ) ;
33+ }
34+ }
35+ }
36+ }
Original file line number Diff line number Diff line change 11@implements IDisposable
22@namespace Blazor.AdminLte
3-
3+ @inject ILayoutManager layoutManager
44@inject IJSRuntime js
55
66@inject NavigationManager NavigationManager
3232 }
3333 void LocationChanged (object sender , LocationChangedEventArgs e )
3434 {
35+ layoutManager .OverlayMode (false );
3536 js .InvokeVoidAsync (" overlay" , false );
3637 }
3738 void IDisposable .Dispose ()
4344
4445 protected override Task OnAfterRenderAsync (bool firstRender )
4546 {
47+ layoutManager .OverlayMode (true );
4648 js .InvokeVoidAsync (" overlay" , true );
4749 return base .OnAfterRenderAsync (firstRender );
4850 }
Original file line number Diff line number Diff line change @@ -8,13 +8,15 @@ public static class ServiceCollectionExtensions
88 {
99 public static IServiceCollection AddAdminLte ( this IServiceCollection services )
1010 {
11- return services . AddScoped < NavBarLeftInjectableMenu > ( ) . AddBlazorState ( ( aOptions ) =>
11+ return services
12+ . AddScoped < NavBarLeftInjectableMenu > ( )
13+ . AddBlazorState ( ( aOptions ) =>
1214 aOptions . Assemblies = new Assembly [ ]
1315 {
1416 typeof ( BaseClasses ) . GetTypeInfo ( ) . Assembly ,
1517 Assembly . GetExecutingAssembly ( )
1618 }
17- ) ;
19+ ) . AddScoped < ILayoutManager , LayoutManager > ( ) ;
1820 }
1921 }
2022}
You can’t perform that action at this time.
0 commit comments