Ejemplo n.º 1
0
        protected override async Task OnFirstAfterRenderAsync()
        {
            dotNetObjectRef ??= JSRunner.CreateDotNetObjectRef(new BreakpointActivatorAdapter(this));

            if (Rendered)
            {
                _ = JSRunner.RegisterBreakpointComponent(dotNetObjectRef, ElementId);

                if (Mode != BarMode.Horizontal)
                {
                    // Check if we need to collapse the Bar based on the current screen width against the breakpoint defined for this component.
                    // This needs to be run to set the inital state, RegisterBreakpointComponent and OnBreakpoint will handle
                    // additional changes to responsive breakpoints from there.
                    isBroken = BreakpointActivatorAdapter.IsBroken(Breakpoint, await JSRunner.GetBreakpoint());

                    if (Visible == isBroken)
                    {
                        Visible = !isBroken;
                        StateHasChanged();
                    }
                }
            }

            await base.OnFirstAfterRenderAsync();
        }
Ejemplo n.º 2
0
 /// <summary>
 /// An event that fires when the navigation location has changed.
 /// </summary>
 /// <param name="sender">Object the fired the notification.</param>
 /// <param name="args">New location arguments.</param>
 private async void OnLocationChanged(object sender, LocationChangedEventArgs args)
 {
     // Collapse the bar automatically
     if (Visible && BreakpointActivatorAdapter.IsBroken(NavigationBreakpoint, await JSRunner.GetBreakpoint()))
     {
         await Toggle();
     }
 }
Ejemplo n.º 3
0
        protected override async Task OnInitializedAsync()
        {
            if (Mode != BarMode.Horizontal)
            {
                lastBrokenState = BreakpointActivatorAdapter.IsBroken(Breakpoint, await JSRunner.GetBreakpoint());
                Visible         = !lastBrokenState;
            }

            if (NavigationBreakpoint != Breakpoint.None)
            {
                NavigationManager.LocationChanged += OnLocationChanged;
            }

            await base.OnInitializedAsync();
        }