Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PR] Hide status bar when side menu open #50

Open
casamia918 opened this issue Jul 9, 2016 · 0 comments
Open

[PR] Hide status bar when side menu open #50

casamia918 opened this issue Jul 9, 2016 · 0 comments

Comments

@casamia918
Copy link

casamia918 commented Jul 9, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant