ProMotion 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -3
- data/lib/ProMotion/AppDelegate.rb +2 -2
- data/lib/ProMotion/_modules/ScreenNavigation.rb +40 -8
- data/lib/ProMotion/classes/Screen.rb +24 -13
- data/lib/ProMotion/classes/TableScreen.rb +6 -1
- data/lib/ProMotion/helpers/motion-table/1st/searchable_table.rb +0 -2
- data/lib/ProMotion/helpers/motion-table/1st/sectioned_table.rb +0 -1
- data/lib/ProMotion/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -76,8 +76,8 @@ element before it is dropped into the view.
|
|
76
76
|
Add a nav_bar button and a tab_bar icon:
|
77
77
|
|
78
78
|
```ruby
|
79
|
-
|
80
|
-
set_tab_bar_item
|
79
|
+
set_nav_bar_right_button "Save", action: :save_something, type: UIBarButtonItemStyleDone
|
80
|
+
set_tab_bar_item title: "Contacts", system_icon: UITabBarSystemItemContacts
|
81
81
|
```
|
82
82
|
|
83
83
|
Open a new screen:
|
@@ -162,7 +162,7 @@ it to the current view. Screens include this helper by default.
|
|
162
162
|
backgroundColor: UIColor.whiteColor
|
163
163
|
}
|
164
164
|
|
165
|
-
@element = set_attributes
|
165
|
+
@element = set_attributes UIView.alloc.initWithFrame(CGRectMake(0, 0, 20, 20)), {
|
166
166
|
backgroundColor: UIColor.whiteColor
|
167
167
|
}
|
168
168
|
```
|
@@ -45,8 +45,8 @@ module ProMotion
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def open_home_screen
|
48
|
-
|
49
|
-
load_root_view
|
48
|
+
get_home_screen.send(:on_load) if get_home_screen.respond_to?(:on_load)
|
49
|
+
load_root_view get_home_screen.main_controller
|
50
50
|
end
|
51
51
|
|
52
52
|
def get_home_screen
|
@@ -3,18 +3,26 @@ module ProMotion
|
|
3
3
|
def open_screen(screen, args = {})
|
4
4
|
# Instantiate screen if given a class instead
|
5
5
|
screen = screen.new if screen.respond_to? :new
|
6
|
-
|
6
|
+
|
7
7
|
screen.parent_screen = self
|
8
|
+
screen.view_controller.title = args[:title] if args[:title]
|
8
9
|
|
9
|
-
screen.
|
10
|
+
screen.add_nav_bar if args[:nav_bar]
|
11
|
+
unless args[:close_all] || args[:modal]
|
12
|
+
screen.navigation_controller ||= self.navigation_controller
|
13
|
+
end
|
10
14
|
|
15
|
+
screen.main_controller.hidesBottomBarWhenPushed = args[:hide_tab_bar] if args[:hide_tab_bar]
|
16
|
+
|
17
|
+
screen.modal = args[:modal] if args[:modal]
|
18
|
+
|
19
|
+
screen.send(:on_load) if screen.respond_to?(:on_load)
|
20
|
+
|
11
21
|
if args[:close_all]
|
12
22
|
fresh_start(screen)
|
13
23
|
elsif args[:modal]
|
14
|
-
screen.modal = true
|
15
24
|
self.view_controller.presentModalViewController(screen.main_controller, animated:true)
|
16
25
|
elsif self.navigation_controller
|
17
|
-
screen.navigation_controller = self.navigation_controller
|
18
26
|
push_view_controller screen.view_controller
|
19
27
|
else
|
20
28
|
open_view_controller screen.main_controller
|
@@ -32,14 +40,24 @@ module ProMotion
|
|
32
40
|
end
|
33
41
|
|
34
42
|
def close_screen(args = {})
|
43
|
+
args ||= {}
|
44
|
+
|
35
45
|
# Pop current view, maybe with arguments, if in navigation controller
|
46
|
+
previous_screen = self.parent_screen
|
36
47
|
if self.is_modal?
|
37
48
|
self.parent_screen.view_controller.dismissModalViewControllerAnimated(true)
|
38
49
|
elsif self.navigation_controller
|
39
|
-
|
50
|
+
if args[:to_screen]
|
51
|
+
self.navigation_controller.popToViewController(args[:to_screen].view_controller, animated: true)
|
52
|
+
previous_screen = args[:to_screen]
|
53
|
+
else
|
54
|
+
self.navigation_controller.popViewControllerAnimated(true)
|
55
|
+
end
|
40
56
|
else
|
41
|
-
#
|
57
|
+
Console.log("Tried to close #{self.to_s}; however, this screen isn't modal or in a nav bar.", withColor: Console::PURPLE_COLOR)
|
42
58
|
end
|
59
|
+
|
60
|
+
previous_screen.send(:on_return, args) if previous_screen && previous_screen.respond_to?(:on_return)
|
43
61
|
end
|
44
62
|
|
45
63
|
def tab_bar_controller(*screens)
|
@@ -61,21 +79,35 @@ module ProMotion
|
|
61
79
|
|
62
80
|
def open_tab_bar(*screens)
|
63
81
|
tab_bar = tab_bar_controller(*screens)
|
82
|
+
|
83
|
+
screens.each do |s|
|
84
|
+
s.parent_screen = self if s.respond_to? "parent_screen="
|
85
|
+
s.on_load if s.respond_to? :on_load
|
86
|
+
end
|
87
|
+
|
64
88
|
open_view_controller tab_bar
|
89
|
+
|
65
90
|
screens.each do |s|
|
66
91
|
s.on_opened if s.respond_to? :on_opened
|
67
|
-
s.parent_screen = self if s.respond_to? "parent_screen="
|
68
92
|
end
|
93
|
+
|
69
94
|
tab_bar
|
70
95
|
end
|
71
96
|
|
72
97
|
def push_tab_bar(*screens)
|
73
98
|
tab_bar = tab_bar_controller(*screens)
|
99
|
+
|
100
|
+
screens.each do |s|
|
101
|
+
s.parent_screen = self if s.respond_to? "parent_screen="
|
102
|
+
s.on_load if s.respond_to? :on_load
|
103
|
+
end
|
104
|
+
|
74
105
|
push_view_controller tab_bar
|
106
|
+
|
75
107
|
screens.each do |s|
|
76
108
|
s.on_opened if s.respond_to? :on_opened
|
77
|
-
s.parent_screen = self if s.respond_to? "parent_screen="
|
78
109
|
end
|
110
|
+
|
79
111
|
tab_bar
|
80
112
|
end
|
81
113
|
|
@@ -6,26 +6,28 @@ module ProMotion
|
|
6
6
|
|
7
7
|
attr_accessor :view_controller, :navigation_controller, :parent_screen, :first_screen, :tab_bar_item, :modal
|
8
8
|
|
9
|
-
def initialize(
|
10
|
-
|
9
|
+
def initialize(args = {})
|
10
|
+
args.each do |k, v|
|
11
11
|
self.send "#{k}=", v if self.respond_to? "#{k}="
|
12
12
|
end
|
13
|
-
|
14
13
|
self.load_view_controller
|
15
|
-
|
16
14
|
self.view_controller.title = self.title
|
17
|
-
|
18
|
-
self.add_nav_bar if attrs[:nav_bar]
|
19
|
-
|
20
|
-
self.on_load if self.respond_to? :on_load
|
21
15
|
|
16
|
+
self.add_nav_bar if args[:nav_bar]
|
17
|
+
self.on_init if self.respond_to? :on_init
|
22
18
|
self
|
23
19
|
end
|
24
20
|
|
25
21
|
def is_modal?
|
26
|
-
self.modal
|
22
|
+
$stderr.puts self.modal
|
23
|
+
self.modal == true
|
24
|
+
end
|
25
|
+
|
26
|
+
def has_nav_bar?
|
27
|
+
self.navigation_controller.nil? != true
|
27
28
|
end
|
28
29
|
|
30
|
+
# Note: this is overridden in TableScreen
|
29
31
|
def load_view_controller
|
30
32
|
self.view_controller ||= ViewController
|
31
33
|
end
|
@@ -40,10 +42,8 @@ module ProMotion
|
|
40
42
|
end
|
41
43
|
|
42
44
|
def add_nav_bar
|
43
|
-
|
44
|
-
|
45
|
-
self.first_screen = true
|
46
|
-
end
|
45
|
+
self.navigation_controller = NavigationController.alloc.initWithRootViewController(self.view_controller)
|
46
|
+
self.first_screen = true
|
47
47
|
end
|
48
48
|
|
49
49
|
def set_nav_bar_right_button(title, args={})
|
@@ -53,6 +53,17 @@ module ProMotion
|
|
53
53
|
|
54
54
|
right_button = UIBarButtonItem.alloc.initWithTitle(title, style: args[:style], target: args[:target], action: args[:action])
|
55
55
|
self.view_controller.navigationItem.rightBarButtonItem = right_button
|
56
|
+
right_button
|
57
|
+
end
|
58
|
+
|
59
|
+
def set_nav_bar_left_button(title, args={})
|
60
|
+
args[:style] ||= UIBarButtonItemStyleBordered
|
61
|
+
args[:target] ||= self
|
62
|
+
args[:action] ||= nil
|
63
|
+
|
64
|
+
left_button = UIBarButtonItem.alloc.initWithTitle(title, style: args[:style], target: args[:target], action: args[:action])
|
65
|
+
self.view_controller.navigationItem.leftBarButtonItem = left_button
|
66
|
+
left_button
|
56
67
|
end
|
57
68
|
|
58
69
|
def view_controller=(vc)
|
@@ -9,7 +9,8 @@ module ProMotion
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def load_view_controller
|
12
|
-
|
12
|
+
check_table_data_method
|
13
|
+
|
13
14
|
self.view_controller ||= TableViewController
|
14
15
|
self.view_controller.view = self.createTableViewFromData(self.table_data)
|
15
16
|
if self.class.get_searchable
|
@@ -17,6 +18,10 @@ module ProMotion
|
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
21
|
+
def check_table_data_method
|
22
|
+
Console.log("- table_data method needed in table view screen.", withColor: Console::RED_COLOR) unless self.respond_to? :table_data
|
23
|
+
end
|
24
|
+
|
20
25
|
def update_table_data
|
21
26
|
self.updateTableViewData(table_data)
|
22
27
|
end
|
@@ -97,7 +97,6 @@ module ProMotion::MotionTable
|
|
97
97
|
end
|
98
98
|
|
99
99
|
def triggerAction(action, arguments)
|
100
|
-
$stderr.puts "Action: #{action.to_s} and args #{arguments.to_s}"
|
101
100
|
if self.respond_to?(action)
|
102
101
|
expectedArguments = self.method(action).arity
|
103
102
|
if expectedArguments == 0
|
data/lib/ProMotion/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ProMotion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-09-
|
14
|
+
date: 2012-09-12 00:00:00.000000000 Z
|
15
15
|
dependencies: []
|
16
16
|
description: ProMotion is a new way to organize RubyMotion apps.
|
17
17
|
email:
|