lib/ProMotion/_modules/ScreenNavigation.rb in ProMotion-0.2.0 vs lib/ProMotion/_modules/ScreenNavigation.rb in ProMotion-0.3.0
- old
+ new
@@ -22,28 +22,30 @@
fresh_start(screen)
elsif args[:modal]
self.view_controller.presentModalViewController(screen.main_controller, animated:true)
elsif args[:in_tab] && self.tab_bar
vc = open_tab(args[:in_tab])
- $stderr.puts "Found a #{vc.to_s}"
+ # $stderr.puts "Found a #{vc.to_s}"
if vc
- if vc.is_a? UINavigationController
+ if vc.is_a?(UINavigationController)
+ screen.navigation_controller = vc
push_view_controller(screen.view_controller, vc)
else
self.tab_bar.selectedIndex = vc.tabBarItem.tag
$stderr.puts "#{self.tab_bar.selectedIndex} is selected and should be #{vc.tabBarItem.tag}"
# PM::TabBar.replace_current_item(self.tab_bar, view_controller: screen.view_controller)
+ # TODO: This doesn't work yet.
end
else
$stderr.puts "No tab bar item '#{args[:in_tab]}'"
end
elsif self.navigation_controller
push_view_controller screen.view_controller
else
open_view_controller screen.main_controller
end
-
+
if screen.respond_to?(:on_opened)
screen.send(:on_opened)
end
end
@@ -70,12 +72,18 @@
self.navigation_controller.popViewControllerAnimated(true)
end
else
Console.log("Tried to close #{self.to_s}; however, this screen isn't modal or in a nav bar.", withColor: Console::PURPLE_COLOR)
end
-
- previous_screen.send(:on_return, args) if previous_screen && previous_screen.respond_to?(:on_return)
+
+ if previous_screen && previous_screen.respond_to?(:on_return)
+ if args
+ previous_screen.send(:on_return, args)
+ else
+ previous_screen.send(:on_return)
+ end
+ end
end
def tab_bar_controller(*screens)
tab_bar_controller = UITabBarController.alloc.init
@@ -119,10 +127,9 @@
tab_bar
end
def open_tab(tab)
if tab.is_a? String
- $stderr.puts "Opening tab in #{self.tab_bar.to_s} : #{tab}"
return PM::TabBar.select(self.tab_bar, title: tab)
else
$stderr.puts "Unable to open tab #{tab.to_s} because it isn't a string."
end
end
\ No newline at end of file