lib/ProMotion/delegate/delegate_module.rb in ProMotion-1.2.1 vs lib/ProMotion/delegate/delegate_module.rb in ProMotion-2.0.0.rc1
- old
+ new
@@ -1,67 +1,62 @@
-motion_require '../containers/tabs'
-motion_require '../containers/split_screen'
-motion_require 'delegate_notifications'
-
module ProMotion
module DelegateModule
include ProMotion::Tabs
include ProMotion::SplitScreen if UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad
- include ProMotion::DelegateNotifications
- attr_accessor :window, :aps_notification, :home_screen
+ attr_accessor :window, :home_screen
def application(application, willFinishLaunchingWithOptions:launch_options)
will_load(application, launch_options) if respond_to?(:will_load)
true
end
def application(application, didFinishLaunchingWithOptions:launch_options)
apply_status_bar
on_load application, launch_options
- check_for_push_notification launch_options
+ # Requires 'ProMotion-push' gem.
+ check_for_push_notification(launch_options) if respond_to?(:check_for_push_notification)
super rescue true # Can cause error message if no super is found, but it's harmless. Ignore.
end
def applicationDidBecomeActive(application)
- on_activate if respond_to?(:on_activate)
+ try :on_activate
end
def applicationWillResignActive(application)
- will_deactivate if respond_to?(:will_deactivate)
+ try :will_deactivate
end
def applicationDidEnterBackground(application)
- on_enter_background if respond_to?(:on_enter_background)
+ try :on_enter_background
end
def applicationWillEnterForeground(application)
- will_enter_foreground if respond_to?(:will_enter_foreground)
+ try :will_enter_foreground
end
def applicationWillTerminate(application)
- on_unload if respond_to?(:on_unload)
+ try :on_unload
end
def application(application, openURL: url, sourceApplication:source_app, annotation: annotation)
- on_open_url({ url: url, source_app: source_app, annotation: annotation }) if respond_to?(:on_open_url)
+ try :on_open_url, { url: url, source_app: source_app, annotation: annotation }
end
def app_delegate
self
end
def app_window
- self.window
+ window
end
def ui_window
(defined?(Motion) && defined?(Motion::Xray) && defined?(Motion::Xray::XrayWindow)) ? Motion::Xray::XrayWindow : UIWindow
end
- def open_screen(screen, args={})
-
+ def open(screen, args={})
screen = screen.new if screen.respond_to?(:new)
self.home_screen = screen
self.window ||= self.ui_window.alloc.initWithFrame(UIScreen.mainScreen.bounds)
@@ -69,22 +64,29 @@
self.window.tintColor = self.class.send(:get_tint_color) if self.window.respond_to?("tintColor=")
self.window.makeKeyAndVisible
screen
end
- alias :open :open_screen
+ alias :open_screen :open
alias :open_root_screen :open_screen
- alias :home :open_screen
+ def status_bar?
+ UIApplication.sharedApplication.statusBarHidden
+ end
+
+ private
+
def apply_status_bar
self.class.send(:apply_status_bar)
end
- def status_bar?
- UIApplication.sharedApplication.statusBarHidden
+ def try(method, *args)
+ send(method, *args) if respond_to?(method)
end
+ public
+
module ClassMethods
def status_bar(visible = true, opts={})
@status_bar_visible = visible
@status_bar_opts = opts
@@ -105,12 +107,14 @@
end
def tint_color(c)
@tint_color = c
end
+
def tint_color=(c)
@tint_color = c
end
+
def get_tint_color
@tint_color || nil
end
end