This gem provides an easier way to integrate a great open source toolkit, RubyMotion, with another great Objective-C framework, PKRevealController, allowing you to easily have a cool Facebook or Path style slide navigation menu, complete with gestures.

Installation
Bundler
Add the following to your project's Gemfile
to work with bundler.
gem "pro_motion_slide_menu"
Install with bundler:
bundle install
Dependenices
This depends on motion-cocoapods and ProMotion.
Rakefile
As of motion-cocoapods v1.3.7, you no longer have to include a pods setup block in your project Rakefile, we can do that for you in the gem.
Creating and Configuring a Slide Menu
To create a slide menu in your application, you need to start in your AppDelegate:
class AppDelegate < PM::Delegate
def on_load(app, options)
open_slide_menu MyGreatAppScreen.new(nav_bar: true), left: NavigationScreen
slide_menu.controller(:left).class.name
slide_menu.disablesFrontViewInteraction = true
slide_menu.animationDuration = 0.5
...
end
end
To make the slide menu present the menu from anywhere in your app:
App.delegate.slide_menu.show(:left)
App.delegate.slide_menu.showViewController App.delegate.slide_menu.left_controller, animated: true, completion: ->(c) { true }
App.delegate.slide_menu.hide
App.delegate.slide_menu.showViewController App.delegate.slide_menu.content_controller, animated: true, completion: ->(c) { true }
You can use any UIViewController
subclass you want as the menu controller, but the easiest way to provide this would be to subclass ProMotion::TableScreen
like below:
class NavigationScreen < ProMotion::TableScreen
def table_data
[{
title: nil,
cells: [{
title: 'OVERWRITE THIS METHOD',
action: :swap_content_controller,
arguments: HomeScreen
}]
}]
end
def swap_content_controller(screen_class)
App.delegate.slide_menu.controller(content: screen_class)
end
end
By default, PKRevealController
supports showing the slide menu via a gesture recognizer. To disable this feature, look at the documentation or use the following:
App.delegate.slide_menu.removePanGestureRecognizerFromFrontView
App.delegate.slide_menu.addPanGestureRecognizerToFrontView
You may want to create a button for users to show the menu in addition to the gesture recognizer. To do so, in your Screen class:
class MyScreen < ProMotion::Screen
def on_load
swipe_btn = UIButton.custom
swipe_btn.setBackgroundImage("nav_bar_menu_show_bg".uiimage, forState: :normal.uicontrolstate)
swipe_btn.setImage("nav_bar_menu_show".uiimage, forState: :normal.uicontrolstate)
size = "nav_bar_menu_show_bg".uiimage.size
swipe_btn.frame = CGRectMake(0, 0, size.width, size.height)
@left_item = UIBarButtonItem.alloc.initWithCustomView(swipe_btn)
swipe_btn.on(:touch.uicontrolevent) do
App.delegate.slide_menu.show(:left)
end
self.navigationItem.leftBarButtonItem = @left_item
end
end