Merge branch 'master' into version-0.7

This commit is contained in:
Jamon Holmgren
2013-05-20 09:40:30 -07:00
14 changed files with 47 additions and 33 deletions

View File

@@ -1,7 +1,7 @@
PATH
remote: .
specs:
ProMotion (0.6.1)
ProMotion (0.6.2)
GEM
remote: https://rubygems.org/

View File

@@ -84,13 +84,12 @@ Create a new RubyMotion project.
`motion create myapp`
Open it in your favorite editor, then go into your Rakefile and add the following to the top:
Open it in your favorite editor, then go into your Rakefile and modify the top to look like the following:
```ruby
# -*- coding: utf-8 -*-
$:.unshift("/Library/RubyMotion/lib")
require 'motion/project'
require "rubygems"
require 'motion/project/template/ios'
require 'bundler'
Bundler.require
```
@@ -100,7 +99,7 @@ Create a Gemfile and add the following lines:
```ruby
source 'https://rubygems.org'
gem "ProMotion", "~> 0.6.0"
gem "ProMotion", "~> 0.6.2"
```
Run `bundle install` in Terminal to install ProMotion.

View File

@@ -1,12 +1,11 @@
$:.unshift("/Library/RubyMotion/lib")
require 'motion/project/template/ios'
require 'bundler/gem_tasks'
Bundler.setup
require 'bundler'
Bundler.require
Motion::Project::App.setup do |app|
app.name = 'ProMotionTest'
app.version = "0.99.0" # I've got 99 problems and the test app's version isn't one of them
app.version = "0.99.0"
app.redgreen_style = :focused # :focused, :full
# Devices

View File

@@ -8,16 +8,14 @@ class SplitViewController < UISplitViewController
s.respond_to?(:visibleViewController) ? s.visibleViewController : s
end
def master_screen=(s)
self.viewControllers = [s.main_controller, self.viewControllers.last]
self.viewControllers = [s.pm_main_controller, self.viewControllers.last]
end
def detail_screen=(s)
# set the button from the old detail screen to the new one
button = detail_screen.navigationItem.leftBarButtonItem
s.navigationItem.leftBarButtonItem = button
vc = s.respond_to?(:main_controller) ? s.main_controller : s
self.viewControllers = [self.viewControllers.first, vc]
self.viewControllers = [self.viewControllers.first, s.pm_main_controller]
end
def screens=(s_array)
self.viewControllers = s_array

View File

@@ -28,7 +28,7 @@ module ProMotion
end
def load_root_screen(new_screen)
new_screen = new_screen.main_controller if new_screen.respond_to?(:main_controller)
new_screen = new_screen.pm_main_controller
self.window ||= self.ui_window.alloc.initWithFrame(UIScreen.mainScreen.bounds)
self.window.rootViewController = new_screen

View File

@@ -29,7 +29,7 @@ module ProMotion
push_view_controller screen
else
open_root_screen screen
open_root_screen screen.pm_main_controller
end
@@ -121,9 +121,7 @@ module ProMotion
end
def present_modal_view_controller(screen, animated)
vc = screen
vc = screen.main_controller if screen.respond_to?(:main_controller)
self.presentModalViewController(vc, animated:animated)
self.presentModalViewController(screen.pm_main_controller, animated:animated)
end
def present_view_controller_in_tab_bar_controller(screen, tab_name)

View File

@@ -16,8 +16,7 @@ module ProMotion
s.parent_screen = self if self.is_a?(UIViewController) && s.respond_to?("parent_screen=")
s.tab_bar = tab_bar_controller if s.respond_to?("tab_bar=")
vc = s.respond_to?(:main_controller) ? s.main_controller : s
view_controllers << vc
view_controllers << s.pm_main_controller
tag_index += 1

View File

@@ -146,10 +146,6 @@ module ProMotion
end
def on_disappear; end
def main_controller
self.navigation_controller || self
end
def view_controller
warn "[DEPRECATION] `view_controller` is deprecated, as screens are now UIViewController subclasses."
self

View File

@@ -0,0 +1,10 @@
module ProMotion
module BehavesLikeScreen
def pm_main_controller
navigationController || self
end
alias_method :main_controller, :pm_main_controller
end
end
UIViewController.send :include, ProMotion::BehavesLikeScreen

View File

@@ -1,3 +1,3 @@
module ProMotion
VERSION = "0.6.1" unless defined?(ProMotion::VERSION)
VERSION = "0.6.2" unless defined?(ProMotion::VERSION)
end

View File

@@ -97,6 +97,21 @@ describe "screen properties" do
end
describe "pm_main_controller" do
it "should return the navigation controller wrapper" do
@screen.pm_main_controller.should.be.instance_of ProMotion::NavigationController
end
it "should return itself when screen is a plain UIViewController" do
vc = UIViewController.alloc.initWithNibName(nil, bundle: nil)
vc.respond_to?(:pm_main_controller).should == true
vc.pm_main_controller.should == vc
end
end
describe "navigation controller behavior" do
it "should have a nav bar" do

View File

@@ -38,12 +38,12 @@ describe "split screen in tab bar functionality" do
it "should set the first viewController to HomeScreen's main controller" do
@split_screen.master_screen.should == @master_screen
@split_screen.viewControllers.first.should == @master_screen.main_controller
@split_screen.viewControllers.first.should == @master_screen.pm_main_controller
end
it "should set the second viewController to BasicScreen's main controller" do
@split_screen.detail_screen.should == @detail_screen
@split_screen.viewControllers.last.should == @detail_screen.main_controller
@split_screen.viewControllers.last.should == @detail_screen.pm_main_controller
end
it "should set the tab bar first viewController to the split screen" do

View File

@@ -17,15 +17,15 @@ describe "split screen `open` functionality" do
it "should open a new screen in the detail view" do
@master_screen.open @detail_screen_2, in_detail: true
@split_screen.detail_screen.should == @detail_screen_2
@split_screen.viewControllers.first.should == @master_screen.main_controller
@split_screen.viewControllers.last.should == @detail_screen_2.main_controller
@split_screen.viewControllers.first.should == @master_screen.pm_main_controller
@split_screen.viewControllers.last.should == @detail_screen_2.pm_main_controller
end
it "should open a new screen in the master view" do
@detail_screen_1.open @detail_screen_2, in_master: true
@split_screen.master_screen.should == @detail_screen_2
@split_screen.viewControllers.first.should == @detail_screen_2.main_controller
@split_screen.viewControllers.last.should == @detail_screen_1.main_controller
@split_screen.viewControllers.first.should == @detail_screen_2.pm_main_controller
@split_screen.viewControllers.last.should == @detail_screen_1.pm_main_controller
end
it "should open a new screen in the master view's navigation controller" do
@@ -37,7 +37,7 @@ describe "split screen `open` functionality" do
it "should open a new modal screen in the detail view" do
@detail_screen_1.open @detail_screen_2, modal: true
@split_screen.detail_screen.should == @detail_screen_1
@detail_screen_1.presentedViewController.should == @detail_screen_2.main_controller
@detail_screen_1.presentedViewController.should == @detail_screen_2.pm_main_controller
end
it "should not interfere with normal non-split screen navigation" do

View File

@@ -28,12 +28,12 @@ describe "split screen functionality" do
it "should set the first viewController to MasterScreen" do
@split_screen.master_screen.should == @master_screen
@split_screen.viewControllers.first.should == @master_screen.main_controller
@split_screen.viewControllers.first.should == @master_screen.pm_main_controller
end
it "should set the second viewController to DetailScreen" do
@split_screen.detail_screen.should == @detail_screen
@split_screen.viewControllers.last.should == @detail_screen.main_controller
@split_screen.viewControllers.last.should == @detail_screen.pm_main_controller
end
it "should set the title on both screens" do