lib/ProMotion/screen/screen_module.rb in ProMotion-2.4.2 vs lib/ProMotion/screen/screen_module.rb in ProMotion-2.5.0.beta1
- old
+ new
@@ -3,19 +3,20 @@
include ProMotion::Support
include ProMotion::ScreenNavigation
include ProMotion::Styling
include ProMotion::NavBarModule
include ProMotion::Tabs
- include ProMotion::SplitScreen if UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad
+ include ProMotion::SplitScreen if UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad || (UIDevice.currentDevice.systemVersion.to_i >= 8 )
attr_accessor :parent_screen, :first_screen, :modal, :split_screen
def screen_init(args = {})
+ @screen_options = args
check_ancestry
resolve_title
apply_properties(args)
- add_nav_bar(args) if args[:nav_bar]
+ add_nav_bar(args)
add_nav_bar_buttons
tab_bar_setup
try :on_init
try :screen_setup
mp "In #{self.class.to_s}, #on_create has been deprecated and removed. Use #screen_init instead.", force_color: :yellow if respond_to?(:on_create)
@@ -36,10 +37,11 @@
def view_did_load
self.send(:on_load) if self.respond_to?(:on_load)
end
def view_will_appear(animated)
+ super
resolve_status_bar
self.will_appear
self.will_present if isMovingToParentViewController
end
@@ -68,10 +70,22 @@
self.on_dismiss if isMovingFromParentViewController
end
def on_disappear; end
def on_dismiss; end
+ def did_receive_memory_warning
+ self.on_memory_warning
+ end
+ def on_memory_warning
+ mp "Received memory warning in #{self.inspect}. You should implement on_memory_warning in your secreen.", force_color: :red
+ end
+
+ def on_live_reload
+ self.view.subviews.each(&:removeFromSuperview)
+ on_load
+ end
+
def should_rotate(orientation)
case orientation
when UIInterfaceOrientationPortrait
return supported_orientation?("UIInterfaceOrientationPortrait")
when UIInterfaceOrientationLandscapeLeft
@@ -173,10 +187,11 @@
status_bar_style UIStatusBarStyleLightContent
when :dark
status_bar_hidden false
status_bar_style UIStatusBarStyleDefault
else
+ return status_bar_hidden true if UIApplication.sharedApplication.isStatusBarHidden
status_bar_hidden false
global_style = NSBundle.mainBundle.objectForInfoDictionaryKey("UIStatusBarStyle")
status_bar_style global_style ? Object.const_get(global_style) : UIStatusBarStyleDefault
end
end
@@ -216,11 +231,11 @@
mp "You're trying to set the title of #{self.to_s} to an instance of #{t.class.to_s}. In ProMotion 2+, you must use `title_image` or `title_view` instead.", force_color: :yellow
return raise StandardError
end
@title = t if t
@title_type = :text if t
- @title ||= self.to_s
+ @title
end
def title_type
@title_type || :text
end
@@ -247,9 +262,17 @@
@status_bar_style || :default
end
def status_bar_animation
@status_bar_animation || UIStatusBarAnimationSlide
+ end
+
+ def nav_bar(enabled, args={})
+ @nav_bar_args = ({ nav_bar: enabled }).merge(args)
+ end
+
+ def get_nav_bar
+ @nav_bar_args ||= { nav_bar: false }
end
def nav_bar_button(side, args={})
@nav_bar_button_args = args
@nav_bar_button_args[:side] = side