
Security News
New Website “Is It Really FOSS?” Tracks Transparency in Open Source Distribution Models
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
pro_motion_slide_menu
Advanced tools
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.
Add the following to your project's Gemfile
to work with bundler.
gem "pro_motion_slide_menu"
Install with bundler:
bundle install
This depends on motion-cocoapods and ProMotion.
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.
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 the slide menu with your content view (initially shown) and navigation view(s) (initially hidden)
open_slide_menu MyGreatAppScreen.new(nav_bar: true), left: NavigationScreen
# You can get to the instance of the slide menu at any time if you need to
slide_menu.controller(:left).class.name
# => NavigationScreen
# SlideMenuScreen is just an enhanced subclass of PKRevealController, so you can do all sorts of things with it
slide_menu.disablesFrontViewInteraction = true
slide_menu.animationDuration = 0.5
...
end
end
To make the slide menu present the menu from anywhere in your app:
# Show the menu
App.delegate.slide_menu.show(:left)
# Equivalent to
App.delegate.slide_menu.showViewController App.delegate.slide_menu.left_controller, animated: true, completion: ->(c) { true }
# Hide the menu
App.delegate.slide_menu.hide
# Equivalent to
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:
# Disable the gesture recongizer
App.delegate.slide_menu.removePanGestureRecognizerFromFrontView
# Re-enable the gesture recognizer (enabled by default)
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
# Create a button with a custom bg & image
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)
# Create a Bar button item containing that button
# When tapping the button, show the menu (uses Sugarcube syntax)
@left_item = UIBarButtonItem.alloc.initWithCustomView(swipe_btn)
swipe_btn.on(:touch.uicontrolevent) do
App.delegate.slide_menu.show(:left)
end
# Assign the button item to the navigation item for it to appear in the top left
self.navigationItem.leftBarButtonItem = @left_item
end
end
FAQs
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A new site reviews software projects to reveal if they’re truly FOSS, making complex licensing and distribution models easy to understand.
Security News
Astral unveils pyx, a Python-native package registry in beta, designed to speed installs, enhance security, and integrate deeply with uv.
Security News
The Latio podcast explores how static and runtime reachability help teams prioritize exploitable vulnerabilities and streamline AppSec workflows.