ProMotion-menu 1.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +185 -0
- data/lib/ProMotion-menu.rb +20 -0
- data/lib/ProMotion/menu/delegate.rb +31 -0
- data/lib/ProMotion/menu/drawer.rb +84 -0
- data/lib/ProMotion/menu/gestures.rb +51 -0
- data/lib/ProMotion/menu/version.rb +7 -0
- data/lib/ProMotion/menu/visibility.rb +35 -0
- data/spec/app_delegate_spec.rb +29 -0
- data/spec/drawer_spec.rb +52 -0
- data/spec/gestures_spec.rb +18 -0
- data/spec/helpers/blank_screen.rb +2 -0
- data/spec/helpers/left_nav_screen.rb +10 -0
- data/spec/helpers/right_nav_screen.rb +10 -0
- data/spec/visibility_spec.rb +82 -0
- metadata +126 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 506495232e85d5bec57a034e5fd0c6820bcce68b
|
4
|
+
data.tar.gz: 5b169253848bbde36cc8c34f99be6d3d169fee62
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 818000fdbc9bd789b3fe132d91252ebb995afe00d7d5e793f795ebc7f396f5040ee32b4650fd96826d6b136ad57e057c2291e89e91ee59a5308340a04b7bafa7
|
7
|
+
data.tar.gz: 7bbf88df1c5f29981fb872f945528f8f9158b332ce2e23fdaf1d074f7d4d8fdbce6764db15dba0cb9a852ec845f1890c4b25c20a469f6eae2ed02417c3afd381
|
data/README.md
ADDED
@@ -0,0 +1,185 @@
|
|
1
|
+
# ProMotion-menu [![Gem Version](https://badge.fury.io/rb/ProMotion-menu.png)](http://badge.fury.io/rb/ProMotion-menu) [![Build Status](https://travis-ci.org/clearsightstudio/ProMotion-menu.svg?branch=master)](https://travis-ci.org/clearsightstudio/ProMotion-menu) [![Code Climate](https://codeclimate.com/github/clearsightstudio/ProMotion-menu/badges/gpa.svg)](https://codeclimate.com/github/clearsightstudio/ProMotion-menu) [![Test Coverage](https://codeclimate.com/github/clearsightstudio/ProMotion-menu/badges/coverage.svg)](https://codeclimate.com/github/clearsightstudio/ProMotion-menu)
|
2
|
+
|
3
|
+
ProMotion-menu provides a menu component for the popular RubyMotion gem [ProMotion](https://github.com/clearsightstudio/ProMotion). Utilizing [MMDrawerController](https://github.com/mutualmobile/MMDrawerController) it allows you to easily have a cool Facebook or Path style slide navigation menu, complete with gestures.
|
4
|
+
|
5
|
+
The gem was originally named `pro_motion_slide_menu` and authored by [Matt Brewer](https://github.com/macfanatic).
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
### Bundler
|
10
|
+
|
11
|
+
Add the following to your project's `Gemfile` to work with bundler.
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'ProMotion-menu'
|
15
|
+
```
|
16
|
+
|
17
|
+
Install with bundler:
|
18
|
+
|
19
|
+
```ruby
|
20
|
+
bundle install
|
21
|
+
```
|
22
|
+
|
23
|
+
### Dependenices
|
24
|
+
This depends on motion-cocoapods and ProMotion.
|
25
|
+
|
26
|
+
### Rakefile
|
27
|
+
|
28
|
+
As of [motion-cocoapods](https://github.com/HipByte/motion-cocoapods/compare/1.3.6...1.3.7) 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.
|
29
|
+
|
30
|
+
## Creating and Configuring a Menu
|
31
|
+
To create a menu in your application, you need to start in your AppDelegate:
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
class AppDelegate < PM::Delegate
|
35
|
+
|
36
|
+
def on_load(app, options)
|
37
|
+
|
38
|
+
# Open the menu with your center view (initially shown) and navigation view(s) (initially hidden)
|
39
|
+
open_menu MyGreatAppScreen.new(nav_bar: true), left: NavigationScreen
|
40
|
+
|
41
|
+
# You can get to the instance of the menu at any time if you need to
|
42
|
+
self.menu.controller(:left).class.name
|
43
|
+
# => NavigationScreen
|
44
|
+
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
```
|
49
|
+
|
50
|
+
### Alternate Approach
|
51
|
+
If you prefer to keep your menu encapsulated you can create a menu drawer and do your setup there.
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
class MenuDrawer < PM::Menu::Drawer
|
55
|
+
|
56
|
+
def setup
|
57
|
+
self.center = MyGreatAppScreen.new(nav_bar: true)
|
58
|
+
self.left = NavigationScreen
|
59
|
+
self.to_show = [:tap_nav_bar, :pan_nav_bar]
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
class AppDelegate < PM::Delegate
|
65
|
+
|
66
|
+
def on_load(app, options)
|
67
|
+
@menu = open MenuDrawer
|
68
|
+
end
|
69
|
+
|
70
|
+
def show_menu
|
71
|
+
@menu.show :left
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
```
|
76
|
+
|
77
|
+
## Gesture Recognition
|
78
|
+
By default you can show the menu by panning within 20 pts of the bezel and hide it by panning or tapping
|
79
|
+
the center view. It's possible to override the default behavior:
|
80
|
+
|
81
|
+
```ruby
|
82
|
+
|
83
|
+
# In AppDelegate
|
84
|
+
open_menu BodyScreen, right: MenuScreen, to_show: :pan_nav_bar, to_hide: [:pan_nav_bar, :tap_nav_bar]
|
85
|
+
|
86
|
+
# From elsewhere in your app
|
87
|
+
app_delegate.menu.to_show = :pan_center
|
88
|
+
|
89
|
+
# The following gestures are provided:
|
90
|
+
|
91
|
+
# For to_show:
|
92
|
+
:pan_nav_bar # Pan anywhere on the navigation bar
|
93
|
+
:pan_content # Pan anywhere on the center view
|
94
|
+
:pan_center # Alias of above
|
95
|
+
:pan_bezel # Pan anywhere within 20 pts of the bezel
|
96
|
+
:all # All of the above
|
97
|
+
:none # No gesture recognition
|
98
|
+
|
99
|
+
# For to_hide:
|
100
|
+
:pan_nav_bar # Pan anywhere on the navigation bar
|
101
|
+
:pan_content # Pan anywhere on the center view
|
102
|
+
:pan_center # Alias of above
|
103
|
+
:pan_bezel # Pan anywhere within the bezel of the center view
|
104
|
+
:tap_nav_bar # Tap the navigation bar
|
105
|
+
:tap_content # Tap the center view
|
106
|
+
:tap_center # Alias of above
|
107
|
+
:pan_menu # Pan anywhere on the drawer view
|
108
|
+
:all # All of the above
|
109
|
+
:none # No gesture recognition
|
110
|
+
|
111
|
+
```
|
112
|
+
|
113
|
+
## Toggling the Menu Drawer Current Screen
|
114
|
+
To make the menu drawer present the menu from anywhere in your app:
|
115
|
+
|
116
|
+
```ruby
|
117
|
+
|
118
|
+
# Show the menu
|
119
|
+
app_delegate.menu.show(:left)
|
120
|
+
|
121
|
+
# Equivalent to
|
122
|
+
app_delegate.menu.openDrawerSide MMDrawerSideLeft, animated: true, completion: ->(c) { true }
|
123
|
+
|
124
|
+
# Hide the menu
|
125
|
+
app_delegate.menu.hide
|
126
|
+
|
127
|
+
# Equivalent to
|
128
|
+
app_delegate.menu.closeDrawerAnimated animated: true, completion: ->(c) { true }
|
129
|
+
|
130
|
+
# Actually toggle the menu between open/closed states
|
131
|
+
app_delegate.menu.toggle(:left)
|
132
|
+
app_delegate.menu.toggle_left
|
133
|
+
|
134
|
+
# Equivalent to
|
135
|
+
app_delegate.menu.toggleDrawerSide MMDrawerSideLeft, animated: true, completion: ->(c) { true }
|
136
|
+
|
137
|
+
```
|
138
|
+
|
139
|
+
## Setting up the Menu
|
140
|
+
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:
|
141
|
+
|
142
|
+
```ruby
|
143
|
+
class NavigationScreen < ProMotion::TableScreen
|
144
|
+
|
145
|
+
def table_data
|
146
|
+
[{
|
147
|
+
title: nil,
|
148
|
+
cells: [{
|
149
|
+
title: 'OVERWRITE THIS METHOD',
|
150
|
+
action: :swap_center_controller,
|
151
|
+
arguments: HomeScreen
|
152
|
+
}]
|
153
|
+
}]
|
154
|
+
end
|
155
|
+
|
156
|
+
def swap_center_controller(screen_class)
|
157
|
+
app_delegate.menu.center_controller = screen_class
|
158
|
+
end
|
159
|
+
|
160
|
+
end
|
161
|
+
```
|
162
|
+
|
163
|
+
## More Information
|
164
|
+
|
165
|
+
Be sure to check out more documenation from the [cocoapod itself](http://cocoadocs.org/docsets/MMDrawerController/0.5.6/), for fun things such as gesture support for showing or dismissing drawers, custom UIBarButtonItems and more.
|
166
|
+
|
167
|
+
### Help
|
168
|
+
|
169
|
+
ProMotion is not only an easy DSL to get started. The community is very helpful and
|
170
|
+
welcoming to new RubyMotion developers. We don't mind newbie questions.
|
171
|
+
|
172
|
+
If you need help, feel free to open an issue on GitHub. If we don't respond within a day, tweet us a link to the issue -- sometimes we get busy.
|
173
|
+
|
174
|
+
### Contributing
|
175
|
+
|
176
|
+
See [CONTRIBUTING.md](https://github.com/clearsightstudio/ProMotion/blob/master/CONTRIBUTING.md).
|
177
|
+
|
178
|
+
### Primary Contributors
|
179
|
+
|
180
|
+
* Matt Brewer: [@macfanatic](https://github.com/macfanatic)
|
181
|
+
* Ryan Linton: [@ryanlntn](https://twitter.com/ryanlntn)
|
182
|
+
* Jason Stirk: [@jstirk](https://github.com/jstirk)
|
183
|
+
* Mark Rickert: [@markrickert](https://twitter.com/markrickert)
|
184
|
+
* Jamon Holmgren: [@jamonholmgren](https://twitter.com/jamonholmgren)
|
185
|
+
* [Many others](https://github.com/clearsightstudio/ProMotion-menu/graphs/contributors)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
unless defined?(Motion::Project::Config)
|
2
|
+
raise "The ProMotion gem must be required within a RubyMotion project Rakefile."
|
3
|
+
end
|
4
|
+
|
5
|
+
require 'motion-cocoapods'
|
6
|
+
require 'ProMotion'
|
7
|
+
|
8
|
+
Motion::Project::App.setup do |app|
|
9
|
+
core_lib = File.join(File.dirname(__FILE__), 'ProMotion')
|
10
|
+
insert_point = app.files.find_index { |file| file =~ /^(?:\.\/)?app\// } || 0
|
11
|
+
|
12
|
+
Dir.glob(File.join(File.dirname(__FILE__), 'ProMotion/menu/**/*.rb')).each do |file|
|
13
|
+
app.files << file
|
14
|
+
end
|
15
|
+
|
16
|
+
app.pods do
|
17
|
+
pod 'MMDrawerController', '~> 0.5'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module ProMotion
|
2
|
+
module Menu
|
3
|
+
module Delegate
|
4
|
+
|
5
|
+
def menu=(m)
|
6
|
+
@menu = m
|
7
|
+
end
|
8
|
+
alias_method :slide_menu=, :menu=
|
9
|
+
|
10
|
+
def menu
|
11
|
+
@menu
|
12
|
+
end
|
13
|
+
alias_method :slide_menu, :menu
|
14
|
+
|
15
|
+
def has_menu?
|
16
|
+
!menu.nil?
|
17
|
+
end
|
18
|
+
alias_method :has_slide_menu?, :has_menu?
|
19
|
+
|
20
|
+
def open_menu(content, options={})
|
21
|
+
self.menu = ProMotion::Menu::Drawer.new(content, options)
|
22
|
+
open_root_screen menu
|
23
|
+
menu
|
24
|
+
end
|
25
|
+
alias_method :open_slide_menu, :open_menu # backwards compat
|
26
|
+
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
PM::Delegate.send :include, ProMotion::Menu::Delegate
|
@@ -0,0 +1,84 @@
|
|
1
|
+
module ProMotion
|
2
|
+
module Menu
|
3
|
+
class Drawer < MMDrawerController
|
4
|
+
include ::ProMotion::ScreenModule
|
5
|
+
include Gestures
|
6
|
+
include Visibility
|
7
|
+
|
8
|
+
def self.new(center=nil, options={})
|
9
|
+
menu = alloc.init
|
10
|
+
menu.send(:auto_setup, center, options)
|
11
|
+
menu
|
12
|
+
end
|
13
|
+
|
14
|
+
def auto_setup(center, options={})
|
15
|
+
options[:to_show] ||= :pan_bezel
|
16
|
+
options[:to_hide] ||= [:pan_center, :tap_center]
|
17
|
+
options[:center] ||= center if center
|
18
|
+
set_attributes self, options
|
19
|
+
self.send(:setup) if self.respond_to?(:setup)
|
20
|
+
end
|
21
|
+
|
22
|
+
def left_controller=(c)
|
23
|
+
self.leftDrawerViewController = prepare_controller_for_pm(c)
|
24
|
+
end
|
25
|
+
alias_method :left=, :left_controller=
|
26
|
+
|
27
|
+
def left_controller
|
28
|
+
self.leftDrawerViewController
|
29
|
+
end
|
30
|
+
alias_method :left, :left_controller
|
31
|
+
|
32
|
+
def right_controller=(c)
|
33
|
+
self.rightDrawerViewController = prepare_controller_for_pm(c)
|
34
|
+
end
|
35
|
+
alias_method :right=, :right_controller=
|
36
|
+
|
37
|
+
def right_controller
|
38
|
+
self.rightDrawerViewController
|
39
|
+
end
|
40
|
+
alias_method :right, :right_controller
|
41
|
+
|
42
|
+
def center_controller=(c)
|
43
|
+
self.centerViewController = prepare_controller_for_pm(c)
|
44
|
+
end
|
45
|
+
alias_method :content_controller=, :center_controller=
|
46
|
+
alias_method :center=, :center_controller=
|
47
|
+
alias_method :content=, :center_controller=
|
48
|
+
|
49
|
+
def center_controller
|
50
|
+
self.centerViewController
|
51
|
+
end
|
52
|
+
alias_method :content_controller, :center_controller
|
53
|
+
alias_method :center, :center_controller
|
54
|
+
alias_method :content, :center_controller
|
55
|
+
|
56
|
+
def controller=(side={})
|
57
|
+
self.left_controller = side[:left] if side[:left]
|
58
|
+
self.right_controller = side[:right] if side[:right]
|
59
|
+
self.center_controller = side[:center] if side[:center]
|
60
|
+
self.center_controller ||= side[:content] if side[:content]
|
61
|
+
end
|
62
|
+
alias_method :controllers=, :controller=
|
63
|
+
|
64
|
+
def controller(side)
|
65
|
+
return self.left_controller if side == :left
|
66
|
+
return self.right_controller if side == :right
|
67
|
+
self.center_controller if [:content, :center].include?(side)
|
68
|
+
end
|
69
|
+
|
70
|
+
protected
|
71
|
+
|
72
|
+
def prepare_controller_for_pm(controller)
|
73
|
+
controller = set_up_screen_for_open(controller, {})
|
74
|
+
ensure_wrapper_controller_in_place(controller, {})
|
75
|
+
controller.navigationController || controller
|
76
|
+
end
|
77
|
+
|
78
|
+
def default_completion_block
|
79
|
+
-> (completed) { true }
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module ProMotion; module Menu
|
2
|
+
module Gestures
|
3
|
+
|
4
|
+
SHOW_MASKS = {
|
5
|
+
pan_nav_bar: MMOpenDrawerGestureModePanningNavigationBar, # Pan anywhere on the navigation bar
|
6
|
+
pan_content: MMOpenDrawerGestureModePanningCenterView, # Pan anywhere on the center view
|
7
|
+
pan_center: MMOpenDrawerGestureModePanningCenterView, # Alias of above
|
8
|
+
pan_bezel: MMOpenDrawerGestureModeBezelPanningCenterView, # Pan anywhere within 20 pts of the bezel
|
9
|
+
all: MMOpenDrawerGestureModeAll, # All of the above
|
10
|
+
none: MMOpenDrawerGestureModeNone # No gesture recognition
|
11
|
+
}
|
12
|
+
|
13
|
+
HIDE_MASKS = {
|
14
|
+
pan_nav_bar: MMCloseDrawerGestureModePanningNavigationBar, # Pan anywhere on the navigation bar
|
15
|
+
pan_content: MMCloseDrawerGestureModePanningCenterView, # Pan anywhere on the center view
|
16
|
+
pan_center: MMCloseDrawerGestureModePanningCenterView, # Alias of above
|
17
|
+
pan_bezel: MMCloseDrawerGestureModeBezelPanningCenterView, # Pan anywhere within the bezel of the center view
|
18
|
+
tap_nav_bar: MMCloseDrawerGestureModeTapNavigationBar, # Tap the navigation bar
|
19
|
+
tap_content: MMCloseDrawerGestureModeTapCenterView, # Tap the center view
|
20
|
+
tap_center: MMCloseDrawerGestureModeTapCenterView, # Alias of above
|
21
|
+
pan_menu: MMCloseDrawerGestureModePanningDrawerView, # Pan anywhere on the drawer view
|
22
|
+
all: MMCloseDrawerGestureModeAll, # All of the above
|
23
|
+
none: MMCloseDrawerGestureModeNone # No gesture recognition
|
24
|
+
}
|
25
|
+
|
26
|
+
def to_show=(gestures)
|
27
|
+
self.openDrawerGestureModeMask = mask_for_show(gestures)
|
28
|
+
end
|
29
|
+
|
30
|
+
def to_hide=(gestures)
|
31
|
+
self.closeDrawerGestureModeMask = mask_for_hide(gestures)
|
32
|
+
end
|
33
|
+
|
34
|
+
def mask_for_show(gestures)
|
35
|
+
mask = 0
|
36
|
+
Array(gestures).each do |g|
|
37
|
+
mask = mask | SHOW_MASKS[g]
|
38
|
+
end
|
39
|
+
mask
|
40
|
+
end
|
41
|
+
|
42
|
+
def mask_for_hide(gestures)
|
43
|
+
mask = 0
|
44
|
+
Array(gestures).each do |g|
|
45
|
+
mask = mask | HIDE_MASKS[g]
|
46
|
+
end
|
47
|
+
mask
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
end; end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module ProMotion; module Menu
|
2
|
+
module Visibility
|
3
|
+
|
4
|
+
def show(side, animated=true)
|
5
|
+
self.show_left(animated) if side == :left
|
6
|
+
self.show_right(animated) if side == :right
|
7
|
+
end
|
8
|
+
|
9
|
+
def show_left(animated=true)
|
10
|
+
openDrawerSide MMDrawerSideLeft, animated: animated, completion: default_completion_block
|
11
|
+
end
|
12
|
+
|
13
|
+
def show_right(animated=true)
|
14
|
+
openDrawerSide MMDrawerSideRight, animated: animated, completion: default_completion_block
|
15
|
+
end
|
16
|
+
|
17
|
+
def hide(animated=true)
|
18
|
+
closeDrawerAnimated animated, completion: default_completion_block
|
19
|
+
end
|
20
|
+
|
21
|
+
def toggle(side, animated=true)
|
22
|
+
toggle_left(animated) if side == :left
|
23
|
+
toggle_right(animated) if side == :right
|
24
|
+
end
|
25
|
+
|
26
|
+
def toggle_left(animated=true)
|
27
|
+
toggleDrawerSide MMDrawerSideLeft, animated: animated, completion: default_completion_block
|
28
|
+
end
|
29
|
+
|
30
|
+
def toggle_right(animated=true)
|
31
|
+
toggleDrawerSide MMDrawerSideRight, animated: animated, completion: default_completion_block
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
|
+
end; end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
describe ProMotion::Menu::Delegate do
|
2
|
+
|
3
|
+
before do
|
4
|
+
@delegate = UIApplication.sharedApplication.delegate
|
5
|
+
end
|
6
|
+
|
7
|
+
it "should have a 'slide_menu' attribute" do
|
8
|
+
@delegate.respond_to?(:slide_menu).should == true
|
9
|
+
end
|
10
|
+
|
11
|
+
it "should not have a slide menu by default" do
|
12
|
+
@delegate.has_menu?.should == false
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should respond to 'open_menu'" do
|
16
|
+
@delegate.respond_to?(:open_menu).should == true
|
17
|
+
end
|
18
|
+
|
19
|
+
it "#open_menu should return a Menu::Drawer" do
|
20
|
+
@delegate.open_menu(BlankScreen, left: LeftNavScreen).should.be.instance_of ProMotion::Menu::Drawer
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should have a Menu::Drawer as the rootViewController" do
|
24
|
+
@delegate.open_menu(BlankScreen)
|
25
|
+
|
26
|
+
@delegate.window.rootViewController.should.be.instance_of ProMotion::Menu::Drawer
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
data/spec/drawer_spec.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
describe ProMotion::Menu::Drawer do
|
2
|
+
|
3
|
+
before do
|
4
|
+
@delegate = UIApplication.sharedApplication.delegate
|
5
|
+
@left = LeftNavScreen.new
|
6
|
+
@right = RightNavScreen.new
|
7
|
+
@content = BlankScreen.new
|
8
|
+
end
|
9
|
+
|
10
|
+
it "returns an instance of PM::Menu::Drawer" do
|
11
|
+
menu = ProMotion::Menu::Drawer.new @content, left: @left
|
12
|
+
menu.should.be.instance_of ProMotion::Menu::Drawer
|
13
|
+
end
|
14
|
+
|
15
|
+
it "stores menu & content controllers" do
|
16
|
+
menu = ProMotion::Menu::Drawer.new @content, left: @left
|
17
|
+
menu.left_controller.should == @left
|
18
|
+
menu.center_controller.should == @content
|
19
|
+
end
|
20
|
+
|
21
|
+
it "allows you to pass class instances" do
|
22
|
+
menu = ProMotion::Menu::Drawer.new BlankScreen, left: LeftNavScreen
|
23
|
+
menu.left_controller.should.be.instance_of LeftNavScreen
|
24
|
+
menu.center_controller.should.be.instance_of BlankScreen
|
25
|
+
end
|
26
|
+
|
27
|
+
it "lets me wrap the content controller in a UINavigationController" do
|
28
|
+
center_controller = BlankScreen.new(nav_bar: true)
|
29
|
+
menu = ProMotion::Menu::Drawer.new center_controller, left: @left
|
30
|
+
menu.center_controller.should.be.instance_of ProMotion::NavigationController
|
31
|
+
end
|
32
|
+
|
33
|
+
it "lets me set the title on the content controller during creation" do
|
34
|
+
center_controller = BlankScreen.new(title: 'My Title')
|
35
|
+
menu = ProMotion::Menu::Drawer.new center_controller, left: @left
|
36
|
+
menu.center_controller.title.should == 'My Title'
|
37
|
+
end
|
38
|
+
|
39
|
+
it "accepts a plain UIViewController" do
|
40
|
+
menu = ProMotion::Menu::Drawer.new @content, left: @left
|
41
|
+
should.not.raise(NoMethodError) { menu.left_controller = UIViewController }
|
42
|
+
menu.left_controller.should.be.instance_of UIViewController
|
43
|
+
end
|
44
|
+
|
45
|
+
it "allows you to set both a right and left menu controller" do
|
46
|
+
menu = ProMotion::Menu::Drawer.new @content, left: @left, right: @right
|
47
|
+
menu.left_controller.should == @left
|
48
|
+
menu.right_controller.should == @right
|
49
|
+
menu.center_controller.should == @content
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
describe ProMotion::Menu::Gestures do
|
2
|
+
|
3
|
+
before do
|
4
|
+
@object = Object.new
|
5
|
+
@object.extend(ProMotion::Menu::Gestures)
|
6
|
+
end
|
7
|
+
|
8
|
+
it "assigns the correct gesture mode" do
|
9
|
+
@object.mask_for_show(:pan_bezel).should == MMOpenDrawerGestureModeBezelPanningCenterView
|
10
|
+
end
|
11
|
+
|
12
|
+
it "correctly combines gestures" do
|
13
|
+
@object.mask_for_hide([:pan_center, :tap_center]).should == (
|
14
|
+
MMCloseDrawerGestureModePanningCenterView | MMCloseDrawerGestureModeTapCenterView
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
describe ProMotion::Menu::Visibility do
|
2
|
+
|
3
|
+
before do
|
4
|
+
@delegate = UIApplication.sharedApplication.delegate
|
5
|
+
@left = LeftNavScreen.new
|
6
|
+
@right = RightNavScreen.new
|
7
|
+
@content = BlankScreen.new
|
8
|
+
end
|
9
|
+
|
10
|
+
describe "#show" do
|
11
|
+
it "presents the menu controller when requested" do
|
12
|
+
menu = ProMotion::Menu::Drawer.new @content, left: @left
|
13
|
+
menu.show(:left)
|
14
|
+
wait(0.5) { menu.openSide.should == MMDrawerSideLeft }
|
15
|
+
end
|
16
|
+
|
17
|
+
it "presents the menu controller without animation when requested" do
|
18
|
+
menu = ProMotion::Menu::Drawer.new @content, left: @left
|
19
|
+
menu.show(:left, false)
|
20
|
+
wait(0.1) { menu.openSide.should == MMDrawerSideLeft }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#hide" do
|
25
|
+
it "presents the content controller when requested" do
|
26
|
+
menu = ProMotion::Menu::Drawer.new @content, left: @left
|
27
|
+
menu.hide
|
28
|
+
wait(0.5) { menu.openSide.should == MMDrawerSideNone }
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "#toggle" do
|
33
|
+
before do
|
34
|
+
@menu = ProMotion::Menu::Drawer.new @content, left: @left, right: @right
|
35
|
+
end
|
36
|
+
|
37
|
+
describe "from left" do
|
38
|
+
it "opens the menu " do
|
39
|
+
@menu.toggle(:left)
|
40
|
+
wait 0.25 do
|
41
|
+
@menu.openSide.should == MMDrawerSideLeft
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
it "closes the menu" do
|
46
|
+
@menu.show(:left)
|
47
|
+
wait 0.25 do
|
48
|
+
|
49
|
+
@menu.openSide.should == MMDrawerSideLeft
|
50
|
+
@menu.toggle(:left)
|
51
|
+
|
52
|
+
wait 0.25 do
|
53
|
+
@menu.openSide.should == MMDrawerSideNone
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
describe "from right" do
|
60
|
+
it "opens the menu" do
|
61
|
+
@menu.toggle(:right)
|
62
|
+
wait 0.25 do
|
63
|
+
@menu.openSide.should == MMDrawerSideRight
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
it "closes the menu" do
|
68
|
+
@menu.show(:right)
|
69
|
+
wait 0.25 do
|
70
|
+
|
71
|
+
@menu.openSide.should == MMDrawerSideRight
|
72
|
+
@menu.toggle(:right)
|
73
|
+
|
74
|
+
wait 0.25 do
|
75
|
+
@menu.openSide.should == MMDrawerSideNone
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
metadata
ADDED
@@ -0,0 +1,126 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ProMotion-menu
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.beta1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Matt Brewer
|
8
|
+
- Ryan Linton
|
9
|
+
- Jamon Holmgren
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2014-08-27 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: motion-cocoapods
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - ">="
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '0'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: ProMotion
|
31
|
+
requirement: !ruby/object:Gem::Requirement
|
32
|
+
requirements:
|
33
|
+
- - "~>"
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: '2'
|
36
|
+
type: :runtime
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: !ruby/object:Gem::Requirement
|
39
|
+
requirements:
|
40
|
+
- - "~>"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '2'
|
43
|
+
- !ruby/object:Gem::Dependency
|
44
|
+
name: rake
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: motion-stump
|
59
|
+
requirement: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
64
|
+
type: :development
|
65
|
+
prerelease: false
|
66
|
+
version_requirements: !ruby/object:Gem::Requirement
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
description: ProMotion DSL integration with MMDrawerController cocoapod providing
|
72
|
+
a left and/or right 'slide' out menu complete with gestures for reveal/hide.
|
73
|
+
email:
|
74
|
+
- matt.brewer@me.com
|
75
|
+
- ryanl@clearsightstudio.com
|
76
|
+
- jamon@clearsightstudio.com
|
77
|
+
executables: []
|
78
|
+
extensions: []
|
79
|
+
extra_rdoc_files: []
|
80
|
+
files:
|
81
|
+
- README.md
|
82
|
+
- lib/ProMotion-menu.rb
|
83
|
+
- lib/ProMotion/menu/delegate.rb
|
84
|
+
- lib/ProMotion/menu/drawer.rb
|
85
|
+
- lib/ProMotion/menu/gestures.rb
|
86
|
+
- lib/ProMotion/menu/version.rb
|
87
|
+
- lib/ProMotion/menu/visibility.rb
|
88
|
+
- spec/app_delegate_spec.rb
|
89
|
+
- spec/drawer_spec.rb
|
90
|
+
- spec/gestures_spec.rb
|
91
|
+
- spec/helpers/blank_screen.rb
|
92
|
+
- spec/helpers/left_nav_screen.rb
|
93
|
+
- spec/helpers/right_nav_screen.rb
|
94
|
+
- spec/visibility_spec.rb
|
95
|
+
homepage: https://github.com/clearsightstudio/ProMotion-menu
|
96
|
+
licenses:
|
97
|
+
- MIT
|
98
|
+
metadata: {}
|
99
|
+
post_install_message:
|
100
|
+
rdoc_options: []
|
101
|
+
require_paths:
|
102
|
+
- lib
|
103
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - ">="
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0'
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">"
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: 1.3.1
|
113
|
+
requirements: []
|
114
|
+
rubyforge_project:
|
115
|
+
rubygems_version: 2.2.2
|
116
|
+
signing_key:
|
117
|
+
specification_version: 4
|
118
|
+
summary: Provides a facebook/Path style slide menu for ProMotion RubyMotion apps.
|
119
|
+
test_files:
|
120
|
+
- spec/app_delegate_spec.rb
|
121
|
+
- spec/drawer_spec.rb
|
122
|
+
- spec/gestures_spec.rb
|
123
|
+
- spec/helpers/blank_screen.rb
|
124
|
+
- spec/helpers/left_nav_screen.rb
|
125
|
+
- spec/helpers/right_nav_screen.rb
|
126
|
+
- spec/visibility_spec.rb
|