ProMotion 1.2.1 → 2.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (99) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +36 -10
  3. data/lib/ProMotion.rb +11 -2
  4. data/lib/ProMotion/cocoatouch/ns_string.rb +5 -0
  5. data/lib/ProMotion/cocoatouch/ns_url.rb +5 -0
  6. data/lib/ProMotion/cocoatouch/tab_bar_controller.rb +5 -7
  7. data/lib/ProMotion/cocoatouch/table_view_cell.rb +0 -16
  8. data/lib/ProMotion/cocoatouch/table_view_controller.rb +2 -3
  9. data/lib/ProMotion/cocoatouch/view_controller.rb +3 -6
  10. data/lib/ProMotion/delegate/delegate.rb +0 -3
  11. data/lib/ProMotion/delegate/delegate_module.rb +24 -20
  12. data/lib/ProMotion/{containers → ipad}/split_screen.rb +30 -32
  13. data/lib/ProMotion/{logger.rb → logger/logger.rb} +6 -5
  14. data/lib/ProMotion/screen/nav_bar_module.rb +126 -0
  15. data/lib/ProMotion/screen/screen.rb +0 -3
  16. data/lib/ProMotion/screen/screen_module.rb +54 -177
  17. data/lib/ProMotion/screen/screen_navigation.rb +29 -40
  18. data/lib/ProMotion/{view → styling}/styling.rb +17 -47
  19. data/lib/ProMotion/table/cell/table_view_cell_module.rb +76 -123
  20. data/lib/ProMotion/table/data/table_data.rb +1 -1
  21. data/lib/ProMotion/table/extensions/longpressable.rb +24 -0
  22. data/lib/ProMotion/table/extensions/refreshable.rb +1 -0
  23. data/lib/ProMotion/table/grouped_table_screen.rb +0 -5
  24. data/lib/ProMotion/table/table.rb +63 -83
  25. data/lib/ProMotion/table/table_screen.rb +0 -4
  26. data/lib/ProMotion/{containers → tabs}/tabs.rb +20 -21
  27. data/lib/ProMotion/version.rb +1 -1
  28. data/lib/ProMotion/web/web_screen.rb +0 -4
  29. data/lib/ProMotion/web/web_screen_module.rb +8 -5
  30. data/spec/functional/func_screen_spec.rb +14 -18
  31. data/spec/functional/func_split_screen_spec.rb +2 -2
  32. data/spec/functional/func_table_screen_spec.rb +54 -40
  33. data/spec/functional/func_web_screen_spec.rb +12 -17
  34. data/spec/helpers/test_helper.rb +27 -0
  35. data/spec/unit/delegate_spec.rb +4 -67
  36. data/spec/unit/image_title_screen.rb +9 -0
  37. data/spec/unit/image_view_title_screen.rb +9 -0
  38. data/spec/unit/load_view_spec.rb +27 -0
  39. data/spec/unit/main_spec.rb +0 -6
  40. data/spec/unit/screen_helpers_spec.rb +23 -17
  41. data/spec/unit/screen_spec.rb +21 -17
  42. data/spec/unit/searchable_table_spec.rb +55 -0
  43. data/spec/unit/split_screen_in_tab_bar_spec.rb +5 -5
  44. data/spec/unit/split_screen_spec.rb +4 -4
  45. data/spec/unit/tab_bar_spec.rb +79 -0
  46. data/spec/unit/tab_spec.rb +11 -5
  47. data/spec/unit/tables/table_module_spec.rb +22 -8
  48. data/spec/unit/tables/table_screen_spec.rb +1 -1
  49. data/spec/unit/tables/table_view_cell_spec.rb +16 -16
  50. data/spec/unit/view_helper_spec.rb +6 -81
  51. data/spec/unit/view_title_screen.rb +10 -0
  52. data/spec/unit/web_spec.rb +31 -37
  53. metadata +37 -111
  54. data/.gitignore +0 -33
  55. data/.travis.yml +0 -4
  56. data/CONTRIBUTING.md +0 -20
  57. data/Gemfile +0 -5
  58. data/LICENSE +0 -22
  59. data/ProMotion.gemspec +0 -30
  60. data/Rakefile +0 -66
  61. data/app/app_delegate.rb +0 -7
  62. data/app/screens/basic_screen.rb +0 -15
  63. data/lib/ProMotion/delegate/delegate_notifications.rb +0 -70
  64. data/lib/ProMotion/extensions/conversions.rb +0 -20
  65. data/lib/ProMotion/map/map_screen.rb +0 -10
  66. data/lib/ProMotion/map/map_screen_annotation.rb +0 -65
  67. data/lib/ProMotion/map/map_screen_module.rb +0 -212
  68. data/lib/ProMotion/push_notification/push_notification.rb +0 -58
  69. data/resources/WebScreen.html +0 -6
  70. data/resources/list.png +0 -0
  71. data/resources/test.png +0 -0
  72. data/spec/functional/func_image_title_screen.rb +0 -20
  73. data/spec/functional/func_image_view_title_screen.rb +0 -20
  74. data/spec/functional/func_map_screen_spec.rb +0 -162
  75. data/spec/functional/func_searchable_table_spec.rb +0 -56
  76. data/spec/functional/func_tab_bar_spec.rb +0 -78
  77. data/spec/functional/func_view_title_screen.rb +0 -21
  78. data/spec/helpers/basic_screen.rb +0 -3
  79. data/spec/helpers/custom_title_view.rb +0 -4
  80. data/spec/helpers/detail_screen.rb +0 -3
  81. data/spec/helpers/dummy_class.rb +0 -3
  82. data/spec/helpers/functional_screen.rb +0 -15
  83. data/spec/helpers/home_screen.rb +0 -19
  84. data/spec/helpers/image_title_screen.rb +0 -15
  85. data/spec/helpers/image_view_title_screen.rb +0 -15
  86. data/spec/helpers/map_screen.rb +0 -53
  87. data/spec/helpers/master_screen.rb +0 -3
  88. data/spec/helpers/present_screen.rb +0 -26
  89. data/spec/helpers/screen_module_view_controller.rb +0 -55
  90. data/spec/helpers/tab_screen.rb +0 -4
  91. data/spec/helpers/table_screen.rb +0 -117
  92. data/spec/helpers/table_screen_indexable.rb +0 -18
  93. data/spec/helpers/table_screen_refreshable.rb +0 -11
  94. data/spec/helpers/table_screen_searchable.rb +0 -72
  95. data/spec/helpers/test_delegate.rb +0 -34
  96. data/spec/helpers/test_delegate_colors.rb +0 -17
  97. data/spec/helpers/view_title_screen.rb +0 -15
  98. data/spec/helpers/web_screen.rb +0 -23
  99. data/spec/unit/map_spec.rb +0 -71
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bef0e1c2d9dac5c7bc580ea6950a36c477446ec5
4
- data.tar.gz: b6a8b220631abbe37a357f67f11ba43287569465
3
+ metadata.gz: 71f77fdb9b22a8f0cd193388c516ccdc22a1e809
4
+ data.tar.gz: 180d0751d10df56d4c1f3a17bb689a8b584b0bd3
5
5
  SHA512:
6
- metadata.gz: 6bd4b1cd897fef08e8a476038acd43027d22d00d611fee8b4552bb36e10e89acfc7fdbee33c03574de25ebf599ef0b34fe3e736500739bd2ee6a573826615402
7
- data.tar.gz: fa0fd455ad6e3e4e86ae0feff264215efa5962f7d3a5e913c6dfc3632edca57680ad89ab27d26aa20614c35969f5b93c322483c1f537304638f84bc8b643ccb2
6
+ metadata.gz: c2e5f9f37a826c0456b47995ecf36b8240ec45d07244523aa18256e2f8882f445973f950f6f389321b260c63c8f5608c1cc7d601de433d85d0aa01ff4d6e1fdd
7
+ data.tar.gz: 30404bfa59a50c7212a7881b40062f242001b5b5f46bff2b4d87f450a66421f28594e0179a12a7e1a6106054fe94d70cc52f6c7924a505e538701c67b2fe2096
data/README.md CHANGED
@@ -7,12 +7,15 @@ It introduces a clean, Ruby-style syntax for building screens that is easy to le
7
7
  abstracts a ton of boilerplate UIViewController, UINavigationController, and other iOS code into a
8
8
  simple, Ruby-like DSL.
9
9
 
10
- Watch the [September Motion Meetup](http://www.youtube.com/watch?v=rf7h-3AiMRQ) where Gant Laborde
10
+ * Watch Jamon Holmgren give a talk about ProMotion at [RubyMotion #inspect2014](http://confreaks.com/videos/3813-inspect-going-pro-with-promotion-from-prototype-to-production) (video)
11
+ * Watch the [September 2013 Motion Meetup](http://www.youtube.com/watch?v=rf7h-3AiMRQ) where Gant Laborde
11
12
  interviews Jamon Holmgren about ProMotion!
12
13
 
13
14
  ```ruby
14
15
  # app/app_delegate.rb
15
16
  class AppDelegate < PM::Delegate
17
+ status_bar true, animation: :fade
18
+
16
19
  def on_load(app, options)
17
20
  open RootScreen.new(nav_bar: true)
18
21
  end
@@ -78,16 +81,39 @@ end
78
81
  2. Watch the excellent [MotionInMotion screencast about ProMotion](https://motioninmotion.tv/screencasts/8) (very reasonably priced subscription required)
79
82
  3. Follow a tutorial: [Building an ESPN app using RubyMotion, ProMotion, and TDD](http://jamonholmgren.com/building-an-espn-app-using-rubymotion-promotion-and-tdd)
80
83
 
81
- # What's New?
84
+ # Changelog
85
+
86
+ ## Version 2.0.0
87
+
88
+ Overview: In ProMotion 2.0, we removed deprecated APIs, refactored and cleaned up a ton of code, pulled `PushNotification` and `MapScreen` into their own gems, and simplified the API. It now builds 55% faster and is 20%+ lighter.
89
+
90
+ **API changes**
91
+
92
+ 1. Extracted `PM::MapScreen` into [ProMotion-map](https://github.com/clearsightstudio/ProMotion-map)
93
+ 2. Extracted `PM::PushNotification` into [ProMotion-push](https://github.com/clearsightstudio/ProMotion-push)
94
+ 3. You can't pass a UIImage or UIView into a `title` anymore. Instead, pass a string into `title_image` (it'll fetch the image for you and create a UIImageView) or pass any arbitrary view into `title_view`. Now, `title` only takes a string title.
95
+ 4. `on_create` has been renamed `screen_init` to avoid confusion with Android's `onCreate` method. It may be reintroduced in a future version of ProMotion as an alias of `onCreate`. We recommend using `on_init` instead.
96
+ 5. `set_nav_bar_right_button` and `set_nav_bar_left_button` have been removed. Use `set_nav_bar_button :right` and `:left` instead.
97
+ 6. Added `NSString#to_url` and `NSURL#to_url` helper methods to help clean up a lot of code.
98
+ 7. `present_modal_view_controller` now takes two arguments: the ViewController and an argument hash. You shouldn't have been using it in the first place.
99
+ 8. `open_in_tab` now properly opens screens in tabs that didn't have a nav_bar. This is probably the closest thing to a new feature in PM 2.0 that we have, even though it should have worked before.
100
+ 9. Cell hash arbitrary values are no longer applied directly to the cell. Instead, use the style: hash to apply arbitrary attributes. [Example here](https://github.com/clearsightstudio/ProMotion/pull/457/files#discussion_r13211807).
101
+ 10. Removed cell hash `:subviews` attribute. Instead, subclass `PM::TableViewCell` and add your own subviews there.
102
+ 11. Actually, there is one new feature. It's called `longpressable`. By adding `longpressable` at the top of your `PM::TableScreen` and then supplying a `long_press_action:` in your cell hash, you can implement a different action for long presses on table cells.
103
+ 12. We no longer insert the cell hash into the arguments hash passed into your cell tap action. If you need that data, pass it in manually.
104
+ 13. Removed `add_element`, `add_view`, `remove_element`, `remove_view` aliases for `add` and `remove`.
105
+ 14. `on_load` now fires on `viewDidLoad` instead of `loadView`. Added a new `load_view` hook for that method & you can set your own view in there. If you don't implement `load_view`, one will be created for you (per Apple's recommendations). This change shouldn't change much in your app except that if you're setting `self.view = something`, you should do it in `load_view`.
82
106
 
83
- ## Version 1.2.x
107
+ **Internal changes:**
84
108
 
85
- 1. Now uses [motion-require](https://github.com/clayallsopp/motion-require) for better compatibility with other libraries [6046dd7f4](https://github.com/clearsightstudio/ProMotion/commit/6046dd7f49ba174f309baaa428eaac80ce0290b6)
86
- 2. SplitScreen: New option `swipe:` allows you to specify if a splitscreen master screen can be opened with a swipe. [ffbb76caf](https://github.com/clearsightstudio/ProMotion/commit/ffbb76caf3071297347d4cf43784069999a746b3)
87
- 3. FormotionScreen: Removed `PM::FormotionScreen` and the Formotion testing dependency. Use [ProMotion-formotion](https://github.com/rheoli/ProMotion-formotion) instead.
88
- 4. Styling: Added a `content_width` helper to PM::Styling (similar to `content_height`) [08a984815](https://github.com/clearsightstudio/ProMotion/commit/08a984815a7c96b9465c31b2e2664ac0086d2e1c)
89
- 5. TableScreen: Removed SDWebImage in favor of similar but more reliable JDImageCache [59ed747e9](https://github.com/clearsightstudio/ProMotion/commit/59ed747e93567e32bdb5099fed12297161cea05a)
90
- 6. Screen: Allow custom views (including images) for `title` setting [#415](https://github.com/clearsightstudio/ProMotion/pull/415)
109
+ 1. Removed `motion-require`. ProMotion now relies entirely on RubyMotion's built-in dependency detector.
110
+ 2. Removed `rake spec:unit`, `rake spec:func`, `rake spec:single filename`. We don't really use these for development anymore.
111
+ 3. Moved many files around into a more logical, simpler structure.
112
+ 4. Removed `PM::Conversions`. The only helper we were using was the `objective_c_method_name` method, and that was only used in `PM::Styling`. So we moved it there.
113
+ 5. New module, `PM::NavBarModule`. Moved any navigation controller methods into this module, cleaning up the `PM::ScreenModule` quite a bit.
114
+ 6. Lots of code refactoring -- CodeClimate went from 2.47 to 3.42 GPA.
115
+ 7. Much cleaner `open` code!
116
+ 8. Converted several *slow* functional tests into *fast* unit tests with the same coverage.
91
117
 
92
118
  # API Reference
93
119
 
@@ -97,7 +123,7 @@ We've created a comprehensive and always updated wiki with code examples, usage
97
123
 
98
124
  # Help
99
125
 
100
- ProMotion is not only an easy DSL to get started. The community is very helpful and
126
+ ProMotion is not only an easy DSL to get started. The community is very helpful and
101
127
  welcoming to new RubyMotion developers. We don't mind newbie questions.
102
128
 
103
129
  If you need help, feel free to tweet [@jamonholmgren](http://twitter.com/jamonholmgren)
data/lib/ProMotion.rb CHANGED
@@ -1,3 +1,12 @@
1
- require 'motion-require'
1
+ unless defined?(Motion::Project::Config)
2
+ raise "The ProMotion gem must be required within a RubyMotion project Rakefile."
3
+ end
2
4
 
3
- Motion::Require.all(Dir.glob(File.expand_path('../ProMotion/**/*.rb', __FILE__)))
5
+ Motion::Project::App.setup do |app|
6
+ core_lib = File.join(File.dirname(__FILE__), 'ProMotion')
7
+ insert_point = app.files.find_index { |file| file =~ /^(?:\.\/)?app\// } || 0
8
+
9
+ Dir.glob(File.join(core_lib, '**/*.rb')).reverse.each do |file|
10
+ app.files.insert(insert_point, file)
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ class NSString
2
+ def to_url
3
+ NSURL.URLWithString(self)
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class NSURL
2
+ def to_url
3
+ self
4
+ end
5
+ end
@@ -4,16 +4,14 @@ module ProMotion
4
4
  def self.new(*screens)
5
5
  tab_bar_controller = alloc.init
6
6
 
7
- view_controllers = []
8
-
9
7
  screens = screens.flatten.map { |s| s.respond_to?(:new) ? s.new : s } # Initialize any classes
10
8
 
11
9
  tag_index = 0
12
- screens.each do |s|
10
+ view_controllers = screens.map do |s|
13
11
  s.tabBarItem.tag = tag_index
14
- s.tab_bar = tab_bar_controller if s.respond_to?("tab_bar=")
15
- view_controllers << (s.navigationController || s)
12
+ s.tab_bar = WeakRef.new(tab_bar_controller) if s.respond_to?("tab_bar=")
16
13
  tag_index += 1
14
+ s.navigationController || s
17
15
  end
18
16
 
19
17
  tab_bar_controller.viewControllers = view_controllers
@@ -28,7 +26,7 @@ module ProMotion
28
26
  end
29
27
 
30
28
  if selected_tab_vc
31
- self.selectedViewController = selected_tab_vc if selected_tab_vc
29
+ self.selectedViewController = selected_tab_vc
32
30
  else
33
31
  PM.logger.error "Unable to open tab #{tab.to_s} -- not found."
34
32
  nil
@@ -36,7 +34,7 @@ module ProMotion
36
34
  end
37
35
 
38
36
  def find_tab(tab_title)
39
- self.viewControllers.select{ |vc| vc.tabBarItem.title == tab_title }.first
37
+ self.viewControllers.find { |vc| vc.tabBarItem.title == tab_title }
40
38
  end
41
39
 
42
40
  end
@@ -1,21 +1,5 @@
1
- motion_require '../table/cell/table_view_cell_module'
2
-
3
1
  module ProMotion
4
2
  class TableViewCell < UITableViewCell
5
3
  include TableViewCellModule
6
-
7
- attr_accessor :image_size
8
-
9
- # TODO: Is this necessary?
10
- def layoutSubviews
11
- super
12
-
13
- if self.image_size && self.imageView.image && self.imageView.image.size && self.imageView.image.size.width > 0
14
- f = self.imageView.frame
15
- size_inset_x = (self.imageView.size.width - self.image_size) / 2
16
- size_inset_y = (self.imageView.size.height - self.image_size) / 2
17
- self.imageView.frame = CGRectInset(f, size_inset_x, size_inset_y)
18
- end
19
- end
20
4
  end
21
5
  end
@@ -2,13 +2,12 @@ module ProMotion
2
2
  class TableViewController < UITableViewController
3
3
  def self.new(args = {})
4
4
  s = self.alloc.initWithStyle(table_style)
5
- s.on_create(args) if s.respond_to?(:on_create)
5
+ s.screen_init(args) if s.respond_to?(:screen_init)
6
6
  s
7
7
  end
8
8
 
9
9
  def loadView
10
- super
11
- self.send(:on_load) if self.respond_to?(:on_load)
10
+ self.respond_to?(:load_view) ? self.load_view : super
12
11
  end
13
12
 
14
13
  def viewDidLoad
@@ -2,13 +2,12 @@ module ProMotion
2
2
  class ViewController < UIViewController
3
3
  def self.new(args = {})
4
4
  s = self.alloc.initWithNibName(args[:nib_name] || nil, bundle:args[:bundle] || nil)
5
- s.on_create(args) if s.respond_to?(:on_create)
5
+ s.screen_init(args) if s.respond_to?(:screen_init)
6
6
  s
7
7
  end
8
8
 
9
9
  def loadView
10
- super
11
- self.send(:on_load) if self.respond_to?(:on_load)
10
+ self.respond_to?(:load_view) ? self.load_view : super
12
11
  end
13
12
 
14
13
  def viewDidLoad
@@ -32,9 +31,7 @@ module ProMotion
32
31
  end
33
32
 
34
33
  def viewDidDisappear(animated)
35
- if self.respond_to?("view_did_disappear:")
36
- self.view_did_disappear(animated)
37
- end
34
+ self.view_did_disappear(animated) if self.respond_to?("view_did_disappear:")
38
35
  super
39
36
  end
40
37
 
@@ -1,6 +1,3 @@
1
- motion_require 'delegate_module'
2
- motion_require 'delegate_parent'
3
-
4
1
  module ProMotion
5
2
  class Delegate < DelegateParent
6
3
  include ProMotion::DelegateModule
@@ -1,14 +1,9 @@
1
- motion_require '../containers/tabs'
2
- motion_require '../containers/split_screen'
3
- motion_require 'delegate_notifications'
4
-
5
1
  module ProMotion
6
2
  module DelegateModule
7
3
  include ProMotion::Tabs
8
4
  include ProMotion::SplitScreen if UIDevice.currentDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad
9
- include ProMotion::DelegateNotifications
10
5
 
11
- attr_accessor :window, :aps_notification, :home_screen
6
+ attr_accessor :window, :home_screen
12
7
 
13
8
  def application(application, willFinishLaunchingWithOptions:launch_options)
14
9
  will_load(application, launch_options) if respond_to?(:will_load)
@@ -18,32 +13,33 @@ module ProMotion
18
13
  def application(application, didFinishLaunchingWithOptions:launch_options)
19
14
  apply_status_bar
20
15
  on_load application, launch_options
21
- check_for_push_notification launch_options
16
+ # Requires 'ProMotion-push' gem.
17
+ check_for_push_notification(launch_options) if respond_to?(:check_for_push_notification)
22
18
  super rescue true # Can cause error message if no super is found, but it's harmless. Ignore.
23
19
  end
24
20
 
25
21
  def applicationDidBecomeActive(application)
26
- on_activate if respond_to?(:on_activate)
22
+ try :on_activate
27
23
  end
28
24
 
29
25
  def applicationWillResignActive(application)
30
- will_deactivate if respond_to?(:will_deactivate)
26
+ try :will_deactivate
31
27
  end
32
28
 
33
29
  def applicationDidEnterBackground(application)
34
- on_enter_background if respond_to?(:on_enter_background)
30
+ try :on_enter_background
35
31
  end
36
32
 
37
33
  def applicationWillEnterForeground(application)
38
- will_enter_foreground if respond_to?(:will_enter_foreground)
34
+ try :will_enter_foreground
39
35
  end
40
36
 
41
37
  def applicationWillTerminate(application)
42
- on_unload if respond_to?(:on_unload)
38
+ try :on_unload
43
39
  end
44
40
 
45
41
  def application(application, openURL: url, sourceApplication:source_app, annotation: annotation)
46
- on_open_url({ url: url, source_app: source_app, annotation: annotation }) if respond_to?(:on_open_url)
42
+ try :on_open_url, { url: url, source_app: source_app, annotation: annotation }
47
43
  end
48
44
 
49
45
  def app_delegate
@@ -51,15 +47,14 @@ module ProMotion
51
47
  end
52
48
 
53
49
  def app_window
54
- self.window
50
+ window
55
51
  end
56
52
 
57
53
  def ui_window
58
54
  (defined?(Motion) && defined?(Motion::Xray) && defined?(Motion::Xray::XrayWindow)) ? Motion::Xray::XrayWindow : UIWindow
59
55
  end
60
56
 
61
- def open_screen(screen, args={})
62
-
57
+ def open(screen, args={})
63
58
  screen = screen.new if screen.respond_to?(:new)
64
59
 
65
60
  self.home_screen = screen
@@ -71,18 +66,25 @@ module ProMotion
71
66
 
72
67
  screen
73
68
  end
74
- alias :open :open_screen
69
+ alias :open_screen :open
75
70
  alias :open_root_screen :open_screen
76
- alias :home :open_screen
71
+
72
+ def status_bar?
73
+ UIApplication.sharedApplication.statusBarHidden
74
+ end
75
+
76
+ private
77
77
 
78
78
  def apply_status_bar
79
79
  self.class.send(:apply_status_bar)
80
80
  end
81
81
 
82
- def status_bar?
83
- UIApplication.sharedApplication.statusBarHidden
82
+ def try(method, *args)
83
+ send(method, *args) if respond_to?(method)
84
84
  end
85
85
 
86
+ public
87
+
86
88
  module ClassMethods
87
89
 
88
90
  def status_bar(visible = true, opts={})
@@ -107,9 +109,11 @@ module ProMotion
107
109
  def tint_color(c)
108
110
  @tint_color = c
109
111
  end
112
+
110
113
  def tint_color=(c)
111
114
  @tint_color = c
112
115
  end
116
+
113
117
  def get_tint_color
114
118
  @tint_color || nil
115
119
  end
@@ -1,53 +1,51 @@
1
1
  module ProMotion
2
2
  module SplitScreen
3
- def split_screen_controller(master, detail)
4
- master_main = master.navigationController ? master.navigationController : master
5
- detail_main = detail.navigationController ? detail.navigationController : detail
6
-
7
- split = SplitViewController.alloc.init
8
- split.viewControllers = [ master_main, detail_main ]
9
- split.delegate = self
10
-
11
- [ master, detail ].map { |s| s.split_screen = split if s.respond_to?(:split_screen=) }
12
-
3
+ def open_split_screen(master, detail, args={})
4
+ split = create_split_screen(master, detail, args)
5
+ open split, args
13
6
  split
14
7
  end
15
8
 
16
9
  def create_split_screen(master, detail, args={})
17
10
  master = master.new if master.respond_to?(:new)
18
11
  detail = detail.new if detail.respond_to?(:new)
19
-
20
- split = split_screen_controller master, detail
21
- if args.has_key?(:icon) or args.has_key?(:title)
22
- split.tabBarItem = create_tab_bar_item(args)
23
- end
24
-
25
- if args.has_key?(:button_title)
26
- @button_title = args[:button_title]
27
- end
28
-
29
- if args.has_key?(:swipe)
30
- split.presentsWithGesture = args[:swipe]
31
- end
32
-
33
- split
34
- end
35
-
36
- def open_split_screen(master, detail, args={})
37
- split = create_split_screen(master, detail, args)
38
- open split, args
12
+ split = split_screen_controller(master, detail)
13
+ split_screen_setup(split, args)
39
14
  split
40
15
  end
41
16
 
42
17
  # UISplitViewControllerDelegate methods
43
18
 
44
19
  def splitViewController(svc, willHideViewController: vc, withBarButtonItem: button, forPopoverController: pc)
45
- button.title = @button_title || vc.title
46
- svc.detail_screen.navigationItem.leftBarButtonItem = button;
20
+ button.title = @pm_split_screen_button_title || vc.title
21
+ svc.detail_screen.navigationItem.leftBarButtonItem = button
47
22
  end
48
23
 
49
24
  def splitViewController(svc, willShowViewController: vc, invalidatingBarButtonItem: barButtonItem)
50
25
  svc.detail_screen.navigationItem.leftBarButtonItem = nil
51
26
  end
27
+
28
+ private
29
+
30
+ def split_screen_controller(master, detail)
31
+ split = SplitViewController.alloc.init
32
+ split.viewControllers = [ (master.navigationController || master), (detail.navigationController || detail) ]
33
+ split.delegate = self
34
+
35
+ [ master, detail ].map { |s| s.split_screen = split if s.respond_to?(:split_screen=) }
36
+
37
+ split
38
+ end
39
+
40
+ def split_screen_setup(split, args)
41
+ args[:icon] ||= args[:item] # TODO: Remove in PM 2.2+.
42
+ if (args[:item] || args[:title]) && respond_to?(:create_tab_bar_item)
43
+ split.tabBarItem = create_tab_bar_item(args)
44
+ end
45
+ @pm_split_screen_button_title = args[:button_title] if args.has_key?(:button_title)
46
+ split.presentsWithGesture = args[:swipe] if args.has_key?(:swipe)
47
+ end
48
+
52
49
  end
50
+
53
51
  end
@@ -36,26 +36,27 @@ module ProMotion
36
36
  return if defined?(RUBYMOTION_ENV) && RUBYMOTION_ENV == "test"
37
37
  color = COLORS[color] || COLORS[:default]
38
38
  puts color[0] + NAME + "[#{label}] #{message_text}" + color[1]
39
+ nil
39
40
  end
40
41
 
41
42
  def error(message)
42
- self.log('ERROR', message, :red) if self.levels.include?(:error)
43
+ log('ERROR', message, :red) if self.levels.include?(:error)
43
44
  end
44
45
 
45
46
  def deprecated(message)
46
- self.log('DEPRECATED', message, :yellow) if self.levels.include?(:warn)
47
+ log('DEPRECATED', message, :yellow) if self.levels.include?(:warn)
47
48
  end
48
49
 
49
50
  def warn(message)
50
- self.log('WARN', message, :yellow) if self.levels.include?(:warn)
51
+ log('WARN', message, :yellow) if self.levels.include?(:warn)
51
52
  end
52
53
 
53
54
  def debug(message)
54
- self.log('DEBUG', message, :purple) if self.levels.include?(:debug)
55
+ log('DEBUG', message, :purple) if self.levels.include?(:debug)
55
56
  end
56
57
 
57
58
  def info(message)
58
- self.log('INFO', message, :green) if self.levels.include?(:info)
59
+ log('INFO', message, :green) if self.levels.include?(:info)
59
60
  end
60
61
 
61
62
  end