Baseflow/Xamarin-Sidebar

[PR] Hide status bar when side menu open

casamia918 opened this issue · 0 comments

I've spent long hour to modify sidebar navigation to hide status bar when side menu open. I want to create pull request but due to my lack of knowledge, I just wrote my code in this page.

In the "Xamarin-Sidebar-Unified" project, find the "Sidebar.cs" file and make some change with below code

  1. Add HideStatusBar member variable in the line 99
    public bool HideStatusBar { get; set; }

  2. Add Default value of HideStatusBar in the SetDefaults() methods in the line 225
    HideStatusBar = true;

  3. Add the setstatusbarhidden method in the OpenMenu(), CloseMenu() method in the line 121 like this

public void OpenMenu()
        {
            if (IsOpen || Disabled)
                return;
            ShowShadow();
            _sidebarContentArea.BeforeOpenAnimation();
// INSERT THIS CODE
            if (HideStatusBar)
                UIApplication.SharedApplication.SetStatusBarHidden(true, UIStatusBarAnimation.Slide);
// INSERT THIS CODE

            UIView.Animate(
                Sidebar.SlideSpeed, 
                0, 
                UIViewAnimationOptions.CurveEaseInOut,
                () => { 
                    _sidebarContentArea.OpenAnimation(MenuLocation, MenuWidth); 

                },
                () => {
                    _sidebarContentArea.AfterOpenAnimation(TapGesture);
                    IsOpen = true;
                });
        }

public void CloseMenu(bool animate = true)
{
            if (!IsOpen || Disabled)
                return;
            MenuViewController.View.EndEditing(true);
// INSERT THIS CODE
            if(HideStatusBar)
                UIApplication.SharedApplication.SetStatusBarHidden(false, UIStatusBarAnimation.Slide);
// INSERT THIS CODE
            UIView.Animate(
                animate ? Sidebar.SlideSpeed : 0, 
                0, 
                UIViewAnimationOptions.CurveEaseInOut, 
                () => { _sidebarContentArea.CloseAnimation(); }, 
                () => {
                    _sidebarContentArea.AfterCloseAnimation(TapGesture);
                    IsOpen = false;
                });
            HideShadow();
}
  1. Build the "Xamarin-Sidebar-Unified" project

  2. Open the Project options and check the output path

  3. In the output path folder, find the Xamarin-Sidebar-Unified.dll

  4. Open your own project

  5. Edit References -> .Net Assembly -> Browse -> (Above output path) -> select Xamarin-Sidebar-Unified.dll

  6. Open Info.plist with text editor (like sublime text) to add this key value pair inside area
    UIViewControllerBasedStatusBarAppearance