lib/ProMotion/screen_helpers/screen_navigation.rb in ProMotion-0.5.2 vs lib/ProMotion/screen_helpers/screen_navigation.rb in ProMotion-0.6.0
- old
+ new
@@ -1,17 +1,20 @@
module ProMotion
module ScreenNavigation
def open_screen(screen, args = {})
-
+
# Apply properties to instance
screen = setup_screen_for_open(screen, args)
ensure_wrapper_controller_in_place(screen, args)
- screen.send(:on_load) if screen.respond_to?(:on_load)
+ screen.send(:on_load) if screen.respond_to?(:on_load)
animated = args[:animated] || true
+ return self.split_screen.detail_screen = screen if args[:in_detail] && self.split_screen
+ return self.split_screen.master_screen = screen if args[:in_master] && self.split_screen
+
if args[:close_all]
open_root_screen screen
elsif args[:modal]
present_modal_view_controller screen, animated
@@ -34,32 +37,29 @@
alias :open :open_screen
def open_root_screen(screen)
app_delegate.open_root_screen(screen)
end
- alias :fresh_start :open_root_screen
def app_delegate
UIApplication.sharedApplication.delegate
end
-
- # TODO: De-uglify this method.
+
def close_screen(args = {})
args ||= {}
args[:animated] ||= true
-
- # Pop current view, maybe with arguments, if in navigation controller
+
if self.is_modal?
close_modal_screen args
elsif self.navigation_controller
close_nav_screen args
send_on_return(args) # TODO: this would be better implemented in a callback or view_did_disappear.
else
- Console.log("Tried to close #{self.to_s}; however, this screen isn't modal or in a nav bar.", withColor: Console::PURPLE_COLOR)
-
+ PM.logger.warn "Tried to close #{self.to_s}; however, this screen isn't modal or in a nav bar."
+
end
end
alias :close :close_screen
def send_on_return(args = {})
@@ -67,27 +67,26 @@
if args
self.parent_screen.send(:on_return, args)
else
self.parent_screen.send(:on_return)
end
- ProMotion::Screen.current_screen = self.parent_screen
end
end
def open_view_controller(vc)
app_delegate.load_root_view vc
end
def push_view_controller(vc, nav_controller=nil)
- Console.log(" You need a nav_bar if you are going to push #{vc.to_s} onto it.", withColor: Console::RED_COLOR) unless self.navigation_controller
+ unless self.navigation_controller
+ 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
+ vc.first_screen = false if vc.respond_to?(:first_screen=)
nav_controller.pushViewController(vc, animated: true)
end
-
-
-
protected
def setup_screen_for_open(screen, args={})
# Instantiate screen if given a class
@@ -95,11 +94,11 @@
# Set parent, title & modal properties
screen.parent_screen = self if screen.respond_to?("parent_screen=")
screen.title = args[:title] if args[:title] && screen.respond_to?("title=")
screen.modal = args[:modal] if args[:modal] && screen.respond_to?("modal=")
-
+
# Hide bottom bar?
screen.hidesBottomBarWhenPushed = args[:hide_tab_bar] == true
# Wrap in a PM::NavigationController?
screen.add_nav_bar if args[:nav_bar] && screen.respond_to?(:add_nav_bar)
@@ -132,10 +131,10 @@
else
self.tab_bar.selectedIndex = vc.tabBarItem.tag
end
else
- Console.log("No tab bar item '#{tab_name}'", with_color: Console::RED_COLOR)
+ PM.logger.error "No tab bar item '#{tab_name}'"
end
end
def close_modal_screen(args={})
args[:animated] ||= true