Coder Social home page Coder Social logo

xamarin-sidebar's Introduction

Xamarin-Sidebar

A slideout navigation control for Xamarin iOS applications.

Menu Open

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 and 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

using XamarinSidebar;
...
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

...
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.

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

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

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.

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

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

xamarin-sidebar's People

Contributors

aloisdeniel avatar bdrelling avatar denniswelu avatar jdehlin avatar psychowood avatar travisrussi avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.