pro_motion_slide_menu 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ pkg/
2
+ *.gem
3
+ .DS_Store
4
+ /build/
5
+ .repl_history
6
+ vendor/Pods/
data/Gemfile ADDED
@@ -0,0 +1,7 @@
1
+ source :rubygems
2
+
3
+ gemspec
4
+ gem 'bubble-wrap'
5
+ gem 'motion-cocoapods'
6
+ gem 'ProMotion', '>= 0.5.2'
7
+ gem 'pro_motion_slide_menu', :path => '.'
data/Gemfile.lock ADDED
@@ -0,0 +1,64 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ pro_motion_slide_menu (0.0.1)
5
+ ProMotion (~> 0.5)
6
+ bubble-wrap
7
+ motion-cocoapods
8
+
9
+ GEM
10
+ remote: http://rubygems.org/
11
+ specs:
12
+ ProMotion (0.5.2)
13
+ activesupport (3.2.13)
14
+ i18n (= 0.6.1)
15
+ multi_json (~> 1.0)
16
+ addressable (2.3.3)
17
+ bubble-wrap (1.1.5)
18
+ cocoapods (0.16.2)
19
+ activesupport (~> 3.2.6)
20
+ colored (~> 1.2)
21
+ escape (~> 0.0.4)
22
+ faraday (~> 0.8.1)
23
+ json (~> 1.7.3)
24
+ octokit (~> 1.7)
25
+ open4 (~> 1.3.0)
26
+ rake (~> 0.9.4)
27
+ xcodeproj (~> 0.4.3)
28
+ colored (1.2)
29
+ escape (0.0.4)
30
+ faraday (0.8.5)
31
+ multipart-post (~> 1.1)
32
+ faraday_middleware (0.9.0)
33
+ faraday (>= 0.7.4, < 0.9)
34
+ hashie (1.2.0)
35
+ i18n (0.6.1)
36
+ json (1.7.7)
37
+ motion-cocoapods (1.2.1)
38
+ cocoapods (>= 0.14.0)
39
+ motion-stump (0.2.1)
40
+ multi_json (1.7.2)
41
+ multipart-post (1.1.5)
42
+ netrc (0.7.7)
43
+ octokit (1.23.0)
44
+ addressable (~> 2.2)
45
+ faraday (~> 0.8)
46
+ faraday_middleware (~> 0.9)
47
+ hashie (~> 1.2)
48
+ multi_json (~> 1.3)
49
+ netrc (~> 0.7.7)
50
+ open4 (1.3.0)
51
+ rake (0.9.6)
52
+ xcodeproj (0.4.3)
53
+ activesupport (~> 3.2.6)
54
+ colored (~> 1.2)
55
+
56
+ PLATFORMS
57
+ ruby
58
+
59
+ DEPENDENCIES
60
+ ProMotion (>= 0.5.2)
61
+ bubble-wrap
62
+ motion-cocoapods
63
+ motion-stump
64
+ pro_motion_slide_menu!
data/README.md ADDED
@@ -0,0 +1,134 @@
1
+ # ProMotion SlideMenu
2
+ This gem provides an easier way to integrate a great open source toolkit, [RubyMotion](http://www.rubymotion.com), with another great Objective-C framework, [PKRevealController](https://github.com/pkluz/PKRevealController), allowing you to easily have a cool facebook or Path style slide navigation menu, complete with gestures.
3
+
4
+ ## Installation
5
+
6
+ ### Bundler
7
+
8
+ Add the following to your project's `Gemfile` to work with bundler.
9
+
10
+ ```ruby
11
+ gem "pro_motion_slide_menu"
12
+ ```
13
+
14
+ Install with bundler:
15
+
16
+ ```ruby
17
+ bundle install
18
+ ```
19
+
20
+ ### Dependenices
21
+ This depends on motion-cocoapods, BubbleWrap and ProMotion.
22
+
23
+ ### Rakefile
24
+
25
+ Currently there is a bug with [motion-cocoapods](https://github.com/HipByte/motion-cocoapods/issues/38) that doesn't allow us to automatically include an ObjC library automatically. Because of this, you will need to edit your Rakefile as follows:
26
+
27
+ ```ruby
28
+ app.pods do
29
+ pod 'PKRevealController'
30
+ end
31
+ ```
32
+
33
+ ## Creating and Configuring a Slide Menu
34
+ To create a slide menu in your application, you need to start in your AppDelegate:
35
+
36
+ ```ruby
37
+ class AppDelegate < ProMotion::AppDelegateParent
38
+
39
+ def on_load(app, options)
40
+
41
+ # Open the slide menu with your navigation view (initially hidden) and a content view (initially shown)
42
+ open_slide_menu NavigationScreen, MyGreatAppScreen.new(nav_bar: true)
43
+
44
+ # You can get to the instance of the slide menu at any time if you need to
45
+ slide_menu.menu_controller.class.name
46
+ # => NavigationScreen
47
+
48
+ # SlideMenuScreen is just an enhanced subclass of PKRevealController, so you can do all sorts of things with it
49
+ slide_menu.disablesFrontViewInteraction = true
50
+ slide_menu.animationDuration = 0.5
51
+ ...
52
+
53
+ end
54
+
55
+ end
56
+ ```
57
+
58
+ ## Toggling the Slide Menu Current Screen
59
+ To make the slide menu present the menu from anywhere in your app:
60
+
61
+ ```ruby
62
+
63
+ # Show the menu
64
+ App.delegate.slide_menu.show_menu
65
+
66
+ # Equivalent to
67
+ App.delegate.slide_menu.showViewController App.delegate.slide_menu.menu_controller, animated: true, completion: ->(c) { true }
68
+
69
+ # Hide the menu
70
+ App.delegate.slide_menu.hide_menu
71
+
72
+ # Equivalent to
73
+ App.delegate.slide_menu.showViewController App.delegate.slide_menu.content_controller, animated: true, completion: ->(c) { true }
74
+
75
+ ```
76
+
77
+ ## Setting up the Menu
78
+ 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:
79
+
80
+ ```ruby
81
+ class NavigationScreen < ProMotion::TableScreen
82
+
83
+ def table_data
84
+ [{
85
+ title: nil,
86
+ cells: [{
87
+ title: 'OVERWRITE THIS METHOD',
88
+ action: :swap_content_controller,
89
+ arguments: HomeScreen
90
+ }]
91
+ }]
92
+ end
93
+
94
+ def swap_content_controller(screen_class)
95
+ App.delegate.slide_menu.content_controller = screen_class
96
+ end
97
+
98
+ end
99
+ ```
100
+
101
+ ## Showing the menu via gesture
102
+ By default, `PKRevealController` supports showing the slide menu via a gesture recognizer. To disable this feature, look at the documentation or use the following:
103
+
104
+ ```ruby
105
+ App.delegate.slide_menu.recognizesPanningOnFrontView = false
106
+ ```
107
+
108
+ ## Creating a UIBarButtonItem to show the menu
109
+ 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:
110
+
111
+ ```ruby
112
+ class MyScreen < ProMotion::Screen
113
+ def on_load
114
+
115
+ # Create a button with a custom bg & image
116
+ swipe_btn = UIButton.custom
117
+ swipe_btn.setBackgroundImage("nav_bar_menu_show_bg".uiimage, forState: :normal.uicontrolstate)
118
+ swipe_btn.setImage("nav_bar_menu_show".uiimage, forState: :normal.uicontrolstate)
119
+ size = "nav_bar_menu_show_bg".uiimage.size
120
+ swipe_btn.frame = CGRectMake(0, 0, size.width, size.height)
121
+
122
+ # Create a Bar button item containing that button
123
+ # When tapping the button, show the menu (uses Sugarcube syntax)
124
+ @left_item = UIBarButtonItem.alloc.initWithCustomView(swipe_btn)
125
+ swipe_btn.on(:touch.uicontrolevent) do
126
+ App.delegate.slide_menu.show_menu
127
+ end
128
+
129
+ # Assign the button item to the navigation item for it to appear in the top left
130
+ self.navigationItem.leftBarButtonItem = @left_item
131
+
132
+ end
133
+ end
134
+ ```
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ $:.unshift('/Library/RubyMotion/lib')
4
+ require 'motion/project'
5
+ require 'bundler'
6
+ Bundler.require
7
+
8
+ Motion::Project::App.setup do |app|
9
+ # Use `rake config' to see complete project settings.
10
+ app.name = 'ProMotionSlideMenu'
11
+ app.delegate_class = 'TestAppDelegate'
12
+
13
+ app.pods do
14
+ pod 'PKRevealController'
15
+ end
16
+ end
@@ -0,0 +1,4 @@
1
+ class TestAppDelegate < ProMotion::AppDelegateParent
2
+ def on_load(app, options)
3
+ end
4
+ end
@@ -0,0 +1,21 @@
1
+ module ProMotionSlideMenu
2
+ module AppDelegate
3
+
4
+ def self.included(base)
5
+ base.send :attr_accessor, :slide_menu
6
+ end
7
+
8
+ def has_slide_menu?
9
+ !slide_menu.nil?
10
+ end
11
+
12
+ def open_slide_menu(menu, content, options={})
13
+ self.slide_menu = SlideMenuScreen.new(menu, content, options)
14
+ load_root_screen slide_menu
15
+ slide_menu
16
+ end
17
+
18
+ end
19
+ end
20
+
21
+ ProMotion::AppDelegateParent.send :include, ProMotionSlideMenu::AppDelegate
@@ -0,0 +1,61 @@
1
+ module ProMotionSlideMenu
2
+ class SlideMenuScreen < PKRevealController
3
+
4
+ include ::ProMotion::ScreenModule
5
+
6
+ #
7
+ # SlideMenuScreen
8
+ #
9
+ # This is added as the root view controller when using the `open_slide_menu` method in your application delegate.
10
+ #
11
+ # Several properties are defined to get the underlying PKRevealController instance for additional configuration, the
12
+ # screen shown as the hidden menu, and the screen shown as the content controller.
13
+ #
14
+
15
+ def self.new(menu, content, options={})
16
+ screen = self.revealControllerWithFrontViewController(nil, leftViewController: nil, options: nil)
17
+ screen.on_create(options) if screen.respond_to?(:on_create)
18
+ screen.menu_controller = menu unless menu.nil?
19
+ screen.content_controller = content unless content.nil?
20
+ screen
21
+ end
22
+
23
+ def show_menu
24
+ self.showViewController menu_controller, animated: true, completion: default_completion_block
25
+ end
26
+
27
+ def hide_menu
28
+ self.showViewController content_controller, animated: true, completion: default_completion_block
29
+ end
30
+
31
+ def menu_controller=(c)
32
+ self.setLeftViewController prepare_controller_for_pm(c).main_controller, focusAfterChange: true, completion: default_completion_block
33
+ end
34
+
35
+ def menu_controller
36
+ self.leftViewController
37
+ end
38
+
39
+ def content_controller=(c)
40
+ self.setFrontViewController prepare_controller_for_pm(c).main_controller, focusAfterChange: true, completion: default_completion_block
41
+ end
42
+
43
+ def content_controller
44
+ self.frontViewController
45
+ end
46
+
47
+
48
+ protected
49
+
50
+ def prepare_controller_for_pm(controller)
51
+ controller = setup_screen_for_open(controller, {})
52
+ ensure_wrapper_controller_in_place(controller, {})
53
+ controller
54
+ end
55
+
56
+ def default_completion_block
57
+ -> (completed) { true }
58
+ end
59
+
60
+ end
61
+ end
@@ -0,0 +1,3 @@
1
+ module ProMotionSlideMenu
2
+ Version = '0.0.1'
3
+ end
@@ -0,0 +1,22 @@
1
+ unless defined?(Motion::Project::Config)
2
+ raise "This file must be required within a RubyMotion project Rakefile."
3
+ end
4
+
5
+ Motion::Project::App.setup do |app|
6
+
7
+ # Add all the files in our lib folder
8
+ # WE ADD THESE AT THE END OF THE FILE LISTING!
9
+ # This way, we can be sure that ProMotion itself has been compiled, but before any of the app's files are compiled.
10
+ Dir.glob(File.join(File.dirname(__FILE__), 'pro_motion_slide_menu/**/*.rb')).each do |file|
11
+ app.files << file
12
+ end
13
+
14
+ # We have a cocoapod that we rely on
15
+ # THIS WON'T WORK until the following issue is resolved with motion-cocoapods
16
+ # https://github.com/HipByte/motion-cocoapods/issues/38
17
+ #
18
+ # app.pods do
19
+ # pod 'PKRevealController'
20
+ # end
21
+
22
+ end
@@ -0,0 +1,22 @@
1
+ require File.expand_path('../lib/pro_motion_slide_menu/version.rb', __FILE__)
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = 'pro_motion_slide_menu'
5
+ s.version = ProMotionSlideMenu::Version
6
+ s.authors = ["Matt Brewer"]
7
+ s.email = 'matt.brewer@me.com'
8
+
9
+ s.summary = "Provides a facebook/Path style slide menu on the left for ProMotion RubyMotion apps."
10
+ s.description = "Provides a facebook/Path style slide menu on the left for ProMotion RubyMotion apps."
11
+
12
+ s.homepage = "https://github.com/macfanatic/pro_motion_slide_menu"
13
+ s.files = `git ls-files`.split($\)
14
+ s.test_files = s.files.grep(%r{^spec/})
15
+ s.require_paths = ['lib']
16
+
17
+ s.add_dependency "bubble-wrap"
18
+ s.add_dependency "motion-cocoapods"
19
+ s.add_dependency "ProMotion", '~> 0.5'
20
+ s.add_development_dependency "motion-stump"
21
+
22
+ end
@@ -0,0 +1,27 @@
1
+ describe ProMotionSlideMenu::AppDelegate do
2
+
3
+ before do
4
+ @delegate = App.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_slide_menu?.should == false
13
+ end
14
+
15
+ it "should respond to 'open_slide_menu'" do
16
+ @delegate.respond_to?(:open_slide_menu).should == true
17
+ end
18
+
19
+ it "#open_slide_menu should return a SlideMenuScreen" do
20
+ @delegate.open_slide_menu(nil, nil).should.be.instance_of ProMotionSlideMenu::SlideMenuScreen
21
+ end
22
+
23
+ it "should have a SlideMenuScreen as the rootViewController" do
24
+ @delegate.window.rootViewController.should.be.instance_of ProMotionSlideMenu::SlideMenuScreen
25
+ end
26
+
27
+ end
@@ -0,0 +1,2 @@
1
+ class BlankScreen < ProMotion::Screen
2
+ end
@@ -0,0 +1,10 @@
1
+ class LeftNavScreen < ProMotion::TableScreen
2
+ def table_data
3
+ [{
4
+ title: nil,
5
+ cells: [{
6
+ title: 'OVERWRITE THIS METHOD'
7
+ }]
8
+ }]
9
+ end
10
+ end
@@ -0,0 +1,50 @@
1
+ describe ProMotionSlideMenu::SlideMenuScreen do
2
+
3
+ before do
4
+ @delegate = App.delegate
5
+ @menu = LeftNavScreen.new
6
+ @content = BlankScreen.new
7
+ end
8
+
9
+ it "should return an instance of SlideMenuScreen" do
10
+ screen = ProMotionSlideMenu::SlideMenuScreen.new nil, nil
11
+ screen.should.be.instance_of ProMotionSlideMenu::SlideMenuScreen
12
+ end
13
+
14
+ it "should store menu & content controllers" do
15
+ screen = ProMotionSlideMenu::SlideMenuScreen.new @menu, @content
16
+ screen.menu_controller.should == @menu
17
+ screen.content_controller.should == @content
18
+ end
19
+
20
+ it "should allow you to pass class instances" do
21
+ screen = ProMotionSlideMenu::SlideMenuScreen.new LeftNavScreen, BlankScreen
22
+ screen.menu_controller.should.be.instance_of LeftNavScreen
23
+ screen.content_controller.should.be.instance_of BlankScreen
24
+ end
25
+
26
+ it "should present the menu controller when requested" do
27
+ screen = ProMotionSlideMenu::SlideMenuScreen.new @menu, @content
28
+ screen.show_menu
29
+ wait(0.5) { screen.focusedController.should == @menu }
30
+ end
31
+
32
+ it "should present the content controller when requested" do
33
+ screen = ProMotionSlideMenu::SlideMenuScreen.new @menu, @content
34
+ screen.hide_menu
35
+ wait(0.5) { screen.focusedController.should == @content }
36
+ end
37
+
38
+ it "should let me wrap the content controller in a UINavigationController" do
39
+ content_controller = BlankScreen.new(nav_bar: true)
40
+ screen = ProMotionSlideMenu::SlideMenuScreen.new @menu, content_controller
41
+ screen.content_controller.should.be.instance_of ProMotion::NavigationController
42
+ end
43
+
44
+ it "should let me set the title on the content controller during creation" do
45
+ content_controller = BlankScreen.new(title: 'My Title')
46
+ screen = ProMotionSlideMenu::SlideMenuScreen.new @menu, content_controller
47
+ screen.content_controller.title.should == 'My Title'
48
+ end
49
+
50
+ end
@@ -0,0 +1,11 @@
1
+
2
+ PODS:
3
+ - PKRevealController (1.0b2)
4
+
5
+ DEPENDENCIES:
6
+ - PKRevealController
7
+
8
+ SPEC CHECKSUMS:
9
+ PKRevealController: 631e6a3db833a0c660203c2dba0963109549ec8a
10
+
11
+ COCOAPODS: 0.16.2
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pro_motion_slide_menu
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Matt Brewer
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-03-29 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bubble-wrap
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
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
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: motion-cocoapods
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: ProMotion
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: '0.5'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '0.5'
62
+ - !ruby/object:Gem::Dependency
63
+ name: motion-stump
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: Provides a facebook/Path style slide menu on the left for ProMotion RubyMotion
79
+ apps.
80
+ email: matt.brewer@me.com
81
+ executables: []
82
+ extensions: []
83
+ extra_rdoc_files: []
84
+ files:
85
+ - .gitignore
86
+ - Gemfile
87
+ - Gemfile.lock
88
+ - README.md
89
+ - Rakefile
90
+ - app/test_app_delegate.rb
91
+ - lib/pro_motion_slide_menu.rb
92
+ - lib/pro_motion_slide_menu/app_delegate.rb
93
+ - lib/pro_motion_slide_menu/slide_menu_screen.rb
94
+ - lib/pro_motion_slide_menu/version.rb
95
+ - pro_motion_slide_menu.gemspec
96
+ - spec/app_delegate_spec.rb
97
+ - spec/helpers/blank_screen.rb
98
+ - spec/helpers/left_nav_screen.rb
99
+ - spec/slide_menu_screen_spec.rb
100
+ - vendor/Podfile.lock
101
+ homepage: https://github.com/macfanatic/pro_motion_slide_menu
102
+ licenses: []
103
+ post_install_message:
104
+ rdoc_options: []
105
+ require_paths:
106
+ - lib
107
+ required_ruby_version: !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ! '>='
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ required_rubygems_version: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 1.8.24
122
+ signing_key:
123
+ specification_version: 3
124
+ summary: Provides a facebook/Path style slide menu on the left for ProMotion RubyMotion
125
+ apps.
126
+ test_files:
127
+ - spec/app_delegate_spec.rb
128
+ - spec/helpers/blank_screen.rb
129
+ - spec/helpers/left_nav_screen.rb
130
+ - spec/slide_menu_screen_spec.rb
131
+ has_rdoc: