Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/baseflow/xamarin-sidebar

A slideout navigation control for Xamarin.iOS
https://github.com/baseflow/xamarin-sidebar

baseflow c-sharp nuget slideout-menu xamarin xamarin-sidebar

Last synced: 3 days ago
JSON representation

A slideout navigation control for Xamarin.iOS

Awesome Lists containing this project

README

        

Xamarin-Sidebar
============================

A slideout navigation control for Xamarin iOS applications.

![license](https://img.shields.io/github/license/jdehlin/Xamarin-Sidebar.svg)
[![Build status](https://ci.appveyor.com/api/projects/status/lonmgoyb01ikni8q?svg=true)](https://ci.appveyor.com/project/martijn00/xamarin-sidebar)
[![NuGet](https://img.shields.io/nuget/v/SidebarNavigation.svg)](https://www.nuget.org/packages/SidebarNavigation/)
[![GitHub tag](https://img.shields.io/github/tag/jdehlin/Xamarin-Sidebar.svg)](https://github.com/jdehlin/Xamarin-Sidebar/releases)
[![MyGet](https://img.shields.io/myget/martijn00/v/xamarin-sidebar.svg)](https://www.myget.org/F/martijn00/api/v3/index.json)

Get the package on [Nuget](https://www.nuget.org/packages/SidebarNavigation/)!

*If you're using Sidebar Navigation send me a link to your app and I'll happily post it here.*

![Menu Open](https://raw.githubusercontent.com/jdehlin/Xamarin-Sidebar/master/Screenshots/Transition.png)

This is partly based on two other good slideout menu implementation that each didn't
provide quite what I was looking for. Those two are
[FlyoutNavigation](https://github.com/Clancey/FlyoutNavigation)
and
[SlideoutNavigation](https://github.com/thedillonb/MonoTouch.SlideoutNavigation/).

`Xamarin-Sidebar` allows you to provide one UIViewController to be used as a content view
and another to be used as a menu. When you open the menu the content view will slide over
to reveal the provided menu UIViewController.

To set it up just create a root UIViewController and a SidebarController, passing in your
content and menu controllers.

`RootViewController.cs`
```csharp
using SidebarNavigation;
...
public partial class RootViewController : UIViewController
{
// the sidebar controller for the app
public SidebarController SidebarController { get; private set; }

public override void ViewDidLoad()
{
base.ViewDidLoad();

// create a slideout navigation controller with the top navigation controller and the menu view controller
SidebarController = new SidebarController(this, new ContentController(), new SideMenuController());
}
}
...
```

`AppDelegate.cs`
```csharp
...
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
window = new UIWindow(UIScreen.MainScreen.Bounds);

// set our root view controller with the sidebar menu as the apps root view controller
window.RootViewController = new RootViewController();

window.MakeKeyAndVisible();
return true;
}
...
```

In the content controller you can add a button to open the slideout menu.

```csharp
menuButton.TouchUpInside += (sender, e) => {
SidebarController.ToggleMenu();
};
```

In the side menu controller you can add buttons to change the content view.

```csharp
otherContentButton.TouchUpInside += (sender, e) => {
SidebarController.ChangeContentView(new OtherContentController());
};
```

Additional options include hiding the shadow, setting the menu width, and placing the menu
on the left.

```csharp
SidebarController.HasShadowing = false;
SidebarController.MenuWidth = 220;
SidebarController.MenuLocation = SidebarController.MenuLocations.Left;
```

See the sample projects included in the source for more details.