File tree 5 files changed +61
-6
lines changed
Blazor.AdminLte.Site.Shared
5 files changed +61
-6
lines changed Original file line number Diff line number Diff line change 1
1
@inherits LayoutComponentBase
2
2
@inject NavigationManager NavigationManager
3
3
@inject IJSRuntime JS
4
+ @inject ILayoutManager layoutManager
4
5
@inject NavBarLeftInjectableMenu navBarLeftInjectableMenu
5
6
<NavBar >
6
7
<NavBarLeft >
203
204
204
205
protected override void OnAfterRender (bool isFirstRender )
205
206
{
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);
209
213
base .OnAfterRender (isFirstRender );
210
214
}
211
215
}
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 1
1
@implements IDisposable
2
2
@namespace Blazor.AdminLte
3
-
3
+ @inject ILayoutManager layoutManager
4
4
@inject IJSRuntime js
5
5
6
6
@inject NavigationManager NavigationManager
32
32
}
33
33
void LocationChanged (object sender , LocationChangedEventArgs e )
34
34
{
35
+ layoutManager .OverlayMode (false );
35
36
js .InvokeVoidAsync (" overlay" , false );
36
37
}
37
38
void IDisposable .Dispose ()
43
44
44
45
protected override Task OnAfterRenderAsync (bool firstRender )
45
46
{
47
+ layoutManager .OverlayMode (true );
46
48
js .InvokeVoidAsync (" overlay" , true );
47
49
return base .OnAfterRenderAsync (firstRender );
48
50
}
Original file line number Diff line number Diff line change @@ -8,13 +8,15 @@ public static class ServiceCollectionExtensions
8
8
{
9
9
public static IServiceCollection AddAdminLte ( this IServiceCollection services )
10
10
{
11
- return services . AddScoped < NavBarLeftInjectableMenu > ( ) . AddBlazorState ( ( aOptions ) =>
11
+ return services
12
+ . AddScoped < NavBarLeftInjectableMenu > ( )
13
+ . AddBlazorState ( ( aOptions ) =>
12
14
aOptions . Assemblies = new Assembly [ ]
13
15
{
14
16
typeof ( BaseClasses ) . GetTypeInfo ( ) . Assembly ,
15
17
Assembly . GetExecutingAssembly ( )
16
18
}
17
- ) ;
19
+ ) . AddScoped < ILayoutManager , LayoutManager > ( ) ;
18
20
}
19
21
}
20
22
}
You can’t perform that action at this time.
0 commit comments