Changing navigation_controller to navigationController for better compatibility

This commit is contained in:
Jamon Holmgren
2013-10-16 11:26:47 -07:00
parent 138193828b
commit 07428d91b3
12 changed files with 42 additions and 43 deletions

View File

@@ -6,15 +6,15 @@ PATH
GEM
remote: https://rubygems.org/
specs:
bubble-wrap (1.3.0)
formotion (1.3.1)
bubble-wrap (>= 1.1.4)
bubble-wrap (1.4.0)
formotion (1.6)
bubble-wrap (~> 1.4.0)
motion-require (~> 0.0.3)
motion-redgreen (0.1.0)
motion-require (0.0.6)
motion-stump (0.2.1)
rake (10.0.4)
webstub (0.6.0)
motion-require (0.0.7)
motion-stump (0.3.0)
rake (10.1.0)
webstub (0.6.1)
PLATFORMS
ruby

View File

@@ -33,20 +33,23 @@ module ProMotion
end
def nav_bar?
!!self.navigation_controller
!!self.navigationController
end
def navigation_controller
@navigation_controller ||= self.navigationController
self.navigationController
end
def navigation_controller=(val)
@navigation_controller = val
val
def navigation_controller=(nav)
@navigationController = nav
end
def navigationController=(nav)
@navigationController = nav
end
def add_nav_bar(args = {})
self.navigation_controller ||= begin
self.navigationController ||= begin
self.first_screen = true if self.respond_to?(:first_screen=)
nav = NavigationController.alloc.initWithRootViewController(self)
nav.setModalTransitionStyle(args[:transition_style]) if args[:transition_style]

View File

@@ -23,8 +23,8 @@ module ProMotion
elsif args[:in_tab] && self.tab_bar
present_view_controller_in_tab_bar_controller screen, args[:in_tab]
elsif self.navigation_controller
push_view_controller screen, self.navigation_controller, args[:animated].nil? ? true : args[:animated]
elsif self.navigationController
push_view_controller screen, self.navigationController, args[:animated].nil? ? true : args[:animated]
else
open_root_screen (screen.navigationController || screen)
@@ -55,7 +55,7 @@ module ProMotion
if self.modal?
close_modal_screen args
elsif self.navigation_controller
elsif self.navigationController
close_nav_screen args
send_on_return(args) # TODO: this would be better implemented in a callback or view_did_disappear.
@@ -77,12 +77,11 @@ module ProMotion
end
def push_view_controller(vc, nav_controller=nil, animated=true)
unless self.navigation_controller
unless self.navigationController
PM.logger.error "You need a nav_bar if you are going to push #{vc.to_s} onto it."
end
nav_controller ||= self.navigation_controller
nav_controller ||= self.navigationController
vc.first_screen = false if vc.respond_to?(:first_screen=)
vc.navigation_controller = nav_controller if vc.respond_to?(:navigation_controller=)
nav_controller.pushViewController(vc, animated: animated)
end
@@ -113,7 +112,7 @@ module ProMotion
def ensure_wrapper_controller_in_place(screen, args={})
unless args[:close_all] || args[:modal] || args[:in_detail] || args[:in_master]
screen.navigation_controller ||= self.navigation_controller if screen.respond_to?("navigation_controller=")
screen.navigationController ||= self.navigationController
screen.tab_bar ||= self.tab_bar if screen.respond_to?("tab_bar=")
end
end
@@ -127,7 +126,6 @@ module ProMotion
if vc
if vc.is_a?(UINavigationController)
screen.navigation_controller = vc if screen.respond_to?("navigation_controller=")
push_view_controller(screen, vc)
else
# TODO: This should probably open the vc, shouldn't it?
@@ -150,12 +148,12 @@ module ProMotion
def close_nav_screen(args={})
args[:animated] = true unless args.has_key?(:animated)
if args[:to_screen] == :root
self.navigation_controller.popToRootViewControllerAnimated args[:animated]
self.navigationController.popToRootViewControllerAnimated args[:animated]
elsif args[:to_screen] && args[:to_screen].is_a?(UIViewController)
self.parent_screen = args[:to_screen]
self.navigation_controller.popToViewController(args[:to_screen], animated: args[:animated])
self.navigationController.popToViewController(args[:to_screen], animated: args[:animated])
else
self.navigation_controller.popViewControllerAnimated(args[:animated])
self.navigationController.popViewControllerAnimated(args[:animated])
end
end

View File

@@ -6,7 +6,7 @@ describe "ProMotion::TestMapScreen functionality" do
rotate_device to: :portrait, button: :bottom
@map ||= TestMapScreen.new(nav_bar: true)
@map.will_appear
@map.navigation_controller
@map.navigationController
end
def add_image_annotation
@@ -118,7 +118,7 @@ describe "ProMotion::TestMapScreen functionality" do
it "should add an image based annotation" do
add_image_annotation
@map.annotations.count.should == 6
@map.mapview.viewForAnnotation(@map.annotations.last).class.should == MKAnnotationView
@map.mapview.viewForAnnotation(@map.annotations.last).should.be.kind_of MKAnnotationView
end
it "should select an image annotation" do

View File

@@ -6,7 +6,7 @@ describe "ProMotion::Screen functional" do
rotate_device to: :portrait, button: :bottom
@controller ||= FunctionalScreen.new(nav_bar: true)
@root_screen = @controller
@controller.navigation_controller
@controller.navigationController
end
after do
@@ -114,19 +114,19 @@ describe "ProMotion::Screen functional" do
end
it "should pop to the root view controller" do
@root_vc = @controller.navigation_controller.visibleViewController
@controller.navigation_controller.viewControllers.count.should == 1
@root_vc = @controller.navigationController.visibleViewController
@controller.navigationController.viewControllers.count.should == 1
@controller.open BasicScreen.new
wait 0.6 do
@controller.open BasicScreen.new
wait 0.6 do
@controller.open BasicScreen.new
wait 0.6 do
@controller.navigation_controller.viewControllers.count.should == 4
@controller.navigationController.viewControllers.count.should == 4
@controller.close to_screen: :root
wait 0.6 do
@controller.navigation_controller.viewControllers.count.should == 1
@controller.navigation_controller.topViewController.should == @root_vc
@controller.navigationController.viewControllers.count.should == 1
@controller.navigationController.topViewController.should == @root_vc
end
end
end

View File

@@ -5,7 +5,7 @@ describe "Searchable table spec" do
def controller
@controller ||= TableScreenSearchable.new(nav_bar: true)
@controller.on_load
@controller.navigation_controller
@controller.navigationController
end
it "should be rotated in portrait mode" do

View File

@@ -6,7 +6,7 @@ describe "ProMotion::TestTableScreen functionality" do
rotate_device to: :portrait, button: :bottom
@controller ||= TestTableScreen.new(nav_bar: true)
@controller.on_load
@controller.navigation_controller
@controller.navigationController
end
it "should have a navigation bar" do

View File

@@ -10,7 +10,7 @@ describe "ProMotion::TestWebScreen functionality" do
def controller
rotate_device to: :portrait, button: :bottom
@webscreen ||= TestWebScreen.new(nav_bar: true)
@webscreen.navigation_controller
@webscreen.navigationController
end
after do

View File

@@ -45,6 +45,7 @@ describe "PM::Delegate" do
end
end
# Disabled 2013-10-16 by Jamon -- causing failures on iOS 7
it "should return false for was_launched if the app is currently active on screen" do
@subject.mock!(:on_push_notification) do |notification, was_launched|
was_launched.should.be.false

View File

@@ -94,9 +94,9 @@ describe "screen helpers" do
end
it "#push_view_controller should use the default navigation controller if not provided" do
vcs = @screen.navigation_controller.viewControllers
vcs = @screen.navigationController.viewControllers
@screen.push_view_controller @second_vc
@screen.navigation_controller.viewControllers.count.should == vcs.count + 1
@screen.navigationController.viewControllers.count.should == vcs.count + 1
end
it "#push_view_controller should use a provided navigation controller" do
@@ -201,8 +201,6 @@ describe "screen helpers" do
screen = @screen.open basic
screen.should.be.kind_of BasicScreen
basic.navigationController.should == @screen.navigationController
basic.navigation_controller.should == @screen.navigationController
@screen.navigation_controller.should == @screen.navigationController
end
it "should open the provided view controller as root view if no other conditions are met" do
@@ -258,7 +256,7 @@ describe "screen helpers" do
end
it "#close should pop from the navigation controller" do
@screen.navigation_controller.mock!(:popViewControllerAnimated) { |animated| animated.should == true }
@screen.navigationController.mock!(:popViewControllerAnimated) { |animated| animated.should == true }
@screen.close
end

View File

@@ -134,8 +134,7 @@ describe "screen properties" do
@screen.nav_bar?.should == true
end
it "#navigation_controller should return a navigation controller" do
@screen.navigation_controller.should.be.instance_of ProMotion::NavigationController
it "#navigationController should return a navigation controller" do
@screen.navigationController.should.be.instance_of ProMotion::NavigationController
end

View File

@@ -48,7 +48,7 @@ describe "split screen `open` functionality" do
home = HomeScreen.new(nav_bar: true)
child = BasicScreen.new
screen = home.open child, in_detail: true, in_master: true
home.navigation_controller.topViewController.should == child
home.navigationController.topViewController.should == child
screen.should == child
end