ProMotion 1.2.1 → 2.0.0.rc1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +36 -10
- data/lib/ProMotion.rb +11 -2
- data/lib/ProMotion/cocoatouch/ns_string.rb +5 -0
- data/lib/ProMotion/cocoatouch/ns_url.rb +5 -0
- data/lib/ProMotion/cocoatouch/tab_bar_controller.rb +5 -7
- data/lib/ProMotion/cocoatouch/table_view_cell.rb +0 -16
- data/lib/ProMotion/cocoatouch/table_view_controller.rb +2 -3
- data/lib/ProMotion/cocoatouch/view_controller.rb +3 -6
- data/lib/ProMotion/delegate/delegate.rb +0 -3
- data/lib/ProMotion/delegate/delegate_module.rb +24 -20
- data/lib/ProMotion/{containers → ipad}/split_screen.rb +30 -32
- data/lib/ProMotion/{logger.rb → logger/logger.rb} +6 -5
- data/lib/ProMotion/screen/nav_bar_module.rb +126 -0
- data/lib/ProMotion/screen/screen.rb +0 -3
- data/lib/ProMotion/screen/screen_module.rb +54 -177
- data/lib/ProMotion/screen/screen_navigation.rb +29 -40
- data/lib/ProMotion/{view → styling}/styling.rb +17 -47
- data/lib/ProMotion/table/cell/table_view_cell_module.rb +76 -123
- data/lib/ProMotion/table/data/table_data.rb +1 -1
- data/lib/ProMotion/table/extensions/longpressable.rb +24 -0
- data/lib/ProMotion/table/extensions/refreshable.rb +1 -0
- data/lib/ProMotion/table/grouped_table_screen.rb +0 -5
- data/lib/ProMotion/table/table.rb +63 -83
- data/lib/ProMotion/table/table_screen.rb +0 -4
- data/lib/ProMotion/{containers → tabs}/tabs.rb +20 -21
- data/lib/ProMotion/version.rb +1 -1
- data/lib/ProMotion/web/web_screen.rb +0 -4
- data/lib/ProMotion/web/web_screen_module.rb +8 -5
- data/spec/functional/func_screen_spec.rb +14 -18
- data/spec/functional/func_split_screen_spec.rb +2 -2
- data/spec/functional/func_table_screen_spec.rb +54 -40
- data/spec/functional/func_web_screen_spec.rb +12 -17
- data/spec/helpers/test_helper.rb +27 -0
- data/spec/unit/delegate_spec.rb +4 -67
- data/spec/unit/image_title_screen.rb +9 -0
- data/spec/unit/image_view_title_screen.rb +9 -0
- data/spec/unit/load_view_spec.rb +27 -0
- data/spec/unit/main_spec.rb +0 -6
- data/spec/unit/screen_helpers_spec.rb +23 -17
- data/spec/unit/screen_spec.rb +21 -17
- data/spec/unit/searchable_table_spec.rb +55 -0
- data/spec/unit/split_screen_in_tab_bar_spec.rb +5 -5
- data/spec/unit/split_screen_spec.rb +4 -4
- data/spec/unit/tab_bar_spec.rb +79 -0
- data/spec/unit/tab_spec.rb +11 -5
- data/spec/unit/tables/table_module_spec.rb +22 -8
- data/spec/unit/tables/table_screen_spec.rb +1 -1
- data/spec/unit/tables/table_view_cell_spec.rb +16 -16
- data/spec/unit/view_helper_spec.rb +6 -81
- data/spec/unit/view_title_screen.rb +10 -0
- data/spec/unit/web_spec.rb +31 -37
- metadata +37 -111
- data/.gitignore +0 -33
- data/.travis.yml +0 -4
- data/CONTRIBUTING.md +0 -20
- data/Gemfile +0 -5
- data/LICENSE +0 -22
- data/ProMotion.gemspec +0 -30
- data/Rakefile +0 -66
- data/app/app_delegate.rb +0 -7
- data/app/screens/basic_screen.rb +0 -15
- data/lib/ProMotion/delegate/delegate_notifications.rb +0 -70
- data/lib/ProMotion/extensions/conversions.rb +0 -20
- data/lib/ProMotion/map/map_screen.rb +0 -10
- data/lib/ProMotion/map/map_screen_annotation.rb +0 -65
- data/lib/ProMotion/map/map_screen_module.rb +0 -212
- data/lib/ProMotion/push_notification/push_notification.rb +0 -58
- data/resources/WebScreen.html +0 -6
- data/resources/list.png +0 -0
- data/resources/test.png +0 -0
- data/spec/functional/func_image_title_screen.rb +0 -20
- data/spec/functional/func_image_view_title_screen.rb +0 -20
- data/spec/functional/func_map_screen_spec.rb +0 -162
- data/spec/functional/func_searchable_table_spec.rb +0 -56
- data/spec/functional/func_tab_bar_spec.rb +0 -78
- data/spec/functional/func_view_title_screen.rb +0 -21
- data/spec/helpers/basic_screen.rb +0 -3
- data/spec/helpers/custom_title_view.rb +0 -4
- data/spec/helpers/detail_screen.rb +0 -3
- data/spec/helpers/dummy_class.rb +0 -3
- data/spec/helpers/functional_screen.rb +0 -15
- data/spec/helpers/home_screen.rb +0 -19
- data/spec/helpers/image_title_screen.rb +0 -15
- data/spec/helpers/image_view_title_screen.rb +0 -15
- data/spec/helpers/map_screen.rb +0 -53
- data/spec/helpers/master_screen.rb +0 -3
- data/spec/helpers/present_screen.rb +0 -26
- data/spec/helpers/screen_module_view_controller.rb +0 -55
- data/spec/helpers/tab_screen.rb +0 -4
- data/spec/helpers/table_screen.rb +0 -117
- data/spec/helpers/table_screen_indexable.rb +0 -18
- data/spec/helpers/table_screen_refreshable.rb +0 -11
- data/spec/helpers/table_screen_searchable.rb +0 -72
- data/spec/helpers/test_delegate.rb +0 -34
- data/spec/helpers/test_delegate_colors.rb +0 -17
- data/spec/helpers/view_title_screen.rb +0 -15
- data/spec/helpers/web_screen.rb +0 -23
- data/spec/unit/map_spec.rb +0 -71
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 71f77fdb9b22a8f0cd193388c516ccdc22a1e809
|
|
4
|
+
data.tar.gz: 180d0751d10df56d4c1f3a17bb689a8b584b0bd3
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
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
|
-
#
|
|
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
|
-
|
|
107
|
+
**Internal changes:**
|
|
84
108
|
|
|
85
|
-
1.
|
|
86
|
-
2.
|
|
87
|
-
3.
|
|
88
|
-
4.
|
|
89
|
-
5.
|
|
90
|
-
6.
|
|
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
|
-
|
|
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::
|
|
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
|
|
@@ -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.
|
|
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
|
|
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.
|
|
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.
|
|
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.
|
|
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,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, :
|
|
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
|
-
|
|
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
|
-
|
|
22
|
+
try :on_activate
|
|
27
23
|
end
|
|
28
24
|
|
|
29
25
|
def applicationWillResignActive(application)
|
|
30
|
-
|
|
26
|
+
try :will_deactivate
|
|
31
27
|
end
|
|
32
28
|
|
|
33
29
|
def applicationDidEnterBackground(application)
|
|
34
|
-
|
|
30
|
+
try :on_enter_background
|
|
35
31
|
end
|
|
36
32
|
|
|
37
33
|
def applicationWillEnterForeground(application)
|
|
38
|
-
|
|
34
|
+
try :will_enter_foreground
|
|
39
35
|
end
|
|
40
36
|
|
|
41
37
|
def applicationWillTerminate(application)
|
|
42
|
-
|
|
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
|
|
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
|
-
|
|
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
|
|
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 :
|
|
69
|
+
alias :open_screen :open
|
|
75
70
|
alias :open_root_screen :open_screen
|
|
76
|
-
|
|
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
|
|
83
|
-
|
|
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
|
|
4
|
-
|
|
5
|
-
|
|
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
|
|
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 = @
|
|
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
|
-
|
|
43
|
+
log('ERROR', message, :red) if self.levels.include?(:error)
|
|
43
44
|
end
|
|
44
45
|
|
|
45
46
|
def deprecated(message)
|
|
46
|
-
|
|
47
|
+
log('DEPRECATED', message, :yellow) if self.levels.include?(:warn)
|
|
47
48
|
end
|
|
48
49
|
|
|
49
50
|
def warn(message)
|
|
50
|
-
|
|
51
|
+
log('WARN', message, :yellow) if self.levels.include?(:warn)
|
|
51
52
|
end
|
|
52
53
|
|
|
53
54
|
def debug(message)
|
|
54
|
-
|
|
55
|
+
log('DEBUG', message, :purple) if self.levels.include?(:debug)
|
|
55
56
|
end
|
|
56
57
|
|
|
57
58
|
def info(message)
|
|
58
|
-
|
|
59
|
+
log('INFO', message, :green) if self.levels.include?(:info)
|
|
59
60
|
end
|
|
60
61
|
|
|
61
62
|
end
|